Is creation code and byte code the same thing?

Is creation code and byte code (fetched via etherscan) the same thing?

(moved from: Not able to compute address for create2 + minimal proxy implementation)

1 Like

Hi @sowmayjn,

Welcome to the community :wave:

Creation code is the code to create the contract, the runtime code (shown on Etherscan) is the contract code.

Deconstructing a Solidity Contract — Part II: Creation vs. Runtime
The creation code gets executed in a transaction, which returns a copy of the runtime code, which is the actual code of the contract. As we will see, the constructor is part of the creation code, and not part of the runtime code.

Etherscan shows the runtime bytecode.

The example from Deep dive into the Minimal Proxy contract shows an example of a minimal proxy:
runtime code: 363d3d373d3d3d363d73bebebebebebebebebebebebebebebebebebebebe5af43d82803e903d91602b57fd5bf3
creation code: 3d602d80600a3d3981f3363d3d373d3d3d363d73bebebebebebebebebebebebebebebebebebebebe5af43d82803e903d91602b57fd5bf3

1 Like

Thanks a lot, @abcoathup

I think, that’s the reason for getting different address while calculating the CREAT2 contract address.

cc @Thrilok_kumar

1 Like

Hi @sowmayjn,

It is a matter of assembling the creation code to calculate the CREATE2 address.

The creation code for a minimal proxy is as follows (just need to replace bebe... with the actual logic address): 3d602d80600a3d3981f3363d3d373d3d3d363d73bebebebebebebebebebebebebebebebebebebebe5af43d82803e903d91602b57fd5bf3

1 Like