As I understand it, it is possible for a contract to call another contract by using

othercontractaddress.call(gas_amount).value(eth amount)(tx data). 

Or in this case sender -> contract A -> contract B.

Is it possible to go one level deeper?

sender -> contract A -> contract B -> contract C?

Something like the following pseudocode?:

   othercontractaddress.call(gas_amount).value(eth amount)(thatothercontract.call(gas_amount).value(eth amount)(2ndtxdata))

1 Answer 1


Yes, although obviously each contract has to execute the call itself. You can do this 1024 times until you reached the maximum depth. At that depth all new calls will fail. This even lead to vulnerabilities in the past.

That said, EIP-150 increased the gas cost of calls so much that you can't reach the maximum depth anymore.

  • That makes sense. Would something like the call code I posted actually work or would it need to be tweaked? Mar 26, 2018 at 4:39
  • No, you would have to define each call in the contract that should execute it. For example, in contract A you have b_addr.call(gas_amount), then in contract B you have c_addr.call(gas_amount) and so on. You can't "condense" the calls into a single contract like in your code.
    – mafrasi2
    Mar 26, 2018 at 5:59
  • 1024 refers to the max local stack depth, of which every call will use more than 1 (up to 16 using solidity), so the max amount of nested calls is probably much less than 1024
    – Theo Port
    Mar 26, 2018 at 9:32
  • Interesting, can you elaborate? Why does a single call in solidity produce a call depth creater than 1?
    – mafrasi2
    Mar 26, 2018 at 9:41
  • 1
    Since he doesn't care to answer, here is my own view on this: it's incorrect. A call in solidity will increase the call depth exactly by one. Nothing I've seen indicates otherwise and it really wouldn't make any sense anyways. At the very least on EVM level this is definitely true: github.com/ethereum/pyethereum/blob/develop/ethereum/vm.py#L712: msg.depth + 1 for a CALL instruction.
    – mafrasi2
    Mar 29, 2018 at 16:54

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.