Why can’t I get return values of state-changing smart contract calls?

From reading I have surmised that it is impossible to get the return value of state changing calls. Consider this example.sol:

contract F { function createChildContract() public returns (address child) { child = C(); } } contract C { } 

If in javascript, I instantiate F, then call F.createChildContract() this will return the transaction receipt. This is reasonable, because the transaction will not have been mined yet. But is there not a way to wait on the transaction, then once it is mined get that child address that it returns?

Everywhere I look, I see people telling me it can't be done, and I should use Events: How do I get the return value of a solidity function with web3? How to get return values when function with argument is called? https://github.com/ethereum/web3.js/issues/1207

Fine, I'll use events – but I would like to understand why this not possible? It seems like something that should be very much possible.

Submitted February 07, 2019 at 02:47AM }
via reddit http://bit.ly/2RNHIkF

Advertisements