As we know you can't get the return value of a non-constant function
Still ERC20 does this a lot, for example:
function approve(address _spender, uint256 _value) returns (bool success)
Hypothesis: return values are only there for contract-to-contract calls, and since you can't return anything from a transaction it is useless if not called by contracts.
Is this true? Are contract to contract calls with return values possible? And should you then always have a (Event, return) pair in this cases?
Best Answer
Yes, contract to contract return values are possible. Let's say you have this contract:
We now call it from another contract:
Within your tests you can check what
saved
value is kept in theCaller
contract.I have created a small repo to demonstrate it. Look at the contracts and the tests, which contain comments.