How to use a CREATE2 deployer

Hi there,
I deployed a CREATE2 deployer contract on many chains
AllswapCreate2Deployer
ropsten,bsctestnet,bsc,rinkeby,kovan,goerli,mumbai(polygon testnet)
contract address: 0x311CafcE93f4EE3d1ab2266B887a4aB3D2612Ea7
followed this guide https://andrecronje.medium.com/multichain-dapp-guide-standards-and-best-practices-8fabe2672c60

but I don’t have any clue how to use it to deploy other contracts.

Hello joop! Welcome to Open Zeppelin.

What I would do first, is make sure you get this on BSC TestNet, which I believe you did.

Then using the TestNet, I would use the below function, 1. deploy.

Step 1. Put your bytecode of the contract you want to deploy into the first field. If you are using Remix you will need to look around the settings. Alternatively deploy to the BSC Test Net and get the bytecode from there. If you are using hardhat then check the json file for the bytecode of your compiled contracts.

Step 2. Put your salt that you will use for deploying the contracts do the other chain in the Salt field. Think of it like a password you’re going to use to make sure your deployed contracts have the same address. Don’t tell anyone your salt obviously.

Step 3. After doing this on the BSC TestNet, verify your contract to make sure you are deploying correctly.

Step 4. Try to do this on Rinkeby using the same Salt. Verify and make sure you have the same address and same contract functions.

Step 5. Do it on all chains you want.

Please let me know if Step 4 doesn’t work. I haven’t done this before, but I believe that’s how it works. Best of luck!

If it works let us know too.

1 Like

First of all, thanks for your reply with the details.

but I already deployed the above contract (AllswapCreate2Deployer) on ropsten,bsctestnet,bsc,rinkeby,kovan,goerli,mumbai(polygon testnet) and it’s verified on all above chains except polygon testnet
and it has the same address on all above chains: 0x311CafcE93f4EE3d1ab2266B887a4aB3D2612Ea7

now I’m working on a DeFi project that will run on many chains.
so how I can use my Create2Deployer contract to deploy the project contracts to get the same deterministic addresses on all EVM compatible blockchains?

P.S I’m using truffle to deploy my contracts

1 Like

Hi Joop, yes I understand you have created the deployer contract.

I am talking about your project code. Put your DeFi project’s code into the function at Step 1.

You will deploy by using the function Deploy in your CREATE2 contract.

You may not be able to use Truffle specifically, but instead you could use ethers.js or just use etherscan/bscscan too.

2 Likes

Hi, welcome! :wave:

I just provide another way to do the same thing: you can use one a little special account, that is the nonce of this account should be same(general, nonce is 0 is the easiest) at all blockchains you want to deploy, then use the same scripts to deploy the contracts, cause it has the same nonce on the different chains, and execute the same actions, it will generate the same contract address. In this way, you use the opcode create rather than create2 to create contracts, the address for the new contract is computed the following way:

new_address = hash(sender, nonce)
2 Likes

Thanks, bro but frankly I’m new to this stuff.

Thanks for your reply, do you mean that I use the same address to deploy all the contracts
by that way, I’ll get the same deterministic addresses on all EVM compatible blockchains?

Just like I mentioned above, it depends on account and its nonce.

1 Like