1

I am using the web3-implementation from python (web3.py) and use the both methods get_transaction and get_transaction_receipt to lookup failed transactions. If the status-field from get_transaction_receipt is 0, i know the transaction has failed.

But if i lookup the transaction with etherscan (or bscscan) i see an error-message (for example: "Fail with error 'Return amount is not enough'".

How can i lookup the transaction with web3 to get access to the content of the error message?

1
+50

As per the current scenario, web3.py doesn't handle this very well, this due to differnt clients handle RPC response in differnt ways (see this issue). However, this is being worked upon very actively (see this issue).

There are few workarounds to accomplish this:

  • use eth-brownie, TransactionReceipt.revert_msg will give the verbose message for revert and TransactionReceipt.dev_revert_msg allows customization for developer specified revert comment

  • use raw RPC call and parse the json

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.