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');
}
}
if (amount > 12)
andNot enough value
seems like an oxymoron. You should either change the>
to<=
, or thenot enough
totoo much
. 2. The amount is generally passed inmsg.value
, wheremsg
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 forrevert
. 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). – goodvibration Sep 4 '18 at 11:53