• Stars
    star
    260
  • Rank 157,189 (Top 4 %)
  • Language
    Solidity
  • Created about 2 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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
  • Gnosis Chain 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]

More Repositories

1

playpen

Playpen is a set of modern, gas optimized staking pool contracts.
Solidity
273
star
2

vested-erc20

A wrapper ERC20 token that linearly vests an underlying ERC20 token to its holders.
Solidity
242
star
3

foundry-template

Minimalist template for foundry projects
Solidity
156
star
4

trustus

Trust-minimized way to access offchain data onchain
Solidity
139
star
5

bunni

ERC-20 LP tokens for Uniswap V3
Solidity
124
star
6

universal-bridge

Unified interface for sending messages from Ethereum to other chains and rollups.
Solidity
103
star
7

foundry-docgen

JavaScript
50
star
8

pooled-cdai

Pools DAI, converts it into Compound DAI, and sends interests to a beneficiary. Users putting DAI into the pool receives Pooled cDAI (pcDAI), an ERC20 token which is 1-for-1 redeemable for DAI at any time.
Solidity
49
star
9

foundry-canary

Minimal repo for Foundry examples and reproducing bugs in Foundry
Solidity
46
star
10

bagholder

Reward holders of an NFT without needing their NFTs to leave their wallets
Solidity
46
star
11

token-migrator

A simple contract for migrating from an old ERC20 token to a new ERC20 token.
Solidity
35
star
12

RevS

RevS is an open source P2P library for building Peer-to-Peer based apps.
Objective-C
19
star
13

ethhead

JavaScript
17
star
14

fee-distributor

Solidity
15
star
15

mev-token

JavaScript
14
star
16

hardhat-template

My personal template for hardhat projects
TypeScript
11
star
17

zeroswap

AMM written in Zinc for zkSync, based on Uniswap v2
Rust
9
star
18

pooled-cdai-subgraph

The Graph protocol subgraph for Pooled cDAI
TypeScript
6
star
19

warpy-contracts

Warpy is Venmo + them πŸ”₯ DeFi interests
JavaScript
6
star
20

blog

HTML
3
star
21

pooldai-frontend

TypeScript
3
star
22

YHack2017-Submission

Submission for YHack 2017
Python
3
star
23

RevS-Server

A server implementation using RevS.
Objective-C
1
star
24

pooldai

HTML
1
star
25

RevS-Test

A test client app using RevS for iOS
Objective-C
1
star
26

pool-dai-ui

Front end for Pool DAI
TypeScript
1
star
27

f12-landing-page

1
star
28

p2pLazer

An easy-to-use hybrid P2P library with high stability and success rate.
Objective-C
1
star
29

astrodrop-production

CSS
1
star
30

Concave-NFT-SC

hardhat
Solidity
1
star