Imagine I'm developing a simple function as the following:
uint256 state;
event Addition(uint256 result);
function addition(uint256 a, uint256 b)
public
returns (uint256)
{
uint256 result = a + b;
state = result;
emit Addition(result);
return result;
}
How can I get the returned value (result)? I know that I can get the value listening the event Addition, but in that case... Why should I return values? When I execute the function with web3.js in my javascript frontend, I can wait until the transaction finishes, but the result don't came with transaction response.