2

I am trying to call a contract function through the 'eth_call' method of rpc. my contract is as follows:

contract Ballot {

   function Ballot(string _title) {

       title = _title;
   }
...

   function getTitle() constant returns (string) { return title; }

...

}

I am calculating the method id for 'getTitle()' which yeilds '0x4e7ea493' which should return the title variable when sent in the 'data' param for the rpc call.

However it only every returns '0x' in the result, what am I doing incorrectly?

3

In geth:

> web3.sha3('getTitle()').substring(0,10)
"0xff3c1a8f"

Your method call signature should be 0xff3c1a8f.

Confirming using Browser Solidity and the following code:

pragma solidity ^0.4.6;

contract Ballot {
    string public title;

    function Ballot(string _title) {
        title = _title;
    }

   function getTitle() constant returns (string) { 
       return title; 
   }
}

Here's a screenshot of Browser Solidity's generated signature:

enter image description here

  • 1
    Apologies, there was an error in my code for calculating the method id. :P – Samuel Barnes Feb 7 '17 at 0:03

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.