4

How many nested calls can an Ethereum transaction do?

Can Smart Contract A call Smart Contract B, then Smart Contract C and so on with only one call through Smart Contract A, and is there a limit to this chain of calls?

Thorkil Værge
  • 4,220
  • 2
  • 16
  • 38
Nathan Aw
  • 1,954
  • 12
  • 27

1 Answers1

6

Ethereum allows up to 1024 nested calls as specified in the Yellow Paper.

The definition of the CALL opcode presented below, specifies this limit. enter image description here enter image description here

Some recent changes to the limit of the gas allowed to be consumed by nested calls have reduced the practical limit of call depth to around 340. See: How does EIP 150 change the call depth attack?

The change is due to the fact that the max amount of gas that may be used by a nested call is ceil(63/64 * remaining_gas).

Thorkil Værge
  • 4,220
  • 2
  • 16
  • 38
  • Thanks Thorkil! This means Smart Contract 1 can call up to Smart Contract 1024? – Nathan Aw Apr 28 '18 at 01:20
  • 1
    In theory yes. But it seems that some recent changes has made it impossible to make more than 340 nested calls due to gas limits: https://github.com/ethereum/EIPs/issues/150 and https://ethereum.stackexchange.com/questions/9398/how-does-eip-150-change-the-call-depth-attack – Thorkil Værge Apr 28 '18 at 01:24