Is there anyway to read the return value from revert('Errored out') from Solidity contract via web3.

For example from below code I need to read the value from revert

pragma solidity ^0.4.22;
contract sample {
function buy(uint amount) payable {
  if (amount > 12)
     revert('Not enough value');
  • 1. The combination of if (amount > 12) and Not enough value seems like an oxymoron. You should either change the > to <=, or the not enough to too much. 2. The amount is generally passed in msg.value, where msg is passed to the function (any function) implicitly. So there's no need to pass it as an (explicit) input argument. 3. There is no return-value for revert. You can catch this exception when you call the function from the off-chain (web3 client) using standard exception handling, depending on the language that you use (e.g., try/catch if you're using Javascript). Commented Sep 4, 2018 at 11:53

1 Answer 1


Unfortunately, as of the latest version of Solidity (0.4.24) and the EVM, this is not possible. The transaction is reverted and that's it. It is something which is being worked on and you can track its status on this GitHub issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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