hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Make it easier to get the return data of a transaction

Open PatrickAlphaC opened this issue 3 years ago • 4 comments

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

PatrickAlphaC avatar Jan 18 '22 13:01 PatrickAlphaC

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.

github-actions[bot] avatar May 25 '22 17:05 github-actions[bot]

Not stale

fvictorio avatar May 30 '22 14:05 fvictorio

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 avatar Dec 28 '22 13:12 fvictorio

@fvictorio I think that would be a good workaround!

PatrickAlphaC avatar Dec 28 '22 13:12 PatrickAlphaC