Skip to content

ZeroPointLabs/create3-factory

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CREATE3 Factory

Factory contract for easily deploying contracts to the same address on multiple chains, using CREATE3.

Why?

Deploying a contract to multiple chains with the same address is annoying. One usually would create a new Ethereum account, seed it with enough tokens to pay for gas on every chain, and then deploy the contract naively. This relies on the fact that the new account's nonce is synced on all the chains, therefore resulting in the same contract address. However, deployment is often a complex process that involves several transactions (e.g. for initialization), which means it's easy for nonces to fall out of sync and make it forever impossible to deploy the contract at the desired address.

One could use a CREATE2 factory that deterministically deploys contracts to an address that's unrelated to the deployer's nonce, but the address is still related to the hash of the contract's creation code. This means if you wanted to use different constructor parameters on different chains, the deployed contracts will have different addresses.

A CREATE3 factory offers the best solution: the address of the deployed contract is determined by only the deployer address and the salt. This makes it far easier to deploy contracts to multiple chains at the same addresses.

Deployments

CREATE3Factory has been deployed to 0x9fBB3DF7C40Da2e5A0dE984fFE2CCB7C47cd0ABf on the following networks:

  • Ethereum Mainnet
  • Ethereum Goerli Testnet
  • Arbitrum Mainnet
  • Avalanche C-Chain Mainnet
  • Fantom Opera Mainnet
  • Optimism Mainnet
  • Polygon Mainnet

Usage

Call CREATE3Factory::deploy() to deploy a contract and CREATE3Factory::getDeployed() to predict the deployment address, it's as simple as it gets.

A few notes:

  • The salt provided is hashed together with the deployer address (i.e. msg.sender) to form the final salt, such that each deployer has its own namespace of deployed addresses.
  • The deployed contract should be aware that msg.sender in the constructor will be the temporary proxy contract used by CREATE3 rather than the deployer, so common patterns like Ownable should be modified to accomodate for this.

Installation

To install with Foundry:

forge install zeframlou/create3-factory

Local development

This project uses Foundry as the development framework.

Dependencies

forge install

Compilation

forge build

Deployment

Make sure that the network is defined in foundry.toml, then run:

./deploy/deploy.sh [network]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 75.8%
  • Shell 24.2%