I write a simple contract to test my Parity jsonRPC. Here is my contract:

pragma solidity ^0.4.4;

contract test01 {
  string key;
  string name;
  function test01() {
    // constructor
  function readKey(string p) constant returns(string) {
    key = p;
    return key;
  function readName(string p) constant returns(string) {
    name = p;
    return name;

I read some document and know that I should use the first 4 bytes of function name to call a function.

I write it on Remix so that I can get the function bytes directly. Just as this picture show: enter image description here

So I use the jsonRPC eth_call to call the functoin readKey. And put the parameter behind the four bytes.

Just like this command:

curl --data '{"method":"eth_call","params":[{"data":"0x19efb2b30000000000000000000000000000000000000000000000000000000000000005"}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST

But it just return {"jsonrpc":"2.0","result":"0x","id":1}

And I change some other parameters. But it still return 0x. I don't understand why. Maybe because I don't call jsonRPC in a correct way? Thanks!

| improve this question | | | | |

Your problem is with the encoding of the string


With your contract abi you can use the site https://abi.hashex.org/ to create the data parameter of your call.

| improve this answer | | | | |

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.