texts:
The output of hash function SHA256 is a hex string of size 64. For example: 3ed54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab

I want to call the function of a smart contract with the following structure:

function register(bytes32 hash)

and pass the hex as an argument.

I use the web3 JavaScript library.

First I tried to pass the argument without any conversion. The result was a truncation of the last 32 bytes

Then I tried web3's fromAscii function with the same results.

I also tried hexToBytes and bytesToHex functions from the 1.x version. hexToBytes returns a byte array of size 32. When I pass the array to the smart contract function the results are totally different from the expected ones.

So how do I convert a hex of 32 bytes (64 character hex) in a format suitable for a bytes32 function argument ?

I know I can use bytes or string instead of bytes32 but I would rather avoid it as the hex of SHA256 is indeed 32 bytes.

EDIT

I create a test contract and test it in remix. I call set function with input 0x3fd54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab. The value is not truncated and I get the expected results.

pragma solidity ^0.4.24;

contract Test {
    bytes32 public hash;

    function set(bytes32 h) public {
        hash = h;
    }
}

So, the problem should be in the web3 library or JS itself right ?

UPDATE

I use the truffle-contract library to call my smart contract's functions


texts: How can I install the Mist wallet at d:?

texts: Windows is running on my ssd und i want not to install the mist wallet at my ssd but everytime i try to install the wallet it installs instant on c: .


texts: filter to restrict output of opcode data only to contracts/functions called by local node

texts:
Having modified the instructions.go file in geth I'm able to see the execution time of individual opcodes, it looks like this:

My interpretation of that output is that it represents the execution of all the contracts that my running node hears about, so then- all the transactions of the entire network (ropsten testnet).

The changes I made to the geth client are here:

func opAdd(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {

    // begin execution time tracking
    var startTime = time.Now().UnixNano();

    x, y := stack.pop(), stack.pop()
    stack.push(math.U256(x.Add(x, y)))

    evm.interpreter.intPool.put(y)

    // log ellapsed execution time
    fmt.Println("execute opAdd consume = ",(time.Now().UnixNano() - startTime))

    return nil, nil
}

What I'd like to do is somehow restrict that output so that it only displays for contracts/functions that I deploy from my local node, i.e. the ones that I call myself.

What I'm looking for now is, some thoughts about how to do that- not even necessarily a solution- although that would be great- but even, places to start- e.g. some code that corresponds to a similar filter/flag of sorts, all that kind of stuff, all those type of ideas would be very cool and helpful!


texts:
The contract:

pragma solidity ^0.4.19;

contract Info {
  /* some other setters */

  function ageOf(uint256 _tokenId) public view returns (uint256 age) {
        return ages[_tokenId];
  }

  function ownersAddress(uint256 _tokenId) public view returns (address addr);
}

Then, I have React Parent component:

class Parent extends React.component {
  render () {

      <Child />

  }
}

and the Child component:

export class Child extends React.Component {
  render() {

      Solidity ageOf() goes here

      Solidity ownersAddress() goes here

  }
}

I am new to Dapp development, and struggling to link these all together. Particularly, how to initiate the Solidity functions in React, and how to make the Component to "query" Ethereum so that whenever the age parameter changes it'd update the corresponding
 value?

P.S. I'm using Truffle/Ganache and Truffle's React Auth box.


texts:
Cannot deploy the code, it compiles normally on version 0.4.22 with the same compiler version. I have looked at the answer on a similar thread and changed version to 0.5.11, when I try to compile it in that version 3 more errors arise and I can't compile nor deploy. Here is the code in version 0.4.22

pragma solidity ^0.4.22;

contract SimpleAuction {
address public beneficiary1;
address public beneficiary2;
uint public auctionEnd;

// Current state of the auction.
// address public highestBidder;
//uint public highestBid;

address public highestBidder1;
uint public highestBid1;

address public highestBidder2;
uint public highestBid2;

uint public proportion;
uint public bid1;
uint public bid2;

mapping(address => uint) pendingReturns;

bool ended;

constructor (uint _biddingTime) public {
    beneficiary1 = msg.sender;
    beneficiary2 = msg.sender;
    auctionEnd = now + _biddingTime;
}

//fallback function that enables direct payments through metamask
function () public payable{
    makebid(proportion);
}

function makebid(uint var1) public payable {

    // saving variable1 as proportion
    proportion = var1;
    // creating mutiple bids;
    bid1 = var1 * msg.value;
    bid2 = 1 - var1 * msg.value;

    require(now <= auctionEnd);

    // If the bid is not higher, send the
    // money back.
    //require(msg.value > highestBid);

    //if (highestBid != 0) {
      //  pendingReturns[highestBidder] += highestBid;
    //}
    //highestBidder = msg.sender;
    //highestBid = msg.value;

//}

    require(bid1 > highestBid1);

    if (highestBid1 != 0) {

        pendingReturns[highestBidder1] += highestBid1;
    }
    highestBidder1 = msg.sender;
    highestBid1 = bid1;

    require(bid2 > highestBid2);

    if (highestBid2 != 0) {

        pendingReturns[highestBidder2] += highestBid2;
    }
    highestBidder2 = msg.sender;
    highestBid2 = bid2;

}
/// Withdraw a bid that was overbid.
function withdraw() public returns (bool) {
    uint amount1 = pendingReturns[highestBidder1];
    if (amount1 > 0) {
        pendingReturns[highestBidder1] = 0;

        if (!msg.sender.send(amount1)) {
            pendingReturns[highestBidder1] = amount1;
            return false;
        }

    uint amount2 = pendingReturns[highestBidder2];
    if (amount2 > 0) {

        pendingReturns[highestBidder2] = 0;

        if (!msg.sender.send(amount2)) {
            // No need to call throw here, just reset the amount owing
            pendingReturns[highestBidder2] = amount2;
            return false;
        }

    }
    return true;
  }

}

    // 1. Conditions
   require(now >= auctionEnd); // auction did not yet end
    require(!ended); // this function has already been called

    // 2. Effects
    ended = true;

    // 3. Interaction
    beneficiary1.transfer(highestBid1);
    beneficiary2.transfer(highestBid2);

}

}


texts: Query parity or geth to get total ethereum produced?

texts:
How do I query geth or parity to get the total coins ever mined/in circulation.
On bitcoind or any other coin based on btc core source its easy to achieve with a command line.

Something similar for ethereum?

Thanks


texts: Is the SafeMath library obsolete in solidity 0.8.0?

texts:
SafeMath was commonly used to revert the transaction on overflow and underflow, instead of allowing the number to wrap around. The solidity 0.8.0 release notes state:

Code Generator: All arithmetic is checked by default. These checks can
be disabled using unchecked { ... }.

Does this mean SafeMath is now completely obsolete when compiling with solc >= 0.8.0, or are there still situations where it can be useful?


texts: How does NONCE prevent a replay attack in case of knowing NONCE value?

texts:
I have a question about a nonce in the Ethereum network. I understand that a nonce helps to prevent a replay attack, but there is one particular part that I don't understand.

I have applied my ethereum network over Rinkeby Testnet, which all data besides the nonce is available for the public.

In case of attacker try to replay the transaction with the same value of NONCE, it's clear that a transaction will be denied as duplicate one.

However, What about if the attacker knowns the last Nonce value, for example, 48, and try to duplicate my transaction with NONCE +1, which is 49. What does happen in this case, does the transaction will be succeeded as it has a different nonce value even when the sender is the attacker?


texts: web3 contract TypeError: 'apply' is not a function

texts:
I'm Trying to call the apply function on the contract ABI but I'm getting:

TypeError: 'apply' is not a function
    at :1:1

> myContract
{
  abi: [{
      constant: false,
      inputs: [{...}],
      name: "apply",
      outputs: [],
      payable: false,
      stateMutability: "nonpayable",
      type: "function"
  }, {
      constant: true,
      inputs: [{...}],
      name: "getApplicationID",
      outputs: [{...}],
      payable: false,
      stateMutability: "view",
      type: "function"
  }],
  eth: {},
  at: function(address, callback),
  getData: function(),
  new: function()
}

var abi = [{"constant": false,"inputs":[{"name": "hash","type": "bytes32"}],"name": "apply","outputs": [],"payable": false,"stateMutability": "nonpayable","type": "function"},{"constant": true,"inputs": [{"name": "email","type": "string"}],"name": "getApplicationID","outputs":[{"name": "","type": "uint256"}],"payable": false,"stateMutability": "view","type": "function"}]
var myContract = web3.eth.contract(abi,"0xcbbfbafedb0eb83016d2a96a4e80d30b20fa3e30");
 myContract.apply("4183f3a48d92d7b874e0e2dc0353e29aee0031b0a174be6f6a2e7a289e9febca");


texts: address payable type - store address and send later using Solidity 0.5.0

texts:
Solidity 0.5.0 has separated the "address" type into two types: address payable and address. Only address payable have the address.transfer method. I don't want to use the withdrawal mechanism.

When I store the address in an array, and try to access it later I get an error from solc:

  Member "transfer" not found or not visible after argument-dependent
  lookup in address.

I guess it's because the address that I stored is not of type "address payable" (it wouldn't hurt to make this error more clear btw). But it is said in the documentation that the address returned by msg.sender is of type "address payable". So I don't quite understand. It is also said that a conversion using the type uint160 is possible, but I don't know how. Any help would be greatly appreciated

Here is a useless sample code which reproduce the problem:

pragma solidity >0.4.99 <0.6.0;
contract simple{

  address payable[] private addressIndex;
  uint price = 100;

  /* Distribute all the fund to the clients */
  function distribute() private returns (uint) {

    uint amount = (address(this).balance-1) / addressIndex.length;
    for (uint i = 0; i < addressIndex.length; i++) {
      addressIndex[i].transfer(amount); //error
    }
    return amount;
  }

  function () external payable {

    if ( msg.value != price ) { revert(); }
    addressIndex.push(msg.sender);
    distribute();
  }

}

EDIT 1: With the Solidity compiler solc v0.5.0, I had to declare all "address" variables which will receive fund in the future as "address payable". For security reasons no implicit conversion of the type "address" will be made to "address payable". Only "address payable" have the ".transfer" method. Therefore my addressIndex array of address should be declared as:

address payable[] addressIndex;


texts: How do Miner choose transactions for a block?

