When a contract creates a contract, where's the new contract's bytecode stored?

For example: This Maker contract was created by their deployment contract: https://etherscan.io/address/0x448a5065aebb8e423f0896e6c5d525c040f59af3 here's the internal transaction: https://etherscan.io/txsInternal?block=4752011

Etherscan says 0x448a5065aebb8e423f0896e6c5d525c040f59af3 was created in transaction 0xa066bef4d74ad5433cc89ea21799d7df3e2f37ec0879f9ca74c419e861064fbf and normally, when an external transaction creates a contract, that bytecode is in the blockchain in the input.

In this case, data was sent to the deployment (existing) contract to tell it to deploy a new contract, but the bytecode for the new contract is not in the blockchain data. Would the bytecode be in the event logs? or somewhere else?

2 Answers 2


It's an implementation detail where contract bytecode is stored: a Geth node can store it differently from a Parity node. What matters is that the APIs across all nodes are consistent.

web3.eth.getCode(someAddress) will give the bytecode of a contract at someAddress.

normally, when an external transaction creates a contract, that bytecode is in the blockchain in the input.

Not exactly. It may be a common misunderstanding that the input is the code of the created contract, but actually the input is code that returns the contract code. See Bytecode on block chain different from the one used when deploying

  • 1
    i'm working on extracting all data in an automated fashion, i think in order to use the web3.eth.getCode method to get the bytecode I need to be able to determine when an internal transaction creates a contract, as opposed to just calls a contract. like etherscan shows: etherscan.io/txsInternal?block=4752011. any idea how to determine this?
    – j4ys0n
    Apr 14, 2019 at 15:13
  • i didn't ask the question i wanted to correctly, but this does answer the question i asked :)
    – j4ys0n
    Apr 15, 2019 at 21:24

The code of a contract is part of it's account state. Every account in ethereum has a state which consists of it's balance, code, storage, and nonce.

The tree consisting of the states of every individual accounts is known as the state tree (trie). Transactions can be seen as transitions between state tries. So when you send a transaction that causes a contract to deploy, that is seen as a modification to state, much as changing storage or balances would be.

As @eth pointed out, you can in general retrieve information about the state from a node via eth.getX where X is the type of information you want

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.