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?

1 Answer 1

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.

2
  • how output will be different for "pending" and "latest" block param?
    – Proton
    Aug 26, 2023 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, 2023 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.