texts:
i am wondering how a Miner chooses the transactions, he want to mine inside a block.
For example, a Miner has got the Transactions T1 and T2 at the moment he starts a new mining work. This Miner is the one, finding the next block, which is after 10 seconds. After 8 seconds and 2 seconds before the Miner would find the next block T3 arrives at the Miner. Which transactions does the Miner then mine into the next Block, only T1 and T2 or also T3? (I assume here, the block size is bigger than the combined size of T1,T2 and T3.

So does the Miner determine at the beginning of a new mining process, which transactions go into the next block and ignores incoming transactions during the mining process of the next block?


texts:
When creating a site with MetaMask, you also want that other users who do not have MetaMask can use this site. To do this, you want to use the same library MetaMask uses - which is 0.20.3 currently.

I cannot find 0.20.3. I checked GitHub releases. Version 1.0.0-beta is up, and older versions do not hit 0.20.3

Where can I find this web3 version?


texts:
I am about to invest to ETH and I am looking for an application/website what could serve me as a wallet.

What happens if I switch a device or lose a key to my account?
What happens if the website/application goes bankrupted? Am I going to lose my money?

Based on the research what I did, it seems it's quite easy to lock yourself out from the system.


texts:
Friends. I did a stupid thing here and need your help.
I just want to delete the accounts, so I delete everything in datadir, the datadir is the directory which is used in the command below:

./geth --datadir ethereum init genesis.json

After deleting, I run the command ./geth --datadir ethereum init genesis.json

> eth.accounts
["0x6d0b5524a7cfd667a4f7ce5744c15ad31588ded4"]

but when I run command below:

superman@ubuntu:~/data/src/github.com/ethereum/go-ethereum$ ./geth account list
Account #0: {9aed02c60c71ea53e7d34f52c624ab060b467b84} keystore:///home/superman/.ethereum/keystore/UTC--2017-06-16T02-26-03.490121281Z--9aed02c60c71ea53e7d34f52c624ab060b467b84
Account #1: {acf3e3d535903e8ddeefc25cfc9a9fcec74cf60f} keystore:///home/superman/.ethereum/keystore/UTC--2017-07-20T03-04-30.295140884Z--acf3e3d535903e8ddeefc25cfc9a9fcec74cf60f

why it shows 2 accounts but there is only 1 account in geth console? And there are not same? how to solve the problem?


texts: Does ethereum wallets have HD addresses like Bitcoin? How do I generate my own seed?

texts: Bitcoin has HD wallet addresses where you can generate a 12 word seed which generates all the addresses moving forward. Does Ethereum have something like this in the mist wallet? How can someone get the same affect of an HD seed where I can just write down?


texts: How to connect peers which are on different computers in geth on private network?

texts:
I am trying to setup a private network and trying to connect peers. Currently I'm trying it on my laptop and virtual machine(VM) runing on the same laptop (both of them are connected to internet).
I init genesis file on my VM, start geth.
Then init my genesis file on laptop(same copy of file), start geth.

With help of admin.addPeer("enode://....@[ip]:30303") i add peers on both machines.

admin.peersCount returns 0


texts: Where's the Solidity code for Mist's default multi-sig contract wallet?

texts: I would like to audit the Solidity code of Mist's default multi-sig wallet contract, where is it in github exactly? Thanks


texts: Setting start date parameter on private blockchain?

texts: I have a private blockchian and I am using Parity's chain spec to create it.  The first block always gets labeled as 01/01/70 and I wonder what I must change in order to set it to today's date?


texts: Why does this function work in truffle tests and fail through metamask?

texts:
I have the following function and it has been working perfectly in truffle tests as I was developing the smart contracts and now that I am implementing it in the front end I have been getting a error only with this function.
    function deployPlanet(uint256 tokenId) public onlyTokenHolder(tokenId) {
        uint256 yield = GS.getTokenIdToYield(tokenId);
        address _address = pm.createPlanet(
            tokenId,
            abi.encodeWithSignature(
                'initialize(address,address,address,address,uint256,uint256)',
                address(pm),
                address(solar),
                address(fhr),
                address(sats),
                tokenId,
                yield
            )
        );
        GS.setTokenIdToProxyAddress(tokenId, _address);
        GS.setProxyAddressToTokenId(tokenId, _address);
    }

The function itself is calling create planet in PlanetManager, this in turn is creating a proxy Planet contract which you can view bellow.
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
import {Planet} from './Planet.sol';
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
import {ITreasury} from './interfaces/ITreasury.sol';

contract PlanetManager is Ownable {
    address public planetImplementation;
    ITreasury ts;
    mapping(address => bool) operators;
    mapping(address => uint256) addressToTokenId;
    event ProxyCreated(address proxy);

    constructor(
        address _planetImplementation,
        address _gameOperations,
        address _treasury
    ) public {
        planetImplementation = _planetImplementation;
        ts = ITreasury(_treasury);
        addOperator(_gameOperations);
    }

    function addOperator(address _operator) public onlyOwner {
        operators[_operator] = true;
    }

    modifier onlyOperator() {
        // Make sure the access is permitted to only contracts in our Dapp
        require(operators[msg.sender], 'Only Operator');
        _;
    }

    modifier onlyPlanet() {
        require(addressToTokenId[msg.sender] != 0, 'Only planets');
        _;
    }

    function createPlanet(uint256 tokenId, bytes memory _data)
        public
        onlyOperator
        returns (address)
    {
        emit ProxyCreated(planetImplementation);
        address proxy = deployMinimal(planetImplementation, _data);
        addressToTokenId[proxy] = tokenId;
        return proxy;
    }

    function rewardPlanet(address _to, uint256 _amount) public onlyPlanet {
        ts.mintSolar(_to, _amount);
    }

    function deployMinimal(address _logic, bytes memory _data) internal returns (address proxy) {
        bytes20 targetBytes = bytes20(_logic);
        assembly {
            let clone := mload(0x40)
            mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(clone, 0x14), targetBytes)
            mstore(
                add(clone, 0x28),
                0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
            )
            proxy := create(0, clone, 0x37)
        }

        emit ProxyCreated(address(proxy));
        if (_data.length > 0) {
            (bool success, ) = proxy.call(_data);
            require(success);
        }
    }
}

Here you can see the function passing in my tests and costing 250000~ gas.

Now when I have implemented the function on my frontend I get the following error from metamask. As you can see the gas cost is waaaaaay higher than calling that function in truffle. Any help is a +1 from me!


