4

Which strategies should we follow when using create2 and create3?

I had seen that li.fi deployed the contracts using create3 factory contract.

and i know some basics about create that we can find out address of a contract before actually deploy it on the network by passing salt argument.

2
  • CREATE2 is an EVM opcode. I haven't found any details about create3. I think you can assume is some sort buzzword.
    – Ismael
    Mar 3, 2023 at 14:16
  • 1
    @Ismael Yes, agree. but, let's check this repo github.com/lifinance/create3-factory
    – 0xbeny
    Mar 4, 2023 at 15:05

2 Answers 2

5

With CREATE2, the contract bytecode affects the deployment address. So even blank spaces and comment text can affect the address.

CREATE3 is a way to use CREATE and CREATE2 in combination such that bytecode no longer affects the deployment address.

When the goal is to deploy your contracts to the same addresses on multiple blockchains, having fewer factors that affect deployment address makes it easier to achieve such a goal. So in this sense, CREATE3 is better to use than CREATE2.

It's best to use a CREATE3 factory that has been deployed keylessly, so that you and other users of the factory are not dependent on the original deployer of the factory - you can just deploy it yourself if it doesn't exist on your desired blockchain, and it will get the same address as on the other blockchains.

See SKYBIT Keyless Deployment for a detailed overview of the pros and cons of the various ways to achieve the goal of deploying your contracts to the same addresses on multiple blockchains.

1
  • Nice walk-through. let me try it out.
    – 0xbeny
    Sep 4, 2023 at 11:24
2

CREATE3 was created zefram.eth, checkout https://github.com/ZeframLou/create3-factory

also check this twitter thread: https://twitter.com/boredGenius/status/1576754025357115392

Optimized version of CREATE3 from solmate repo: https://github.com/transmissions11/solmate/blob/main/src/utils/CREATE3.sol

Solady re-wrote the optimized version of already optimized solmate's CREATE3 https://github.com/Vectorized/solady/blob/main/src/utils/CREATE3.sol

3
  • Thanks for your response! Do you know what the proxy exactly is in Solmate's Create3.sol file?
    – 0xbeny
    Jul 3, 2023 at 13:04
  • 1
    line number 26 to 31 explains the cde @0xbeny Jul 4, 2023 at 23:40
  • @0xbeny the proxy used simply calls the "create" opcode from its context. This allows contract deployments without depending on contract bytecode due to the proxy getting deployed with a salt, and that proxy calling "create" with its current nonce (1 on first use). This way, the contract bytecode is left out of the address derivation process
    – Slvrfn
    Jan 15 at 16:12

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.