Does “eth_getCode” return the init bytecode or the deployed bytecode

bytecodejson-rpc

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?

Best Answer

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.

Related Topic