JsonRPC call function problem

Hi,
I'm trying to call a function of my smart contract by json rpc method.
The function name is getPath(bool)
The contract address is 0xc510daf0869f323dcb9cfd5406251afe9e9e44e1
And here is my rpc command:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to": "0xc510daf0869f323dcb9cfd5406251afe9e9e44e1","data":"0x1cb0cbbc0000000000000000000000000000000000000000000000000000000000000001"}],"id":1}' localhost:8101

But the return result is 0x.
What is the problem here :'( ?

Comments

  • joseph13joseph13 Member Posts: 5
    Oh, and here is my contract:
    contract test{
      bytes32 input_path;
      bytes32 output_path;
    function DataProcess(){
        input_path = "~/input/";
        output_path = "~/output";
      }
    function getPath(bool flag) returns (bytes32 p){
      	bytes32 path;
        if(flag)
          {path = input_path;}
        else
          {path = output_path;}
      	return path;
      }
    }
  • monkeyklawmonkeyklaw Member Posts: 9
    Hi did you ever resolve this? I am having the same issue
  • autolycusautolycus Member Posts: 2
    Hi,

    So I ran into this same problem. It seems to only occur for me when I haven't deployed the contract that I'm trying to invoke. So for example, if I reset the chain after running my deploy previously, I have an address to the contract but that address no longer maps to any deployed contract. When I call a constant method on that contract, I get a "0x" response. Also check that the address of the contract is correct, if you are off or using the wrong value I get that response as well.

    I think this is a bug, but I haven't run it down yet.

  • TonyBTonyB Member Posts: 4
    I'm trying to use this same "curl-jsonrpc" technique to invoke a very simple contract that has compiled and is deployed into a private EVM and can be invoked from the geth command line console using " greeter.greet(); ". However, I'm having trouble determining the exact parameters for the curl-rpc command that invokes eth_call. Here is the code of my simple contrac.
    contract greeter {
    
     address owner;                               /* Define address variable owner */
     string greeting;                               /* Define string variable greeting */
     
     function greeter(string _greeting) public {  /* Run during initialization */
     greeting = _greeting;
     owner = msg.sender;
     }
     
     function kill() {                            /* Get funds on killing contract */
     if (msg.sender == owner) suicide(owner);
     }
    
     function greet() constant returns (string) { /* Main function */
     return greeting;
     }
    }
    After the contract is mined, the following command works okay from the console command line:
    > greeter.greet();
    "Hello From Vanilla Greeter!!!!!!"
    
    When the contract was mined, the following message with the transactionHash was returned by the console:

    Contract mined! address: 0xda4befa3311c1f36986f586a71ae3345448aa3e3 transactionHash: 0xd2e2caee42e3506a2080e379e296644d201a69262eb00190c6ab106e4620335b

    So I used the transactionHash value returned above to get the contractAddress using eth_getTransactionReceipt. I believe some form of the following command should be able to invoke the greet() method of the greeter contract.

    curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to": "CONTRACT_ADDRESS","data":"NOT_SURE_WHAT_GOES_HERE"}],"id":1}' localhost:8545

    However, there just does not seem to be much in the docs on how to arrive at the exact syntax for eth_call. Any thoughts or ideas would be greatly appreciated.
Sign In or Register to comment.