Skip to content

VitriolLabs/immutable-deployment-factory

Repository files navigation

ImmutableDeploymentFactory

..deterministic omni-chain smart contract deployments


The ImmutableDeploymentFactory can be used to deterministically deploy immutable smart contracts on any EVM-compatible chain to the same address using both create2 and create3 deployment functions.

Contracts deployed with this factory are immutable, and cannot be overwritten. Salts used for deployment can optionally include the caller's address to prevent front-running.

npm version

A blog post has been created reviewing this repo at: Deterministic EVM Deployments and the Immutable Deployment Factory

Usage:

The following functions are available to based on hash and deployment method (create2/3)

  • findCreate[#]Address - find contract deployment address based on salt
  • safeCreate[#]Address - perform contract deployment based on salt
function safeCreate2(bytes32 salt, bytes calldata initializationCode) returns (address deploymentAddress);
function findCreate2Address(bytes32 salt, bytes calldata initCode) returns (address deploymentAddress);
function findCreate2AddressViaHash(bytes32 salt, bytes32 initCodeHash) returns (address deploymentAddress);

function safeCreate3(bytes32 salt, bytes calldata initializationCode) returns (address deploymentAddress);
function findCreate3Address(bytes32 salt) returns (address deploymentAddress);

Note: create2 deployment addresses are influenced by the deploying contract's bytecode


When providing a salt during the deployment process, you have the **option** to prevent front-running of your deployment. This is accomplished by including the caller's address in the first 20 bytes of the salt. If you do not care to prevent front-running, the first 20 bytes of the salt must all be zeros.

Deployment:

The ImmutableDeploymentFactory has been deployed to 0x0000086e1910D5977302116fC27934DC0254266C on the following networks:

The ImmutableDeploymentFactory was initially deployed using Nick's method for keyless contract deployments.

You can deploy a copy of the factory to any EVM compatible chain by:

  1. Funding the deployment address 0x0D6470aED3287d05dF6cE19Ba4fab50852a49b5e with 0.07 chain-currency (possibly with additional chain fees ex: L1 fees on Optimism)
  2. Broadcast signedTx from keylessDeployment.json when gas is less than 100 gwei. You MUST fund the account prior to broadcasting the transaction.

Some web3 providers filter out Type-0 transactions (Ethereum legacy transactions), which are used here for omni-chain deployment. We had success using the Alchemy Sandbox to broadcast the deployment transactions.

Authors / Mentions

This repo was created by Cameron White (Slvrfn) of Vitriol Labs, but would not have been possible without the contributions of:

Contributing

Contributions are welcome, please review CONTRIBUTIONS for more details.

License

The files contained therein are licensed under The MIT License (MIT). See the LICENSE file for more details.

Disclaimer

Please review the DISCLAIMER for more details.


Donations (beermoney):

  • Eth: vitriollabs.eth or 0xFe9fe85c7E894917B5a42656548a9D143f96f12E on any EVM chain.
  • Btc: bc1qwf9xndxfwhfuul93seaq603xkgr64cwkc4d4dd