I'm deploying a contract to my private chain and try to call the contract's function.

After I got in the geth console and finished deploy contract, I called the function but it doesn't work correctly.

pragma solidity ^0.5.6;

contract SimpleBank {
 uint256 storedData;
 function set(uint256 data) public{
  storedData = data;
function get() public view returns (uint256){
    return storedData;

// I tried to call contract’s function like this in the geth console:


// After mining like this:


// I called the get() function:


It should return storedData’s value 42 But it returns 0

And I tried to use other available contract on the web:

pragma solidity 0.5.1;

contract MyContract {
enum State { Waiting, Ready, Active }
State public state;

constructor() public {
    state = State.Waiting;

function activate() public {
    state = State.Active;

function isActive() public view returns(bool) {
    return state == State.Active;

// I called activate() first :


//And I called isActivete():


It should return true, but it return false

if the function’s return type is uint256, it always returns 0 And when the return type is Boolean, it always returns false

It seems like function do not actually work so it returns the default value

  • Can you check if the transactions was effectively mined? After creation it should return a <hash>, you can check the hash was mined with eth.getTransaction(<hash>), and verify block is a valid number. Also 10M as gas is too large try 100k as more reasonable, make sure the block gas limit in your chain is larger than the used. – Ismael Apr 25 '19 at 16:05
  • AFAIK, it should be func().call(), not func.call(). – goodvibration Apr 26 '19 at 8:33

Your Answer

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

Browse other questions tagged or ask your own question.