Skip to the article
Block Times

Crypto markets, protocols and policy

bc49eb

How to Deploy One Contract Address Across EVM Chains

Deploy your contract to the same address on multiple EVM chains with CREATE2: use one factory, salt and byte-identical init code, then verify each deployment.

Block Times Newsroom5 min read

How to Deploy One Contract Address Across EVM Chains

Use CREATE2 to deploy your contract to the same address on several EVM chains by using the same factory, salt and byte-identical init code on each chain. Start with a compiled contract and a funded deployer key; confirm the factory is available and funded on every target chain, calculate the expected address, then run the deployment for each chain and initialize any chain-specific settings. The result is confirmed when each explorer shows code at that address.

  1. What do I need before deploying to several EVM chains?

    For a CREATE2 deployment, you need the compiled contract, a funded deployer key, a factory deployed at the same address on each target chain, and gas on each chain. CREATE2 was added in EIP-1014. Unlike an ordinary CREATE deployment, which uses the deployer’s account nonce, CREATE2 derives the address from the factory, salt and init code hash.

    First choose the target chains and collect each chain ID and RPC URL for your deploy config. Chainlist is useful here because its network entries include chain IDs and RPC endpoints, the details your script needs to connect to the right network. Chainlist is a concrete example of an EVM network directory with those fields; add the selected values to your Foundry or Hardhat configuration and label each RPC clearly.

    Next, check that the factory has code at its expected address on every chain. Query eth_getCode with that address and the chain’s RPC URL. A non-empty result confirms code is present at that address; an empty result means you cannot rely on that factory there. Foundry’s default CREATE2 deployer is 0x4e59b44847b379578588920cA78FbF26c0B4956C. Confirm it is deployed on every target chain before using it. A shared address on one chain alone does not establish that the factory is available everywhere.

  2. How do I make the address match across chains?

    The address matches when the factory address, salt and init code hash match on every chain. The CREATE2 formula is the last 20 bytes of keccak256(0xff ++ factory ++ salt ++ keccak256(initcode)). Since the chain ID is not an input to that formula, the same inputs produce the same address across EVM chains.

    Fix the salt and compiler settings before calculating the address. Pin the compiler version, optimizer runs and metadata settings in your project. Any bytecode difference changes the init code hash and therefore the resulting address, even when the Solidity source looks the same.

    Constructor arguments need special attention because they are part of the init code. Say your constructor takes a router address that differs by chain: that argument changes the init code, which changes its hash and the deployed address. To keep one address, deploy with identical init code and pass chain-specific values through an initializer after deployment. The initializer can set the router for that chain without changing the address calculation.

    With the final build and constructor inputs fixed, compute the expected address using the factory, salt and init code. Keep this value with your deployment config so you can compare it against the result on every chain. CREATE can also produce matching addresses if deployer nonces match, but this walkthrough uses a CREATE2 factory, whose salt and init code give you the inputs to check.

  3. How do I deploy the contract on each chain?

    Run the same deployment process for each chain, using its RPC URL and the same factory, salt and init code. In Foundry or Hardhat, configure the script to build the contract with the pinned settings, submit the CREATE2 deployment through the factory, and record the transaction and returned address for each network.

    Take a two-chain deployment as a short example. First, you add both chain IDs and RPC URLs to the config and confirm the factory code on both. Then you compile once with the pinned settings and choose a salt. You calculate the expected address, run the script against the first RPC, and see the deployment complete at that address. The state is now: code on chain one, with chain two still waiting.

    Next, run the same script against the second RPC. Keep the salt, factory and init code unchanged. The second deployment should return the same calculated address. Once it does, call the initializer separately on each chain with that chain’s router or other network-specific values. This leaves the contract at one address on both chains while its configured values can differ.

    Chainlist’s chain ID and RPC fields help keep each script run pointed at the intended network. Confirm the active chain before sending each transaction; a correct address calculation cannot prevent a transaction from going to the wrong RPC.

  4. How do I confirm the deployments worked?

    The deployment is confirmed when each chain’s explorer shows contract code at the computed address. After running the deployments and initializers, open the relevant explorer for each chain and check that code appears at that address. Compare the address across explorers and confirm it matches the value you calculated before deployment.

    If one chain shows no code at the expected address, check the RPC and chain ID, factory code, salt, compiler settings and constructor arguments. Those inputs identify where the deployment diverged. Once the explorers show code at the same address, record the address and chain-specific settings in your release config so your apps and tools can connect to the intended deployment.

Related coverage