2

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.

5
  • You might want to take a look at this answer Commented Oct 14, 2018 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. Commented Oct 14, 2018 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. Commented Oct 14, 2018 at 13:39
  • Title "want to continue execution even if this call reverts" doesn't match the question. Commented Oct 14, 2018 at 19:54
  • Related: ethereum.stackexchange.com/questions/632/… Commented Oct 14, 2018 at 19:56

2 Answers 2

3

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!

https://solidity.readthedocs.io/en/develop/050-breaking-changes.html

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

-1

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.

3
  • CALL puts a 0 on the stack Commented Oct 15, 2018 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! :) Commented Oct 15, 2018 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 Commented Oct 15, 2018 at 12:52

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.