hardhat
hardhat copied to clipboard
Make it easier to get the return data of a transaction
In brownie, after waiting for a transaction to complete, I can run tx.return_value to get the return value of a function, even if it's non-pure non-view.
You can see how they do it here: https://github.com/eth-brownie/brownie/blob/27ed8b6095be697d420a191805fae2127df26159/brownie/network/transaction.py#L685
We should add this for hardhat, and potentially ethers.js
This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.
Not stale
I'm not sure what to do about this issue. We can't return this as part of the JSON-RPC response, because that wouldn't be spec-compliant. And I don't think using debug_traceTransaction after every transaction is a good idea.
Maybe we could add a getReturnData network helper that receives a transaction hash and returns the return data, using debug_traceTransaction under the hood.
What do you think @PatrickAlphaC?
Edit: we are going to add a network helper for this, and we might also add a custom RPC method that is lighter than debug_tt.
@fvictorio I think that would be a good workaround!