0

I got a error. when invoke a function in geth after I deployed a smart contract in my private chain.

enter image description here

my contract code is below:

pragma solidity ^0.8.0;
contract Storage{
    uint256 public value = 5;
    function set(uint256 number) public{
        value = number;
    }
    function retrieve() public view returns (uint256){
        return value;
    }
}

I want to know how to solve this error. Thanks.

SpaceNinja
  • 31
  • 1

1 Answers1

0

In the GETH console, you can run the JSON-RPC API methods by passing the request object to the console, as well as their JavaScript alternatives.

I don't have a GETH instance available now to verify, but this should work:

eth.call(
    to: "0xcontractAddress",
    data: "0x2e64cec1"
);

I'm assuming the eth.call method from the other examples mentioned in the docs, as well as from the web3 method.

The data field is selector of the specific function. First 4 bytes of keccak-256 hash of the string retrieve().

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100