11

As I understand it, a smart contract can "call" other smart contracts. So what happens when two smart contracts call each other in a recursive loop? Does the whole network break down and die?

15

They will run out of gas.

Each smart contract can only be invoked by a transaction. Transactions costs fees and executing contracts costs gas, which are a kind of additional fees for each executional step. If one smart contract calls another contract, it has to create a new transaction which only works if the contract has access to enough ether to pay the fees and the gas.

One malicious user could create two contract accounts talking to each other in a loop and stuff them with loads of ether. But this will cost a lot. And the whole network wont break down.

And in the end, they will run out of gas.

4

Another interesting thing to consider is contract creation.

As outlined in the Solidity FAQ, contracts can create other contracts but "cyclic creations are not possible".

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.