I have looked into the Solidity docs but cannot seem to find this feature. I want to call into a contract and want to push two values onto the stack: the actual return value AND if the execution completed or not (in the sense that a CALL-like opcode puts 0 on the stack).

The only way it seems to be doable is writing inline assembly, but this gets rather tough if the function I am calling is returning a dynamic sized bytes variable. I know that it is possible, of course, but I find it rather surprising that solidity does not have this feature.

  • You might want to take a look at this answer
    – Henk
    Oct 14 '18 at 11:24
  • Hey there, that doesn't really work because I only get the success bool from this and not the actual returndata. I want to have both. In case of success I use the returndata and if there is an error I will use different code.
    – JBrouwer
    Oct 14 '18 at 12:07
  • Ah I see. Didn't read your wuestion that well. Here's a (rather old, but working) tutorial on how to make a proxy contract. You can use it's code, specifically the inline assembly in Dispatcher.sol to do what you want.
    – Henk
    Oct 14 '18 at 13:39
  • Title "want to continue execution even if this call reverts" doesn't match the question.
    – eth
    Oct 14 '18 at 19:54
  • Related: ethereum.stackexchange.com/questions/632/…
    – eth
    Oct 14 '18 at 19:56

When reading the solidity docs suddenly came across to the answer of "why is this not a feature yet". It will be in Solidity 0.5.0!


Functions .call(), .delegatecall() and .staticcall() now return (bool, bytes memory) to provide access to the return data.


It is required to clarify: “execution completed or not” is not unique.

Case 1: your execution fails because somewhere a revert or throw fires. In this case you cannot have any return from EVM (any) except a string optionally inserted in the reverting line, as per:

require (user != owner, “the cited string”);

but it is quite impossible to use it as return value in a smart contract in the sense you mean, but anyway something comes out from the reverting transaction.

Case 2: your execution fails because some of your checks or call return success=“false” or similar. This can be returned without any hassle in an obvious way, by means of return statement.

Hoping this can help.

  • CALL puts a 0 on the stack
    – JBrouwer
    Oct 15 '18 at 7:51
  • Yes, more precisely "call" is returning 0 on error (eg. out of gas or other revert situation) and 1 on success, but it was you that does not want to use assembly!!! So why are you flagging negative this? Use assembly and do not ask us! :)
    – Rick Park
    Oct 15 '18 at 12:51
  • I did not flag this negatively. I asked for a non-assembly thing because I would expect this would be a solidity feature, but apparently it is not for solidity <0.5. It is introduced in 0.5
    – JBrouwer
    Oct 15 '18 at 12:52

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.