1

where do I check the value returned by a function in Ethereum wallet (I'm using v. 0.8.3)?

I have set a test net and it works fine. So, after I call a function of my deployed contract , I mine on it and the transaction is executed. I see fron an event that the value returned s correct.

ex.:

 function getMyvalue()  returns (uint256 valueInWeis)  {

    print(value); // event is printed correctly

    return value;

}

Here is a screenshotwith my transaction related to a function called after exectution

Where can I see the value returned (without having to check the events) ?

1 Answer 1

1

If your function modifies contract state, then it always returns transaction hash. There is no alternative to get return value other than using events. See How to get values returned by non constant transaction functions?
However if your function doesn't modify the contract state(as in your case), you should probably use constant functions.

function getMyvalue() constant returns (uint256 valueInWeis)  {

    print(value); // event is printed correctly

    return value;

}

What is the difference between a function marked constant and one that is not?

constant functions can perform some action and return a value, but cannot change state (this is not yet enforced by the compiler). In other words, a constant function cannot save or update any variables within the contract or wider blockchain. These functions are called using c.someFunction(...) from geth or any other web3.js environment.

“non-constant” functions (those lacking the constant specifier) must be called with c.someMethod.sendTransaction({from:eth.accounts[x], gas: 1000000}); That is, because they can change state, they have to have a gas payment sent along to get the work done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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