texts: I just finished reading which explains how to build a Dapp with Metamask sending Ethereum to a smart contract (Reference:  https://medium.com/@merunasgrincalaitis/the-ultimate-end-to-end-tutorial-to-create-and-deploy-a-fully-descentralized-dapp-in-ethereum-18f0cf6d7e0e). Metamask doesn't seem to support ERC20 tokens, so how can you transfer these ERC20 tokens within a Dapp instead of Ether?


texts: How to View All Properties and Attributes of a Token

texts:
I am new to Ethereum and have done the basics like go to Etherscan to view token contracts, but I'm curious to find a way to learn more about a specific token. The one I'm interested in is PumaPay. In comparing it to other ERC-20 compliant tokens, it has extremely low transaction volume yet the project is solid and is getting adoption by enterprise partners. This makes me wonder how to discern more information like can they mint new tokens on the fly and other concerns I have. Is there a way to view things like this, whether it be from a website or on the blockchain?

Contract Address

0x846c66cf71c43f80403b51fe3906b3599d63336f


texts: What exactly is Ether currency in Ethereum?

texts:
What is exactly Ether currency in Ethereum?
Is it a token or a set of some functions that generate some tokens? If so, how many of those functions exist and what do they do? Are they hardcoded in the source code or are they programmed within the virtual machine?
Because, Ether can not be a token, since tokens must have to have a finite amount in quantity according to the documentation I have read.

Or is it a contract address that does some token generation?


texts: I want to change the default download location of the chain data to an SD card instead of the internal hard drive. How can I go about it?

texts:
I want to change the default download location of the Geth chain data from the internal hard drive and use an SD card instead. How can I go about it?

OS: Ubuntu 15.10.

The hard drive is kind of small and all the IO operations on the hard drive are distracting. I think it should be possible to make Geth download the chain data to an external location, specifically an external SD card in this case. How can I do it?


texts: run geth light mode looking for peers forever

texts:
i run a geth light mode node on Ubuntu by
geth  --syncmode "light" --identity "mydev" --rpc --rpccorsdomain "*" --datadir "/root/mygeth/chain" --rpcapi "db,eth,net,web3" --networkid 1 console

But it always looking for peers and peer count is 0

Do I need to add some peers and where to find

Thanks


texts: Why can't a blockchain process more transactions then a single node can?

texts:
I'm reading about the on-chain scalability solutions. At the moment I'm looking at sharding.

  Currently, in all blockchain protocols each node stores all states
  (account balances, contract code and storage, etc.) and processes all
  transactions. This provides a large amount of security, but greatly
  limits scalability: a blockchain cannot process more transactions than
  a single node can. In large part because of this, Bitcoin is limited
  to ~3-7 transactions per second, Ethereum to 7-15, etc.

I cant seem to understand this, could someone elaborate?

So in other words:

  The number of transactions the blockchain can process can never exceed
  that of a single node that is participating in the network.

Further more:

  In a traditional database system, the solution to scalability is to
  add more servers (i.e. compute power) to handle the added
  transactions. In the decentralized blockchain world where every node
  needs to process and validate every transaction, it would require us
  to add more compute to every node for the network to get faster.
  Having no control over every public node in the network leaves us in a
  pickle.

So if I understand this correctly, the weakest node (or is it full node?) in the blockchain sets the limit on tx/s. Why is that? Is it possible then to add a really really slow node that slows down the whole processing of transactions?


texts: Smart Contract to receive tokens and give ether?

texts: A CrowdSale contract usually receives Ether in exchange of certain token. Is it possible to make it backwards? To receive certain token and give an amount of ether in exchange? Is as simple as changing positions of the variables in my code or it's a little bit more complicated?


texts: How to store data on ethereum blockchain WITHOUT IPFS

texts:
Hi guys ^^ i want to store PDF file on ethereum blockchain without use of IPFS. I want to do it because i have my own private network where this data will be only stored. That's why i want to store it directly on blockchain.

Thanks in advance!


texts:
Token help

We have created a utility token do we place our total supply on one exchange or divide and distribute portions of our total supply on multiple exchanges?


texts:
I have buid a dapp with web3, truffle and metamask, which works perfectly fine.

Now, instead of using a wallet I want to create my own wallet using ether.js, but couldn't figure out a way to use ether.js with truffle.

Is it possible, if yes, how.
Any lead will be appreciated


texts: How do you deploy a json script into the blockchain?

texts:
I was trying to find a way to test out the blockcerts example link, however I do not know how to deploy the script in the html page into the blockchain.

Any good tutorials for this?


texts: Is possible to continue the BIP32/BIP39 algorithm from a Pk and Sk pair and "climb" to the mnemonic seed?

texts:
A few days reading about the BIP algorithm and the generation of the key pairs.

Found that on the BIP 32 Paper:

  Child key derivation (CKD) functions
  Given a parent extended key and an index i, it is possible to compute the corresponding child extended key. The algorithm to do so depends on whether the child is a hardened key or not (or, equivalently, whether i ≥ 231), and whether we're talking about private or public keys.

  Private parent key → private child key The function CKDpriv((kpar,
  cpar), i) → (ki, ci) computes a child extended private key from the
  parent extended private key:

  Check whether i ≥ 231 (whether the child is a hardened key). If so
  (hardened child): let I = HMAC-SHA512(Key = cpar, Data = 0x00 ||
  ser256(kpar) || ser32(i)). (Note: The 0x00 pads the private key to
  make it 33 bytes long.) If not (normal child): let I = HMAC-SHA512(Key
  = cpar, Data = serP(point(kpar)) || ser32(i)). Split I into two 32-byte sequences, IL and IR. The returned child key ki is
  parse256(IL) + kpar (mod n). The returned chain code ci is IR. In case
  parse256(IL) ≥ n or ki = 0, the resulting key is invalid, and one
  should proceed with the next value for i. (Note: this has probability
  lower than 1 in 2127.) The HMAC-SHA512 function is specified in RFC
  4231. Public parent key → public child key The function CKDpub((Kpar, cpar), i) → (Ki, ci) computes a child extended public key from the
  parent extended public key. It is only defined for non-hardened child
  keys.

  Check whether i ≥ 231 (whether the child is a hardened key). If so
  (hardened child): return failure If not (normal child): let I =
  HMAC-SHA512(Key = cpar, Data = serP(Kpar) || ser32(i)). Split I into
  two 32-byte sequences, IL and IR. The returned child key Ki is
  point(parse256(IL)) + Kpar. The returned chain code ci is IR. In case
  parse256(IL) ≥ n or Ki is the point at infinity, the resulting key is
  invalid, and one should proceed with the next value for i.

I was wondering then, if mnemonic seed only gives you access to the first key pair and then, that key pair, gives you the next.

This will mean that you can execute the BIP 32 algorithm from a Pk,Sk combination that belongs to the herarchy marked by the mnemonic seed.

So I wanted to know if it's possible to scale from a Pk,Sk pair to the mnemonic seed (12 or 15 words from a dictionary).

Does anyne know about that?

Thanks.


texts: Token real synchronization from my website

texts:
I like to integrate a real token synchronization (From distributer wallet account to user's wallet address the token need to transfer) in my website. My website needs to interact with the blockchain real token need to be transferred to the user's wallet address

I have check varoius Dapps not working on my website

If any have experience Real token synchronization let us know as soon as possible


texts: What is the most updated genesis file for Ethereum POA private network?

texts:
I have successfully created the multinode network, but some when trying to deploy smart contracts, some of them fail. This is the config of my genesis:
"config": {
"chainId": 999,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"clique": {
  "period": 3,
  "epoch": 30000


texts:
solidity mapping does not persist
I have this solidity code
contract Starting { //pragma solidity ^0.6.12
struct itemStatus {
    bool created;
}
mapping (bytes => itemStatus) public item;

bool[] public boolArray;

function start(bytes memory itemId) public returns (bool[] memory) {
    boolArray.push(item[itemId].created);
    if (item[itemId].created) {
        boolArray.push(item[itemId].created);
        return boolArray;
    } else {
        item[itemId] = itemStatus(true);
        boolArray.push(item[itemId].created);
        return boolArray;
    }
}

}
frontend javascript code is
  toStart: function () {
    let Instance;
    App.contracts.Starting.deployed().then(function (instance) {
      Instance = instance;
      return Instance.start.call(itemId);
    }).then(function (result) {
      console.log(result);
    }).catch(function (err) {
      console.log(err.message);
    });
  },

The first time I call 'toStart', I would expect [false, true] and the second time I call with the same itemId [false, true, true, true] and third time [false, true, true, true, true, true]. However, the result is always [false, true] irregard how many times I call 'toStart'. It seems item[itemId] = itemStatus(true) and boolArray.push(item[itemId].created) never get stored/persisted. Why is it so? How to change the code to get the expected result? Many thanks in advance.


texts:
When an event is triggered, you get something like this:

{
  "address": "0x0a7a177321f3b3b6e2299e621eb32e892b141b4b",
  "topics": [
"0x0d332ed5c7d6f1999116748c0eb99c740f276d879d025a5be6435fcf177785de"
  ],
  "data": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000568616c6c6f000000000000000000000000000000000000000000000000000000",
  "blockNumber": "0x2f6d30",
  "transactionHash": "0x4aaf274a399ee315dc351b30b2e6ff9525996d4700c4843ec0a625512cd21fd1",
  "transactionIndex": "0x4",
  "blockHash": "0xbfad930ed694aae9fc660951ac4a309701a17e75f02087c72c3ea78431c3005e",
  "logIndex": "0x2",
  "removed": false
}

I need to know if the event has been confirmed and it won't be "reverted" (at least with a high confidence level).

What I was thinking on doing was to wait for the block referenced in blockHash to have 12 confirmations to considered the event confirmed.

In order to check the 12 confirmations, my guess is that I need to check the block by calling eth_getBlockByHash, verify the response is not null (which I guess would mean the block was discarded) and make sure that eth_blockNumber - block.number is equals or bigger than 12.

Does this process to confirm an event sounds correct?


texts: My Ethereum contract is not receiving parameters from a Javascript call

texts:
I'm sending a transaction to a contract from Javascript through web3. The transaction is created. The solidity function is (partially) executed because it sends the token it's expected to send... but, values are no stored in a mapping.

I tested with browser-solidity and it works. I tested with https://www.myetherwallet.com and it works. In both cases, I can retrieve the values of the mapping. But when I do through javascript, it doesn't work.

Here is the code of javascript calling function:

  scheduleAppointment : function(_patient, _doctor, _appointmentDateTime) {
    var patientAddress      = document.getElementById("patientInput");
    var doctorAddress       = document.getElementById("doctorInput");
    var appointmentDateTime = document.getElementById("timeStampInput");
    contractInstance.scheduleAppointment.sendTransaction(patientAddress.value,
                                                         doctorAddress.value,
                                                         appointmentDateTime.value,
                                                         {gas:140000, from:web3.eth.accounts[0]});
  }

Here is the code of solidity function (this function does not send tokens, only stores to mapping):

function scheduleAppointment(address _patient, address _doctor, uint _appointmentDateTime) {
    appointmentsList[_patient][_doctor][_appointmentDateTime].appointmentStatus    = 1;
}

As you see, it would be impossible to make it more simple.. but it doesn't work. Transaction is created, but the value is not stored in the mapping.

Should I convert parameters before sending them from javascript? I couldn't find any reference for sending many parameters with sendTransaction. I've tried converting the integer value with parseInt when calling the function with javascript, but it's the same.

Any ideas? Thanks.


texts: Ethereum Virtual Machine in very simple words

texts: Can someone explain in very simple words (non technical) what EVM is? Is it something tangible, like a computer, that all nodes in the Ethereum network have access to? If so, then where is it located? If not, then what is it? A software that all nodes use? How would you explain it to your grandmother? Thank you!


texts: Is it at all possible to transform geth’s debug_traceTransaction trace into something that looks like what you get from parity's trace_replayTransaction? Parity’s trace module is extraordinarily useful for seeing the exact sequence of calls that led to a transaction reverting (eg), and for getting storage slot diffs. But, Geth is preferable to use in certain situations so I was curious to know if I'm vender locked to parity if I want that nice call trace?


texts: Ethereum HD Wallet implementation in Golang, is there any library in go?

texts: I need a library in golang to implement HD Wallet.


texts:
I used jaxx to create my etherium account, but after reading some comments, I decided to stop using it and switch to Mist 0.9.0.

I got my private key and used geth import account command. Import was successful but my account is not visible in Mist GUI.

Is there a solution for this?


texts:
How can we increase block.number on Ganache for testing purpose ?
If not possible do you know an alternative like passing X fake transactions to artificially increase block.number.

Or if we have to use a private chain: is it possible to change the time between blocks for faster testing ?

Best regards


texts:
I'm trying to run a public method in my smart contract in rinkeby network. But it fails with following error in Geth,

INFO [02-06|06:01:19.593] Served eth_call   conn=172.17.42.1:23241 reqid=1 t=320.98µs    err="context canceled"

What is the reason for this error. Please note that I'm running my Geth node inside a Docker container.


texts: Ethereum contract not allowing or transfering

texts:
I have published my Ethereum contract along with the source code to the test network ROPSTEN here:
https://ropsten.etherscan.io/address/0x4eada3f012a0dbdeff59a8ac62be07dfff71c90f#readContract

However, I am confused why only the approve and balanceOf functions work. All of the other functions return false or 0 when I try to run them using another test address: 0x458D19B5071b4C7B265793394c80e75BaECb5091. As you can see by the source code, I have a pretty straight-forward ERC 20 implementation... could it really be because my Allowed variable is capitalized instead of lower case? That is the only unique thing from the standard implementation that I found... is that the issue or am I missing something else?


texts:
I am running geth -rpc and node to directly interact with the blockchain. When executing a large amount of requests I noticed the following error:

http: Accept error: accept tcp 127.0.0.1:8545: accept: too many open files; retrying in 5ms

How can I configure geth to handle more connections? My code is:

var Web3 = require("web3")
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

// first
txs = [];
// second

for (i = 0; i < 100; i++) {

web3.eth.getBlock(4000000+i, function(error, block) {
        if(!error) {
            for (j = 0; j < block.transactions.length; j++) {
            web3.eth.getTransaction(block.transactions[j], function(error, transaction) {
                    if(!error) {
                        txs.push({block: transaction.blockNumber, from: transaction.from, to: transaction.to, value: transaction.value.toNumber(), id: block.transactions.indexOf(transaction.hash)})
                    }
                    else
                    console.error(error);
                });
            }
        }
        else
        console.error(error);
    });
}


texts: Why are all "safe low" transactions mined eventually?

texts: On the website ethgasstation.info you see the current fees for fast, standard and safe low transactions, assuming that there are always more safe low transactions waiting to be mined than standard or fast transactions, and that there are always more transactions waiting than the capacity of the network, why are all safe low transactions mined eventually? Do miners give priority to those transactions that have more time waiting to be mined?


texts: Does solidity handle prime256v1 ECDSA signatures

texts:
I'm just starting with solidity and I would like to know if it can be used to verify a ECDSA signature. I saw topics about secp256r1 but I was curious to know if it would work on other curves (prime256v1 to be precise).

Let's say I have the public key used, the signature and the input used for the signature; is there a way with solidity to compute all this to know if the signature corresponds ?

Thanks for your responses !


texts:
I'm new to ERC-20 and Solidity.  When I think about some ideas, I have two questions which may be naive.

Suppose I'm developing two coins A and B.

In contract of A, could it automatically send some tokens of A when it receives some tokens of B?
In contract of A, could it automatically send some tokens of B when it receive some tokens of A?


texts: Can Ethereum handle storage of strings in volume?

texts:
I have someone who wants to put strings onto a private blockchain. He thinks it will be safe for his data. So the idea is to store names and addresses etc on the blockchain (private).

I did some testing and hit a lot of gas limits.

Is there a way to effectively store strings in volume onto a private blockchain and to avoid gas limits?

This is really a design question not a strict cost of storage one.

Edit -

Various people stated this is a duplicate but I already tested now and one aspect is mining time lengthens with a high gas limit. So that is a factor. It is not simply about cost. It is also about usability.


texts: Passing Object to smart contract's payable function

texts:
I'm developing a contract where I should be able to pay multiple user's addresses.
I'm using TRON blockchain. I can use the TRONIDE developer API to send funds. But they recently shutdown their API for some reason so I think the better option would be to use the smart contract itself.
I can populate the address and the equivalent amount to transfer to each address and then pay the total amount from my DAPP.
{
'address1' : 10000,
'address2' : 20000,
'address3' : 50000
}

This would be my object.
So I'll create a DAPP to send 80000 in total and this object to my contract and my contract will distribute the funds accordingly.
I tried the below code but I keep getting errors (Mentioned below) Please help.
function performBonusCredit(string[][] _toPayArgs) external payable {
        //Perform send function here
    }

TypeError: Data location must be "calldata" for parameter in external function, but none was given.
function performBonusCredit(string toPayArgs) external payable {
                            ^--------------^


texts: Why does calling allEvents work from the Truffle console, but not from my application?

texts:
I am trying to retrieve the events associated with the default MetaCoin contract in Truffle. I am able to do this from the Truffle console, but not from within app.js. I am using Truffle 4.0.1 with Webpack and TestRPC. The abbreviated version of the contract is as follows:

contract MetaCoin {
    mapping (address => uint) balances;

    event Transfer(address indexed _from, address indexed _to, uint256 _value);

    function MetaCoin() {
        balances[tx.origin] = 10000;
    }

    function sendCoin(address receiver, uint amount) returns(bool sufficient) {
        if (balances[msg.sender] < amount) return false;
        balances[msg.sender] -= amount;
        balances[receiver] += amount;
        Transfer(msg.sender, receiver, amount);
        return true;
    }
}

In the project's app.js, I do the following when using sendCoin to verify that the event is working.

MetaCoin.deployed().then(function(instance) {
  meta = instance;
  return meta.sendCoin(receiver, amount, {from: account});
}).then(function(tx) {
  self.setStatus("Transaction complete!");
  console.log("the transaction:", tx);
});

When I view a transaction in the browser Javascript console I can verify that the transaction object does indeed have have an entry under logs with _from, _to, and _value so this seems to be working. The problem I am having is using allEvents from the Javascript API to get all past events. In my app.js, I have added an additional function:

fetchLogs: function() {
var self = this;
var meta;
var event_data;
var event_data2;
MetaCoin.deployed().then(function(instance) {
  meta = instance;
  console.log("working");
  var events = meta.allEvents({fromBlock: 0, toBlock: 'latest'});
  events.get(function(error, log) {
    event_data = log;
    console.log(event_data);
  });
});

},

When I view the browser console, I get the message "working" and then undefined where I should get an object with all of the past logs.

However, by using the same Javascript in the Truffle Console, I am able to see the logs by doing the following process:

> var meta;
> MetaCoin.deployed().then(function(instance) { meta = instance});
> var events = meta.allEvents({fromBlock: 0, toBlock: 'latest'});
> var event_data;
> events.get( (error, log) => {event_data = log;});
> event_data;

When I do this in the Truffle Console I get the a list of objects corresponding to every transaction that's been performed so far. So why does this work in the console, and not on my Truffle application?


texts: How do Token transfers, the associated token contract transactions and ERC20 token txns fit together?

texts:
Looking at Quantstamp token as an example it contains a list of transfers:

Similarly the associated contract also has "Transactions" and "Erc20 Token Txns", however they all seem to be different.

Transactions:

Erc20 Token Txns:

How do all the different transactions fit together? For example, what transactions appear in each list?


texts: Invalid JSON RPC response: "" Geth RPC on custom domain with nginx

texts:
in my geth.service file I have..

Description=Ethereum Go Client
[Service]
ExecStart=/usr/bin/geth --cache=1000 --datadir=/mnt/eth-blockchain --keystore=/mnt/eth-blockchain --rpc --rpcport=8882 --rpccorsdomain=* --
rpcapi=web3,db,net,eth
Restart=always
RestartSec=30
Type=simple
User=root
Group=root
[Install]

And in the nginx conf file
    /etc/nginx/conf.d/eth.domain.com.conf
I have...

limit_req_zone $binary_remote_addr zone=one:10m rate=30r/m;
limit_conn_zone $binary_remote_addr zone=addr:10m;

server {
    listen 80;
    client_body_timeout 5s;
    client_header_timeout 5s;
    server_name eth.domain.com;

    location / {
        limit_req zone=one;
        limit_conn addr 10;
        proxy_pass http://localhost:8882;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
        return 204;
    }
}

I run the below code in the browser

    web.eth.getBalance('0xa1fe5d3ca40da27705847361351c34a3e77d187a', 'latest', function(error, result){
        if(!error)
            console.log(result)
        else
            console.error(error);
    })

And the response is..

web3-hook.html:68 Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (web3.min.js:1)
    at XMLHttpRequest.n.onreadystatechange (web3.min.js:2)

If I change the host to a different RPC server I don't get the error message, so I know it's a server issue. Both geth and nginx look right to me, what am I missing?

I have also tried starting it from the console with

admin.startRPC("127.0.0.1", 8882, "*", "web3,db,net,eth")

and then I can curl it with

curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' localhost:8882

and I get the response

{"jsonrpc":"2.0","id":67,"result":"Geth/@binky/v1.6.0-stable-facc47cb/linux-amd64/go1.8.1"}


texts: Is there a practical approach to use transaction URL schema?

texts:
We are developing a web application, where a user can refill her account by sending funds to the company's Ethereum address. In order to distinguish different users, we assign each user a random unique alpha-numeric token, which should be sent as a data-string with the transaction.

Right now, we are using integration with MetaMask through web3 and it works perfectly.

However, I was wondering, is there a way to make a single-click payment (like with MetaMask), but using Desktop wallets? There is a discussion about ERC67, but it looks like a work-in-progress, which is not standardized yet.

Still, is there a practically applicable solution to this problem? We really would like to be able to give the user a link, which she could click and initiate payment in her desktop wallet. Also, it would be nice to embed the link to QR-code and allow payments from mobile devices.

And if such solution does exist, does it support custom data field?


texts:
I am relatively new to the eth community and i am currently trying to find a good way of using eth blockchain to create a signuo/signin mechanism. it turns out to do so in browsers, something like Metamask is needed.

What is Metamask ? what does it do ?

EDIT

What i need to know is what exactly should i do when having to use the users eth address to authenticate him/her ? in my recent attempts i had to use a login box like this one :

Of course i do have code behind that verifies the address and the login infos, but with metamsk i still don't grasp what should i do.


texts: How to know if a particular ethereum address is receiving a transaction?

texts: Is it possible to determine if an ethereum address is receving a payment for example?


texts: Using the Ethereum platform for a KYC solution

texts:
I am trying to create a KYC solution based on blockchain. I am trying to understand the benefits that blockchain can give over standard means of storage and documentation.

I do understand well what KYC means and how it is done without the usage of blockchain, but all I find when looking for the benefits of this latter is general and highly abstract of the technical specs of blockchain based platforms.

so my question is what is the benefit the ethereum platform can add to the existent KYC ways.


texts: Issues using oraclize with private network

texts:
I'm having some issues replicating oraclize's Mix use of the oraclizeAPI.sol (which is imported from github) on my local remix - and later on a private blockchain.
Now: I've tried to import the file locally and via git:
//import "./oraclizeAPI.sol";
import "github.com/oraclize/ethereum-api/oraclizeAPI_0.4.sol";

There is an exception when I try to create the contract which uses oraclizeAPI.sol (DieselPrice.sol).
After debugging I can see that the issue happens in the function 'oraclize_setNetwork' in oraclizeAPI.sol, which I believe goes through a list of networks, non of which my private blockchain.
How can I edit this code in order to be able to use oraclize?  Or is there another procedure that I need to do?
Thanks in advance!


texts:
i want to store balances of different tokens into a mapping. Also, i want a getter function to fetch balance of a particular token.
 struct UserTokens {
        address token;
        mapping(address => uint256) balance;
    }

    mapping(address => UserTokens[]) public userTokens;

    function deposit(address _token, uint256 _amt) external {
        // update balance of specified token

        u = UserTokens({token: _token});
        u.balance[msg.sender] = u.balance[msg.sender].add(_amt);

        userTokens[msg.sender].push(u);

        ...
    }

   function getLockedBalance(address _token) public view returns (uint256) {
        return userTokens[msg.sender][_token].balance;
    }


texts: Event suddenly disapears when i call another function in my contract

texts:
So i am doing a factory for an ERC20 token contract, here is my factory code:

pragma solidity >= 0.4.0 < 0.6.0;

import "./ERC20.sol";
import "./ERC20Interface.sol";

contract Factory {
    address[] createdContract;
    mapping (address => uint256) contractNo;
    mapping (address => address) contractOwner;
    mapping (address => bool) isEIP20;
    address owner;

    event NewContractCreated(address newContractAddress, address contractCreator);

    constructor() public {
        owner = msg.sender;
    }

    function createNewContract() payable public returns(address) {
        ERC20 newContract = new ERC20();

        newContract.EIP20();
        createdContract.push(address(newContract));
        isEIP20[address(newContract)] = true;
        contractNo[msg.sender]++;
        contractOwner[address(newContract)] = msg.sender;

        emit NewContractCreated(address(newContract), msg.sender);
    }

    function transfer(address _to, address _contractAddress)  public returns (bool) {
        ERC20Interface contractUsed = ERC20Interface(_contractAddress);
        require(contractUsed.transfer(_to, 50));
        return true;
    }

    function ownedContract() public view returns(uint256) {
        return contractNo[msg.sender];
    }

    function ownerOfContract(address _contractAddress) public view returns(address) {
        return contractOwner[_contractAddress];
    }
}

then i deploy it on ganache test rpc using truffle, then i create a new ERC20 from the factory contract and then check for NewContractCreated event and it fine, it return the result i was expecting:

then i call transfer function from factory contract, then see the NewContractCreated event again but i got empty as a result:

So where did all my past event from before go, and how did it disapear?


texts:
i sent a transaction to credits ico and it came back with a transaction failure due to a revert opcode. the credits team say they are not responsible i should take it up with ethereum. the ether-transaction (see below) did´nt go through but it has not been returend to my etherwallet. how can i get my ether back? please help me on how to solve this issue.

this is the transaction hash:
0xcf1bcbd424b5ca760669bb812d51b69a00f4b3bbfea6c54a24099231234deb5e

thank you


texts: Custom token - do i need to create my own wallet for ICO?

texts:
So my partners and I have been spending the last few months working on creating our own token which will be used in our platform.

We are wanting to launch an ICO to raise a bit of funds to further our development, however, we were wondering if we needed to create our own wallet? We are generating an ERC20 token, which it seems like Mist wallet supports additional tokens, however, is there any NEED for us to create a custom wallet source?

Eg: does there have to be a wallet source code for an exchange like poloniex/bittrex to be able to list a specific ERC20 token?

Thanks


texts: Is there a way to programmatically withdraw money from address?

texts:
I am trying to write a test using the Truffle framework and for one of the tests I need to send the contract some ether. Is there a way that I can programmatically make a specified ether account send money to the contract?

Thanks


texts: Why does webjs 1.0.0 cdn show api 0.20.7?

texts:
I have a project where rather than installing modules I have to import web3.js cdn. It's possible to find it here: https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.34/dist/

In the project there is a specific part integrating the script:

<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.34/dist/web3.min.js"></script>

However I am slightly confused if this is really web3.js 1.0.0.

According to this source, if the web3 is under 1.0 you initiate contracts as

var MyContract = web3.eth.contract(abiArray, contractAddress);

In web3 1.0 and above instead:

var MyContract = new web3.eth.Contract(abiArray, contractAddress);

I am forced in my syntax to use the one provided for versions below 1.0, yet I am importing web3.js@1.0.0-beta.34.

I decided to print the web3 version using

console.log(web3.version);

and in my console it appears to be 0.20.7.

Keep in mind that I tried other packages (from those that work as most don't lol) and the result is similar (I may get another version such as 0.20.8)

----------------Solution in short:

<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.34/dist/web3.min.js"></script>

<script>
window.addEventListener('load', function () {
    if (typeof web3 !== 'undefined') {
        console.log('Web3 Detected! ' + web3.currentProvider.constructor.name)
        window.web3 = new Web3(web3.currentProvider);
    } else {
        console.log('No Web3 Detected... using HTTP Provider')
        window.web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/v3/yourInfuraKey"));
    }
})

</script>


texts: What are the mechanisms that use the Ethereum network to decide when a block B is done and we are going to mine block B+1?

texts:
I know from the Ethereum Stats that a block is mined on average within 14 secs. But that is only on average. I want to know, step by step if possible, what are he mechanisms to say "okay, this block is done, let's create a new one".

In my opinion, it is not a limit of block size (even if there is one), because the Ethereum network can adapt itself if transactions does not consume more than 3 141 592 gas, which represent a lot of transactions.

So, I think this is related to the nounce which set the difficulty to have a block/12 secs. But I'm not sure about it.

Thank you for your valuable time and help.


texts:
I created an ERC20 token and deployed it using Remix IDE. My smart contract is available here: https://etherscan.io/address/0xdacD69347dE42baBfAEcD09dC88958378780FB62#code
I assigned all available tokens to me, and I can see it in my MetaMask
However, when I take a look at the token page on etherscan, I see that holders value is set to 0 addresses.
You can see the etherscan page here: https://etherscan.io/token/0xdacD69347dE42baBfAEcD09dC88958378780FB62
I'm wondering how is this possible.


texts: Can’t we program the contract that sends ETH based on $USD without oracles?

texts: I know that we can program the contract that sends ETH based on $USD if we use oracles. But isn’t there any way to achieve this without the third party?


texts: How do Casper's validators compare to Dash's masternodes?

texts:
Both of these networks are going to have a smaller subset of "privileged" nodes with similar properties (like storing large amounts of currency, receiving part of block rewards).

Are there further similarities? For example, could Dash's "transaction locking" mechanism be implemented (and is it a good idea)?


texts: I am wondering how transactions are propagaded in an Ethereum network. Assuming a Miner recieves an transaction, how does he deal with it. Does he immediatly send it to his peers, or does he collect income transactions for a certain amount of time before publishing them?


texts: divide ethers to current token holders only

texts:
My task is to divide the dividend sent by owner to the contract to the current token holders.The token holders can come later and redeem their pending amounts, the important point here is that, when a deposit is made that deposit should not be given to people that will hold tokens later than this and the portion of each token holder should remain until he redeem.

This is my code snippet:

struct Account {
        uint256 balance;
        uint256 lastDividends;
    }
mapping (address => Account) accounts;

// ------------------------------------------------------------------------
// Ether fallback function -- works as deposit
// ------------------------------------------------------------------------
function () external payable {
    totalDividends = totalDividends.add(msg.value);
}

// ------------------------------------------------------------------------
// Token holders can claim their pending dividends using this function
// - the sender address must not be excluded by owner
// ------------------------------------------------------------------------
function claimDividend() public notExcluded {
    uint256 owing = accountDividend(msg.sender);
    if (owing > 0) {
        msg.sender.transfer(owing);
        accounts[msg.sender].lastDividends = totalDividends;
    }
}

// ------------------------------------------------------------------------
// Calculates the pending dividends of the holders
// ------------------------------------------------------------------------
function accountDividend(address account) internal returns (uint256) {
    soldTokens = (_totalSupply.sub(balances[owner])).sub(excludedTokens);
    return ((totalDividends.sub(accounts[account].lastDividends)).mul(accounts[account].balance)).div(soldTokens);
}

However, this code actually divides each deposit with all sold Tokens but it doesn't keep the share of each token holder's safe. Let's say an owner deposited 100 ethers and there are 10 tokens holded by walletA, 20 tokens holded by walletB, and 40 tokens holded by walletC, now according to above snippet, it will divide add the new deposit to the totalDeposit and it will divide the totalDeposit by sold tokens at the moment when a person make withdraw.

As seen from above example, it has 70 sold tokens at the moment it made the deposit but since the accounts are not updated at that moment so, let's say walletA claims later when two more wallet holding 30 more tokens come. At that very moment, according to above snippet it will divide the total deposit by 100.

My problem is to give share of deposits only to those who are currently present and that deposit is not given to people who become holders later. The late token holders will get portion from next payout.

I am looking forward to design guideline, please? I know I can use loops and divide the deposit to all token holders present at the moment but that will cost me alot of gas. I have written that code snippet too:

// this will accept ether deposits
function deposit() public payable{
    soldTokens = (_totalSupply.sub(balances[owner])).sub(excludedTokens);
    uint256 available = msg.value * scaling;
    dividendPerToken = (available).div(soldTokens);
    if(dividendPerToken == 0)
        dividendPerToken += (available).remainder(soldTokens);
    for(uint i=0; i< holders.length; i++){
        address account = holders[i];
        //if(account != owner)
        if(excludedWallets[account] == false)
            dividendBalanceOf[account] += balances[account].mul(dividendPerToken);
    }
}

function withDraw() public returns(bool success){
    uint256 amount = dividendBalanceOf[msg.sender].div(scaling);
    amount += dividendBalanceOf[msg.sender].remainder(scaling);
    dividendBalanceOf[msg.sender] = 0;
    msg.sender.transfer(amount);
    return true;
}


texts: Mix: How do I reference user accounts in JS

texts: In Mix I can JS reference contracts with contracts['name'].  How do I reference the user accounts?


texts: How can the smart contract auto execute the function in the private chain?

texts: I know currently, we can use the Ethereum Alarm Clock and Aion scheduling system to execute the function automatically, but according to what I know, it only can work in Main Net and Test Net(Rposten). My question is, Is that possible to work in the private chain by using one of these two solutions(EAC or Aion). If both ways can't work in a private chain, Are there any solution to execute the function automatically in the private chain?


texts: web3.eth.sendTransaction sending to random address

texts:
I've been trying since near 2 weeks to make my users able to deposit and send ethereum on site. I use geth mostly, and more recently web3.js.

I face a very weird issue. All seems well, transaction send, it return a tx, balance update etc. But it send to a random address! Both happen with json rpc sentransaction as well web3js.

I've read that some other people had this issue (https://www.reddit.com/r/ethereum/comments/4a8c2h/geth_sent_the_transaction_to_the_wrong_address/), but I'm pretty sure I don't make the mistakes they talk about as "" typos etc, because last eth I sent was sending to good address BUT 2 tx returned (last to another unknown address) and no found received.

Here my code:

var web3 = connect();
    var contract = buildcontract();
    //don't mind of theses functions, I can post if needed

     function sendEth() {

        var fromAddr = "<?php echo $_SESSION['wallet'];?>";
          var pass = "<?php echo $_SESSION['walletpass'];?>";
          web3.personal.unlockAccount(fromAddr, pass, 2);

        var toAddr = $('#destination').val();
         console.log('fromAddr: ' + fromAddr);
         console.log('destination: ' + toAddr);
        var valueEth = $('#sendeth').val();
         console.log('value: ' + valueEth);
        var value = parseFloat(valueEth)*1.0e18;
       // var gasPrice = 1000000000000
      //  var gas = 50000
        web3.eth.sendTransaction({from: fromAddr, to: toAddr, value: value}, function (err, txhash) {
          console.log('error: ' + err);
          console.log('txhash: ' + txhash);
        });
      }

      $('#sendethbut').click(function(){
    sendEth();
});

Anyone can help or had this issue and fixed? I'm sure I make a dumb mistake, I really checked everywhere before post here (I never post here for fun, I respect knowledge and sharing, it's giving me headache and make me miss bitcoind a lot.)


texts: I need to know how to send ether from one address to another address for my Dapp

texts:
I have coded the below code it executes well but the ether cannot be
  send only the gas fees are sent?

pragma solidity ^0.5.2;

contract sendEther{

    address payable rec= address(0xD694fab8b63BeF0149aa47b8333dFeAe7f55E9C7);
    address public reciever;

    function send() public payable{

        rec.transfer(msg.value);

    }
}


texts: Hidden problems in "set array to empty array to clear it" approach

texts:
I needed a way to clear a storage array in my contract. I've seen this answer, but I tried to think of different approach (My arrays are most probably will contain enormous amount of elements) and have come up to this.

I create empty storage array of the same type, as the array I want to clear. Then I just assign empty array to filled array. Here is contract I used for testing.

pragma solidity ^0.4.18;

contract Test {
    address[] array;
    address[] helper;

    function Test() public {
        array.push(0x0);
        array.push(0x0);
        array.push(0x0);
        array.push(0x0);
    }

    function getSize() public view returns (uint256) {
        return array.length;
    }

    function clear() public {
        array = helper;
    }
}

It works as intended, getSize() returns 0 after I call clear().

So now I wonder, if there are some hidden problems in this approach, including something like "dangling pointers" or increased gas cost.

Thank you in advance.


texts: How to keep a Sidechain up to date with well known static singleton contracts?

texts:
it becomes more and more common in the Ethereum ecosystem to have contracts that only need to exist one time - and all other DApps/Contracts are interacting with this one contract instance.

Here are some examples:

0xce0042B868300000d44A59004Da54A005ffdcf9f EIP-2470 Singleton Factory
0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24 EIP-1820 Pseudo-introspection Registry Contract
0xdca7ef03e98e0dc2b855be647c39abe984fcf21b EIP 1056: Ethereum Lightweight Identity

I am wondering now, if there is a full list available, maybe even a tool that is able to automatic deploy those contracts, if they are missing on a specific sidechain.

Yeah of course, there is always the questions: Who decides what contract is important enough to be expected on a sidechain.
But i guess all EIP's are ?!
I have already started developing a tool that is able to do that by fetching the deployment  bytecode from Ethereum Mainnet. but i still need a list :-)
Is there any consens on that ?
If there is, the List could be provided on Ethereum Mainnet :P
Do you guys know any other effort in this direction ?


texts: How would i create a NFT smart contract that pays the artist & the consultant 10% of the sale price?

texts: I am new to programming; learning & doing at the same time, so please bear with me.


texts: Prevent other mining softwares to mine my public forked Ethereum chain

texts:
I forked an Ethereum chain and put it as public, but I only want my own software/client to be able to mine. Other miners using ethminer, geth, etc, cannot mine and profit from my chain (At least not before they hack and de-compile my software and find a way to mine). Is that possible?

Something I have in my mind:

An encrypted key needed to be provide for mining, key is decrypted and verified in nodes.
I create a mining pool and all nodes should only accept answers from my pool (by IP or by an encrypted key).


texts: What are the changes that will be included in the Metropolis/Byzantium network upgrade?

texts: I see a number of EIPS are listed as Accepted Changes, but it is not clear if all the changes are for Metropolis/Byzantium, nor if all Metropolis/Byzantium changes are there.


texts: Why does a transaction trigger 12 or 24 confirmation events?

texts:
Web3.js docs state that a confirmation event will be fired:

12 times when calling web3.eth.sendTransaction (see here)
24 times when calling myContract.methods.myMethod.send (see here)

Why is the difference in the number of times that the event is fired in each case?

More importantly, what exactly should I use these events for?

At present, I simply await for the function to complete, and then use the returned value, which is a resolved Promise containing the transaction receipt (unless we're dealing with a contract deployment, in which case it will contain the new contract's instance).

To my understanding, this receipt can also be obtained using:

myContract.methods.myMethod().send().on('receipt', function(receipt){...});

I assume that this additional way of obtaining the receipt is for when you also want to handle other things, such as those confirmation events, which from what I've observed, do not necessarily occur before the receipt is available.

Do I need to count up 12 (or 24) events in order to be sure that the information receipt reflects the block-chain?

Thank you!


texts:
I am trying to understand how to use the IERC20 token interface. From what I understand, I need to create an instance of an IERC20 token with the address of the token contract. Something like this:
IERC20 public token = IERC20(0xABCD...)

I am confused about where to find the address of the token.


texts: What's the meaning of "similar match" in source verification?

texts:
I'm looking at a contract that shows an orange badge and reads Contract Source Code Verified (Similar Match), providing a different address (with the same code). Does anybody know what this means?

(I can't really provide the example addresses on NDA grounds :( )


texts:
geth help has:

VIRTUAL MACHINE OPTIONS:
--jitvm       Enable the JIT VM
--forcejit       Force the JIT VM to take precedence
--jitcache "64"  Amount of cached JIT VM programs

What optimizations does Geth's --jitvm do?  What should users know about toggling --forcejit and --jitcache?  (This is separate from benchmarking question.)


texts:
Zora is decentralized marketplace for NFTs that doesn't take any fees from sales of NFTs, built on the Ethereum blockchain. Zora's help docs says

Instead of creating artificial scarcity by selling copies of digital
goods (like on Bandcamp or Gumroad,) we propose an alternative: make
one original openly accessible to everyone no matter who owns it, and
sell that original token over and over again.

Does this mean that the NFTs that are sold on Zora's marketplace are not scarce 1 of 1 editions, like how the crypto art platform SuperRare encourages?


texts: How do I deposit ether into a smart contract, actual ether - not a sub-coin?

texts: How can contract (Solidity function) know how many Ethers contract holds?


texts: How to prove anything as "mine" on Ethereum?

texts:
It's one of the key use cases discussed for blockchain technology, yet I haven't found a tutorial or example of this for Ethereum. Granted I'm a newbie, but could anyone explain the big picture of how to achieve this.

In PKC, what I'd do is I'd sign some piece of data which I want to prove as "mine" with my private key, envelope the signed content using e.g. pkcs7, send that along with the original data to the person/authority whom I want to sign it and let them sign the envelope with their private key. Using the mine and the signer's public key I can prove at any time that the original content was signed by me and the signer.

How would I achieve this using Ethereum?


texts: Can I also save other currency like  monero or dash in the Ethereum Wallet ?If yes  I would really appreciate some guideline or advice


texts: How to get initial balances for all those who bought tokens?

texts:
Is it possible to get the initial balances for all those accounts who bought ERC20 tokens? If that’s possible, how that can be achieved?

I’m wondering if there is any way of getting that information for each ERC20 token contract via for example the neon rpc from my get client. I know there is the method eth_call that I can use against each token contract’s balance_of function. But for that I needed to know before all accounts who invested in the specific token as well as the block when the token contract was created, assuming that was the initial time.

Am I missing any piece of information that I should consider in order to get initial balances for all tokens investors/accounts for a given erc20 token? Should I consider get that information from the token ico contract? It comes to that, I’m assuming there is no pattern on how to get that information as ico contracts doesn’t follow any spec.


texts: Why there are 'OUT' token transfers from the zero (0x00...) address?

texts: There are no 'OUT' transactions with ether (link), but there are a lot of token transfers (link). In my understanding, most likely no one has a private key for this address, so where do these transactions come from?


texts: How to create Multi-node private ethereum blockchain network (windows platform)

texts:
I need help in how we can create multi-node private network on ethereum blockchain preferably on windows platform.
My Approach (please suggest if I can follow some better one):
First I want to try to create multi-node network on same machine using different geth instances. Then I want to move forward with different machines are separate nodes as part of that network.

Please suggest me how to achieve above.


texts: Is it possible to pack two uintX into uint2X?

texts:
For example, for two uint16 values, is it possible to concatenate them into one uint32 value and also retrieve the original value later (bitwise operators)?

Please note that I do not mean addition by typecasting the 16 bit value to a 32 bit value and adding them together (+). But packing two 16 bit values into a 32 bit value.

So that instead of this:

           A                  B
           |                  |
mapping (uint16 => mapping (uint16 => bool)) data;

I can do this:

    (A << 16) | B
           |
mapping (uint32 => bool) data;


texts: How can I get the ABI from solc.compile? (^0.6.4)

texts:
In pragma solidity ^0.6.4;

I wrote a contract and can get the byte code as follow:

const solc = require("solc");
const path = require("path");
const fs = require("fs");

const inboxPath = path.resolve(__dirname, "contracts", "Inbox.sol");
const source = fs.readFileSync(inboxPath, "utf8");

var input = {
  language: "Solidity",
  sources: { "test.sol": { content: source } },
  settings: {
    outputSelection: {
      "*": {
        "*": ["*"]
      }
    }
  }
};
var output = JSON.parse(solc.compile(JSON.stringify(input)));

for (var contractName in output.contracts["test.sol"]) {
  console.log(
    contractName +
      ": " +
      output.contracts["test.sol"][contractName].evm.bytecode.object
  );
}

this code returns bytecode however I do not know how I can access to ABI code.


texts:
Does anybody know how to solve this? I've try to compile and deploy my contract to get the address, why obtained this error

Error:

1_initial_migration.js
======================

   Deploying 'towater'
   -------------------------
Error: Error: Error:  *** Deployment Failed ***

"towater" -- Invalid number of parameters for "undefined". Got 0 expected 2!.

    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-migrate/index.js:92:1)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.0.24 (core: 5.0.24)
Node v10.16.0

1_initial_migrations.js file:

var towater = artifacts.require("towater");

module.exports = function(deployer) {
  deployer.deploy(towater);
};


texts: What is the difference between authoring/signing/sealing/mining/validating/importing blocks in a Private Aura chain?

texts:
I want to make sure I'm using this terminology correctly, especially in terms of a private chain using Aura consensus on Parity.

Authoring/signing/sealing/mining I think I understand fine. Authoring a block is essentially the act of sealing it (selecting and mining different transactions from the transaction pool) and signing it (adding its cryptographic thumbprint on it). These are all done by the whichever miner has the authority to do it in the current round.

Validators, I understand their role a bit less. With Aura, they say that "it is capable of tolerating up to 50% of malicious nodes". They do mean malicious VALIDATOR nodes, correct? So from what I understand, validators are nodes that perform the exact same operations as the author of a block to verify that the signer has correctly performed its duties and is not posting erroneous output. Or is it something else that they are validating? And what's stopping a node from just posting erroneous output?

Finally, I don't really know what importing is. For example, when I look at the Parity log it says:

2017-11-03 01:06:44 UTC Imported #55 7331…75d3 (1 txs, 0.03 Mgas, 0.60 ms, 0.70 KiB)
2017-11-03 01:06:49 UTC    1/25 peers   40 KiB chain 55 KiB db 0 bytes queue 10 KiB sync  RPC:  0 conn,  0 req/s, 319 µs
2017-11-03 01:07:00 UTC Transaction mined (hash cc9c4c195b384b6ef025e8cf652258c95fe9858f483893dc4dd90c63785bff4a)
2017-11-03 01:07:00 UTC Imported #56 dbc0…fc40 (1 txs, 0.76 Mgas, 0.82 ms, 3.26 KiB)

I know for a fact that this is coming from the account that authored block #56. But this is also what the log looks like at other nodes in the network. Why would the miner be required to "import" a block that it just authored? Wouldn't it be more accurate to just say "Authored #56" here, and "Imported #56" on other nodes?


texts: Rust: Need both events when a transaction is sent and when is confirmed

texts:
Rust.
For a method send() of a smart contract I need to process both events when the transaction is sent (and generates txhash) and when it is confirmed.
From https://docs.rs/ethcontract/0.7.2/ethcontract/transaction/enum.ResolveCondition.html it seems that ethcontract can trigger a future only on one of these conditions :-(
Is it possible to check both?


texts: Am I Doing It Right? Transferred ETH to main account. No ETH showing, no wallet contract showing

texts:
So, am I doing this right? I sent some ether from Binance to my "main account", which I could see in the ethereum application had an address.

https://etherscan.io/tx/0x6c0a84509d24cb4c0f11cb033a615be8f0bb81f5da851b413b460a0b0ea78069

But I have now synced on the network for a while, and the ETH does not show up. My app is always about 500-1000 blocks behind, but I suppose that is normal?

I tried to create a wallet contract. But that has been stuck in "creating" ever since I did so.

Have I done something wrong?


texts: After reading the Ethash wiki, I kind of get DAG is something that every node can identically generate to verify the work. However I don't get how the DAG is related to Merkle Tree. Can anyone explain in detail?


texts: geth balance is always 0, block chain seems synced

texts:
So I just started to mine ether, using claymore with ethermine pool. I created the ether wallet with geth.

I ran geth --fast --cache=1024, I believe this is to sync the blockchain. So ran that all night.

In another terminal, ran geth attach, then ran eth.syncing and it shows the following results:

> eth.syncing
{
  currentBlock: 4823469,
  highestBlock: 4824783,
  knownStates: 22966377,
  pulledStates: 22961243,
  startingBlock: 0
}

So it seems to me to be synced.

now If I run the following commands, it always a balance of 0 ....

> eth.getBalance(eth.coinbase)
0
> eth.blockNumber
0
> web3.fromWei(eth.getBalance(eth.coinbase), "ether")
0

But my wallet has 0.06741 ETH according to etherchain.org ....


texts: Geth crashes, “missing trie node”, rlp: expected List

texts:
I am struggling with failing geth with my Dapp.
I got an error like this:

Web3

UnhandledPromiseRejectionWarning: Error: Returned error: missing trie node 3b78b9f0a935d03af6f70ac4173f718e46b62573d4363ff5839f41a6df4f2429 (path 020f06020608)

Geth:

INFO [02-07|06:51:18.668] Imported new chain segment               blocks=1 txs=247 mgas=7.993  elapsed=145.425ms mgasps=54.961  number=7186894 hash=bfbcdcâ€¦0a5b69 age=1m12s cache=268.00mB
panic: node 93e9e8033c6f4bdc391443e9d3446e41e41c175e0e2e353924b40b74d41d2933: decode error: rlp: expected List
goroutine 56011323 [running]:
github.com/ethereum/go-ethereum/trie.mustDecodeNode(0xc66da87ba0, 0x20, 0x20, 0xc4bd8300e0, 0x68, 0x68, 0x3ed6, 0x0, 0x0)
/build/ethereum-fSsX30/ethereum-

It happens randomly at least once a month, and i have to do resync every time.

What may cause this problem?

I need a stable solution, should i migrate to Parity?

I use Geth 1.8.22.


texts: 'out of gas' error when running a payable function on Remix+TestRPC

texts:
I'm using Remix connected to TestRPC and I'm getting an out of gas error when calling the sendEther() function with the argument set to the address of one of the accounts created by TestRPC at startup:

pragma solidity ^0.4.18;

contract Test
{

    function sendEther(address toAddr) public payable
    {
        toAddr.transfer(msg.value);
    }
}

I know that an out of gas error usually means that there was some kind of exception in the function. I tried this in geth + Mist Wallet and it worked fine... Also, running this through Remix debugger did not show me at all what the problem was.


texts:
I'm new to Ethereum and encountered a problem when filtering an event and watching it in Web3.

My simple solidity contract is the following:

pragma solidity ^0.4.4;

contract Test

{
    bool approval=false;
    bytes32 UID;

event update(bytes32 indexed _UID);
event Notification (string notification);

function fireEvent(bytes32 _UID) public
{
    UID = _UID;
    update(UID);
}

function getStatus() constant returns(bool)
{
    return approval;
}

function updateStatus(bool approval_UI) returns(bool)

{

    if (approval_UI)
    {
        Notification("ACCEPTED");
        approval=true;
        return approval;

    }
    else
    {
        Notification("REJECTED");
        approval=false;
        return approval;
    }
}

}

My web3.js code which filters the event with a specific value of the _UID, then watches for the event and calls a callback function to change the contract state variable 'approval' from false (default value) to true is the following:

var account = web3.eth.accounts[0];
web3.eth.defaultAccount=account;
if(web3.personal.unlockAccount(account,"1234",0))
{console.log(account);}
var abi=[contract-abi-here]
var address ="[contract-address-here]";
var contract = web3.eth.contract(abi).at(address);

var filter = contract.update({_UID: "123"});
filter.watch(function(error, result){
if (error) {
    console.log(error);
    return;
  }
  else
   {
      contract.updateStatus(true,{from: web3.eth.accounts[0], gas:200000});
      console.log('contract STATE changed!');
 }
});

However, when I connect the Solidity Remix with a Web3 provider (a private geth node) and fire the event as follows:

fireEvent("123");

The Web3 js code seems that never enters the else block to call the updateStatus contract function, i.e. this code snippet is NOT executed:

...
else
   {
      contract.updateStatus(true,{from: web3.eth.accounts[0], gas:200000});
      console.log('contract STATE changed!');
 }

and the function getStatus() returns always false (i.e. the default value)

Note though that if I directly call this function (without filtering and watching the Event)

contract.updateStatus(true,{from: web3.eth.accounts[0], gas:200000});

then the  function getStatus() returns true, i.e. the line above is executed as per normal.

Note: after each transaction, I make sure that it is mined.

Any help would be appreciated!

Regards,
Natassa


texts: If I don't use metamask who manages the private key and the incoming or outgoing ether?

texts: I want to build a dapp without using metamask but web3.js and a node (geth / parity). So if I use this second method what happens when ethere needs to be sent to an account?


texts:
I am quite new to solidity but am taking on work for a client to build a small dApp.

One thing I am struggling with is building a 'leasing' contract where:

Token holder leases token A to customer B for X ETH.

There is an agreed time frame for the length of the 'lease'.

Token A is returned to token holder after set timeframe expires.

Is this possible at all ? If not is there any other recommended approach?


texts:
I'm aware of these posts
How do you sign an verify a message in javascript proving you own an Ethereum address?
How does one properly use ecrecover to verify Ethereum signatures?

I'd like to sign a message and then verify it. I use the following command line in the geth  terminal.
var msg = web3.sha3('Schoolbus')
var signature = web3.eth.sign(web3.eth.accounts[0], msg)
var r = signature.slice(0, 66)
var s = '0x' + signature.slice(66, 130)
var v = '0x' + signature.slice(130, 132)
v = web3.toDecimal(v)

Then I use the smart contract below, and call:
   call_ecover(r, s,  v, msg)

But what i get is: 0x0000000000000000000000000000000000000000
 pragma solidity ^0.5.0;
 contract Call_verify{

  function call_ecover(bytes32 r, bytes32 s, uint8 v,
  bytes32 hash)external pure returns (address){
  bytes memory prefix = "\x19Ethereum Signed
  Message:\n32";
  bytes32 prefixedHash =
  keccak256(abi.encodePacked(prefix,hash));
  return ecrecover(prefixedHash, v, r, s);
  }

}

Note that I'm using compiler version 0.5.3 on remix.
Question: Why cannot I get the return value of ecrecover() function in my contract? Am I missing anything?


texts: Sending an argument to a contract method with sendTransaction

texts:
I'm using the truffle console to test my contract, but I'm having a trouble passing an argument. For example, I have a method like this

function sendEtherTo(address addr) public payable {
   require(addr != 0x0);
   require(msg.value > 0);
   addr.transfer(msg.value);
}

I'm trying to use sendTransaction but can't figure out how to pass in the argument.

This:

 web3.eth.sendTransaction({from: web3.eth.accounts[1], to: myContract.address, data: myContract.sendEtherTo.sendTransaction(web3.eth.accounts[2]), value: web3.toWei(10, "finney")})

Results in my testrpc crashing with an error in truffle saying

Error: Invalid JSON RPC response: undefined

I've tried the following which I've done in web3 successfully

web3.eth.sendTransaction({from: web3.eth.accounts[1], to: myContract.address, data: myContract['sendEtherTo'].getData(web3.eth.accounts[2]), value: web3.toWei(10, "finney")})

but this tells me that getData is undefined


texts: how to create automatic asynchronous transactions form smart contract

texts:
i created a stackable erc20 token with the capability for the contract owner to distribute rewards for stakes manually (via this tutorial). Is there a way to make the rewards go out automatically from within the smart contract? something like scheduling transaction calls?
i know I can easily make a cron job elsewhere that would do that, but the onchain way seems more intuitive


texts: A decentralized publisher-subscriber protocol

texts:
I am here to share with you my project: Smart Contracts which represents a decentralized version of a publisher-subscriber protocol. I called that DPS.
On github https://github.com/dpsprotocol/DPS you can find a paper and the code
I would be really happy in having your comments and opinions on that


texts: Web3: how call the view function at the current time

texts:
How can I call the view methods of the contract using web3 relative to the current time, not the time of the creation of the last block?

For example, on remix, the current time stamp in the view methods is not tied to the last block. How can I repeat this with web3?


texts: Can my users mint their own NFT's ontop of my ERC1155 Token Contract?

texts:
I am planning on incorporating ethereum tokens in my online music community. I wanted to know, if I wanted to allow artists to create their own nfts would they mint it on my erc155 token or would I need my own blockchain to do this?
or could I create a user interface where they deployed their own nfts but were able to exchange them on my platform?


texts:
I am building a simple high level library for off chain Ethereum transactions following ethereumjs-tx.

From what I read and understand:

1) Transaction parameters such as "nonce","to","gas","gasPrice","value","data","v","s","v" are all RLP encoded, striping any leading zeros.

2) Contract function execution parameters are all padded (left or right).

My question, are my assertions (1,2) correct and why not also have stripped parameters for the function calls?


texts:
After struggling with issue from Geth (then I decided to use Geth 1.8.2, magically it solve the problem).

I found 2 approaches to send ether :
The First approach are the codes following

     EthGetTransactionCount ethGetTransactionCount = web3.ethGetTransactionCount(
     creds.getAddress(), DefaultBlockParameterName.LATEST).sendAsync().get();
     BigInteger nonce = ethGetTransactionCount.getTransactionCount();

     RawTransaction rawTransaction = RawTransaction.createEtherTransaction(
     nonce, gasPrice, gasLimit, "0x<TO_ADDRESS>",
     new BigInteger("10000"));

     byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, creds);
     String hexValue = Numeric.toHexString(signedMessage);
     // FROM here you can get the tx hash.
     EthSendTransaction ethSendTransaction =
     web3.ethSendRawTransaction(hexValue).send();

And 2nd approach is :

TransactionReceipt transactionReceipt = Transfer.sendFunds(
     web3, creds, "0x<TO_ADDRESS>",
     BigDecimal.valueOf(1.0),Convert.Unit.ETHER).sendAsync().get();
     String etherReceipt = transactionReceipt.getTransactionHash();

Both are working smoothly, until I realized that the first one will directly create a transaction hash and the next operation can be continued, but the 2nd one will submit a transaction, it require me to start miner in order for it to be completed. Is there any way for the 2nd one to generate its transaction hash and does not require for the program to wait until it finish first then it continue.

Beside, which is the good/bad practice? Why? I would like to use the 2nd approach because it is tidier and shorter , also my way to send ERC20 token to another wallet is just using the wrapper instead of creating its raw transaction.


texts:
I am currently using geth in windows and 1.9.10LTS version of geth.

I have to Open geth console, but when i try to implement geth console or geth attach or geth attach ipc:\\ .\pipe\geth.ipc it doesn't work. Shows an error given below.


texts:
I run a private local Parity node that uses the Ethash engine. How do I use a miner with it?

I tried ethminer like suggested in the wiki (https://wiki.parity.io/Mining), but executing ethminer -G responds with "At least one pool URL must be specified". I also tried running ethminer -F http://localhost:8545 as suggested in Parity mining in testnet, but it says The following argument was not expected: -F.

Here's my mining config section:

[mining]
engine_signer = "0x00bd138abd70e2f00903268f3db08f2d25677c9e"
author = "0x00bd138abd70e2f00903268f3db08f2d25677c9e"

And this is my chainspec engine part:

    "engine": {
        "Ethash": {
            "params": {
                "minimumDifficulty": "0x020000",
                "difficultyBoundDivisor": "0x400",
                "metropolisDifficultyIncrementDivisor": "0xA",
                "blockReward": "0x4563918244F40000",
                "homesteadTransition": "0",
                "difficultyHardforkTransition": "0xC55F7BC23038E38",
                "difficultyHardforkBoundDivisor": "0x800",
                "bombDefuseTransition": "0",
                "eip150Transition": 0,
                "eip160Transition": 0,
                "eip161abcTransition": 0,
                "eip161dTransition": 0,
                "eip170Transition": 0,
                "eip100bTransition":0,
                "eip658Transition":0
            }
        }
    },

I don't care which miner I use, I just need my transactions to be mined.


texts: While compiling contract i got an error "Error: Could not find path from any sources; imported from path"

texts:
pragma solidity ^0.4.22;

import './NewToken.sol';

import 'zeppelin-solidity/contracts/crowdsale/emission/MintedCrowdsale.sol';

import 'zeppelin-solidity/contracts/crowdsale/validation/TimedCrowdsale.sol';
contract TokenCreate is MintedCrowdsale,TimedCrowdsale
{

  constructor()
 Crowdsale(_rate, _wallet, _token)

    TimedCrowdsale(_openingTime, _closingTime)
 {

    uint256 _openingTime;

    uint256 _closingTime;

    uint256 _rate;

    address _wallet;

    MintableToken _token;

                 }

}


texts: How to use Ethereum precompile bn256Pairing to check equality on symmetric groups?

texts:
The address 0x8 contains bn256Pairing pre-compiled contract on Byzantium release. I have the following questions :

If I have G_1 = G_2, i.e., a symmetric pairing, is it possible to check e(a_1, b_1) ?= e(a_2, b_2) ? If yes, how do I pass the arguments because the specification uses a representation like ai+b.
What is the exact encoding of the elements to be used? Is there a sample code or test case reference available? I'm trying to use assembly calls inside Solidity contracts.

In case it is not possible to use the pre-compiled contracts, can I edit the geth source code and test it on a private network? If yes, where can I add the relevant functions inside the source?


texts: How to create a local account from an external private key in Web3.py?

texts:
I've been using local_account = w3.eth.account.create(keys['private_key_1']) to create a local account offline. When I check the public key returned from local_account.address it does not match the existing public key. What should I do?

P.S. The key returned is a string & I've tried changing the private key format from "0x12345" to "12345". I think this is a solution but I can't figure out how to instantiate the class and call the from_key method.


texts: Make transactions free of charge for the user

texts:
I involved in a project that aims to create a token for public use (non blockchain familiar users).
User will have an ERC20 token, but I don't want they to have ETH to pay the gas.

One obvious solution could be centralize the solution, executing transactions from a server wallet for each user to keep traceability (with ETH, but not accessible to the user).
Although that solution could work, I don't think it is the best practice.

Another solution could be to make refunds of expended gas, but that could lead to some users to sell the ETH provided for gas, and not for proper use of the payment token.

Is there a way to fund an Smart Contract, in order to make it available to pay the transaction gas? In that case the user will see 0 gas cost in Metamask, but it seems risky (malicious users could exploit it to empty the funds).

Could I use the Raiden Network to make fast & free payments of my ERC20 tokens, like in Ligntning Network with BTC?

Should I create my own multisignature wallet in order to implement a channel for my ERC20 Token, like Raiden network does?

What could be the best approach if the mission is to provide users an ERC20 token to pay, in an ETH free (transparent) environment?


texts:
When working with web3.js, Truffle and Ganache, I can do this:

web3.currentProvider.send({method: "evm_increaseTime", params: [numOfSeconds]});

How can I do the equivalent in web3.py?

When I do:

from web3 import HTTPProvider
for func in dir(HTTPProvider):
    if not func.startswith('_'):
        print(func)

I get:

decode_rpc_response
encode_rpc_request
endpoint_uri
get_request_headers
get_request_kwargs
isConnected
logger
make_request
middlewares
request_func

Is it possibly one of these functions that I need to call?

Thank you!

UPDATE:

I've found that I can encode the request like so:

provider = Web3(HTTPProvider("http://127.0.0.1:8545")).providers[0]
request = encode_rpc_request("evm_increaseTime", [123])

When printing request, I get:

b'{"jsonrpc": "2.0", "method": "evm_increaseTime", "params": [123], "id": 0}'

But how do I send this request?


texts: Send 2 ETH from Nano to Bittrex, but run out of gas

texts:
I sent 2 ETH from my Nano wallet to Bittrex exchange. However, the transaction gets stucked due to lack of gas. I expect to see my 2 ETH goes back to my wallet minus the gas fee. However, I haven't seen the 2 ETH balance in my wallet. How can I recover my 2 ETH. Greatly appreciated for any help.

Etherscan Tx details.


texts:
EtherScan.io is showing error:  The ERC-20 Token Transfer might have Failed (ErrCode: unable to locate corresponding Transfer event log), check with sender.

Transactions are successful but users are not receiving tokens. Can someone help to explain what error is hiding?

Out of gas error? But not all provided gas was used.

Transaction example: https://etherscan.io/tx/0x20081e3012905d97961c2f1a18e1f3fe39f72a46b24e078df2fe446051366dca


texts: Why aren't costs "advertised" or at least knowable so funds aren't lost?

texts: I'm admittedly new to all of this, but as I learn about the transaction model, it seems to be a confusing business model at the very least.  I can understand that the price of gas fluctuates or can be bid up or down.  But why should a consumer have to guess how much gas is required?


texts: What are the list of nodes at the bottom of kovan.json?


texts:
The version of web3 in Truffle v4.0.5 is v0.20.3. Is it possible to manually upgrade the web3 version?

Similar to this question about web3 in geth. (It's hardcoded.)

Somewhat relevant to this issue.


texts: Firing an event every time eth gets deposited into a wallet

texts:
(I am using a private blockchain running on my computer for testing this)

So I am coding a simple front end app, that waits for a user to deposit some value of ETH into an address, before allowing the user to continue execution of the app.

I am wondering is there anyway to set an event listener on certain address, that gets fired every time a transaction is made to that address.

More importantly is it possible to do this without getting into using Contracts just vanilla wallets?


texts: How to interact with events from a smart contract?

texts:
can we get access to watch the event and get logged data from them and use it for processing in a smart contract?

Like matching an state variable with the data logged by an event .


texts:
I can't start truffle, this is the Error:

truffle init

/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/index.js:182
      for (var file of files) {
                   ^^
SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Module._extensions..js (module.js:474:10)
    at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/truffle/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/lib/profiler.js:7:15)
    at Module._compile (module.js:456:26)
    at Module._extensions..js (module.js:474:10)
    at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/truffle/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/lib/compiler.js:11:16)
    at Module._compile (module.js:456:26)
    at Module._extensions..js (module.js:474:10)
    at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/truffle/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Any idea what the problem might be?