0

I compiled a simple smart contract with --bin option (vs --bin-runtime), and looked at the assembly code. I can see that at first, the "setup" code copy all the run-time code with CODECOPY to memory, then RETURN; STOP.

But what happen after RETURN; STOP? I suppose this stops everything, but logically the main code should run next, so I am confused.

To make sense, after RETURN; STOP, EVM should continue to execute the code staying in returned memory, but this does not seem to be explained in Ethereum specs?

user311703
  • 379
  • 2
  • 9

1 Answers1

1

No, after the STOP nothing is executed. The job of the init code (what you're looking at) is to return the code that will be associated in the future with the newly-created contract address. Once it returns that code, execution is complete. When you subsequently send a transaction to the contract address, that code (that was returned by the init code) will be executed.

user19510
  • 27,999
  • 2
  • 30
  • 48