Assume we have a test() function in our contract:

contract {
 uint state;

 function test() returns (bool ){
   state= 5;
   return true; 

I'm aware that if the test() function didn't have to change the state, then we can use:

  ver result= instance. test.call();

where "instance" is an instance of deployed contract. But what about the above case? The above code can be used in a case where a user interface interactively tells users that their request has been completed (e.g. their vote has been registered, etc.)

  • You cannot get the return value of a function executed by a transaction. The workaround is to generate an event with the actual result. Events are recorded in the transaction receipt and can be recovered by the caller. – Ismael Sep 23 '17 at 5:31

You can use call() on constant functions. It seems the constant keywork is not yet implemented inside the EVM:

The compiler does not enforce yet that a view method is not modifying state.

However, call() doesn't work the same in and out of the EVM, you can read a more in-depth explanation. An outside call, from web3js for example, will run locally and state changes won't be propagated.

I'm not sure of your exact question, but if you modify anything inside a call() your changes will be lost.

  • thanks for the answer. Could you please tell me what the solution is? – Ay. Sep 24 '17 at 17:56
  • The the 2 other comments. What are you trying to do actually? What is the problem? Are you trying to get a result from the function? Are you trying to determine whether you can use call() or not? – Nicolas Bernard Sep 25 '17 at 8:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.