1

The Ethereum JSON-PRC spec contains an eth_getCode method, but it is not specified what is being retrieved:

  1. Init bytecode (including constructor)
  2. Deployed bytecode (without constructor)

Which one is it?

Paul Razvan Berg
  • 17,902
  • 6
  • 73
  • 143

1 Answers1

2

The command eth_getCode returns the bytecode associated with the address in the Ethereum world state, that will be the deployed bytecode (or runtime bytecode).

The init bytecode could be obtained from the deployment transaction's data field, unless it was created by a contract in which case you have to trace the transaction to obtain the details.

Ismael
  • 30,570
  • 21
  • 53
  • 96
  • how output will be different for "pending" and "latest" block param? – Proton Aug 26 '23 at 22:31
  • @Proton The output will change if at some point in between the contract destroy itself. After a contract is destroyed the runtime bytecode should be empty. – Ismael Aug 26 '23 at 23:16