2

Shouldn't this be possible as the return value will be known when the receipt is created?

  • I can think of two possible reasons: 1) a contract can return an arbitrary amount of data, 2) The result is redundant (for example tx receipts are also not stored in the blockchain). Since you can always create a log entry with the result, perhaps creating a special log with the return value is not a bad idea. – Ismael Mar 19 '18 at 21:57
0

If you have a function which does not need the blockchain (or EVM) to get the return value, then you can get it directly. Such functions are view and pure functions. Those functions get the value from your own node and there's no need to go through the EVM.

If the function is not pure or view, then it will go through EVM execution - it has to be mined in a block. Therefore the execution is not instant and you can only get the return value after the transaction is mined in a block.

  • It would still be nice if the interface would allow for return values of transactions to be passed to javascript. If I invoke a contract in Solidity I can get the return value. Is that because even the invocation of the contract is considered part of the same transaction so it's all internal? I assume so. But the library could still be done in a way that would allow access to return values. For instance, by automatically turning return values into events and automatically parsing the events after mining. – Fred Douglis Mar 19 '18 at 13:56
  • 1
    "and you can only get the return value after the transaction is mined in a block." That's what OP is asking for: a return value in the transaction receipt (once the block is mined). But no, a return value is not available for transactions. – user19510 Mar 19 '18 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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