5

I updated from 1.5.7 to 1.5.8 and now all my functions return 0.

Before you ask, yes the functions I am calling don't modifier the blockchain.

I tested both my contract and this simpleStorage code:

pragma solidity ^0.4.2;

contract simpleStorage {
    uint storedData = 4;

    function set(uint x) {
        storedData = x;
    }

    function get() constant returns (uint retVal) {
        return storedData;
    }
}

Here is my geth command:

geth --dev --mine --rpc --rpccorsdomain "*" --datadir dev

The get() function should return 4, but it always returns 0 in versions 1.5.8 and 1.5.9

Works perfectly fine in 1.5.7 with the same compiler version.

Same results in both Linux and Windows.

3

Remix - Internal JavaScript VM - Good Result

Here's a screenshot of Remix (Browser Solidity) showing that your contract works as expected:

enter image description here

Remix - geth RPC - Bad Result

Here's a screenshot of Remix showing that your contract does not work as expected when deploying to a geth 1.5.9 dev blockchain using the parameters you specified in your question.

geth 1.5.9 Command Line - Good Result

I flattened the following code and assigned it to a variable:

pragma solidity ^0.4.2;

contract SimpleStorage {
    uint storedData = 4;

    function set(uint x) {
        storedData = x;
    }

    function get() constant returns (uint retVal) {
        return storedData;
    }
}

And ran the following commands in the geth console:

var simpleStorageSource='pragma solidity ^0.4.2;contract SimpleStorage { uint storedData = 4; function set(uint x) { storedData = x; } function get() constant returns (uint retVal) { return storedData; }}'

var simpleStorageCompiled=web3.eth.compile.solidity(simpleStorageSource);

var simpleStorageContract = web3.eth.contract(simpleStorageCompiled['<stdin>:SimpleStorage'].info.abiDefinition);

var simpleStorage = simpleStorageContract.new({
    from: web3.eth.accounts[0],
    data: simpleStorageCompiled['<stdin>:SimpleStorage'].code, gas: 400000},
    function(e, contract) {
      if (!e) {
        if (!contract.address) {
          console.log("Contract transaction send: TransactionHash: " +
            contract.transactionHash + " waiting to be mined...");
        } else {
          console.log("Contract mined! Address: " + contract.address);
          console.log(contract);
        }
    }
});

Contract transaction send: TransactionHash: 0x45c230b92d8a41c16b74b078323e7fa6e59b07e67bb6e017ac72020a4bf4534c waiting to be mined...

Contract mined! Address: 0x9682c4a5e47a4f61c03118e8bba3de2d203a256c

> simpleStorage.get()
4

It seems the problem may be in Remix. You may want to file a bug report in the Remix repository.

@RolandKofler suggested that the problem could be in geth's JSON-RPC API.

  • 1
    I guess I will stick with 1.5.7 for now and file a bug report. Thanks for the help! – Metaception Mar 13 '17 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.