2

during the process of contract deployment the 'loading' code is executed (60606040523415600e57600080fd5b5b603680601c6000396000f300). This bytecode sequence loads the actual contract into the evm/memory for deployment and do stuff like the initialization of the memory pointer. Is there any other bytecode executed (except the bytecode of the constructor)?

For example, is the whole bytecode of the contract executed during deployment? Or are just the bytecode sequences corresponding to a method executed if the method is invoked?

2

Only the initialization code is executed during the deployment. Initialization code is defined in the yellow paper in section 7. Contract Creation. Solidity will include the code of the constructor in the initialization code and return the bytecode of the contract.

The bytecode corresponding to individual methods of the contract is executed only when you invoke those methods.

  • Thank you! But if I provide a bytecode sequence in the data field of the transaction (to deploy a contract) that does not contain this "deploy bytecode sequence", will the EVM run the whole given bytecode sequence until an exceptional halting or termination occurs? – kedenk Apr 18 '18 at 12:57
  • I haven't tried that, but I suspect that the default function of the contract will be executed and its result will be stored as the bytecode of the smart contract. Or if the default function is not defined it will result in an exceptional halting. – medvedev1088 Apr 18 '18 at 13:04

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.