I have deployed:

contract test { 
      function multiply(uint a) returns(uint d) { 
               return a * 7;

I can call the contract with "eth_call" :

mpsp@ubuntu-slave2:~$ curl --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to": "0x8e6f99f04148b1fb918cde7e44a94375f94dc745","data":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000007"},"latest"],"id":1}'

the output is:


But when I used "eth_sendTransaction" to invoke the contract and after mining, I used "eth_getTransactionReceipt" to get the result, and contract seemed not to be invoked. Here are my steps:


run:       mpsp@ubuntu-slave2:~$ curl --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"0xc60ec7c68d47814288bdfdaa71b88ff922d735a7","to":"0x8e6f99f04148b1fb918cde7e44a94375f94dc745","gas":"0xC350","gasPrice":"0x1388","data":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000003"}],"id":1}'
outputs:   {"jsonrpc":"2.0","id":1,"result":"0xcff6d91d1693abe876c25ba03a58bc6ca693078b3a90e836f656e0dddb08a4cd"}


run:        curl --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xcff6d91d1693abe876c25ba03a58bc6ca693078b3a90e836f656e0dddb08a4cd"],"id":1}'
outputs:    {"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x26e23d45caf0c57159e88d9835c573a79f59a4fad0e7a7d70ea7a49780d14448","blockNumber":"0xc3a1","contractAddress":null,"cumulativeGasUsed":"0x5449","from":"0xc60ec7c68d47814288bdfdaa71b88ff922d735a7","gasUsed":"0x5449","logs":[],"root":"c42b14419677df59e3f593fccf03ea28f65bbd8927dcc9239dad6e77eb85f1a3","to":"0x8e6f99f04148b1fb918cde7e44a94375f94dc745","transactionHash":"0xcff6d91d1693abe876c25ba03a58bc6ca693078b3a90e836f656e0dddb08a4cd","transactionIndex":"0x0"}}

logs was empty in eth_getTransactionReceipt outputs.

Do you have some suggestions ?

Thank you!


The test contract is not emitting an Event, that's why there's no logs. Return values are not automatically included as a log.


contract test { 
      event R(uint x);
      function multiply(uint a) returns(uint d) { 
               R(a * 7);
               return a * 7;

In case that doesn't work, you might need to bump up the gas (you have around 28,423 gas left).

  • I tried and it worked,thanks a lot! Is there anyway I can get the calculation by using eth_sendTransaction without log – Panda Jun 7 '16 at 3:44
  • The return value can be obtained via eth_call; or another contract and see ethereum.stackexchange.com/questions/765/… for more information. – eth Jun 7 '16 at 4:40

In addition to using events, if what I really want to do is just to generate log entries in the transaction receipt, I sometime find it simpler to call the "low-level" Solidity logging functions directly:

log1( value, 'log_topic');

will create a log entry containing value with the topic "log_topic".

log2(value,topic1,topic2) allows you to create an entry with 2 topics, and so on.

Link to Solidity documentation

  • it's much simpler ,thank you ! if I don't generate log entries,is there anyway I can get the calculation of the contract? – Panda Jun 7 '16 at 3:59
  • You can write it to a contract storage variable after calculating and then later read it directly using eth_call(). Writing it to a variable will cost more gas than writing a log entry, but reading it from the contract using call() is way simpler and costs no gas. – jimkberry Jun 7 '16 at 14:27

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.