Simple example contract to deploy a contract using create2.
- ETH mainnet: 0x62349c8510de543e0bf77df87f548a1d5f642e7b
You don't have to clone this repo code, you only need a properly setup brownie environement.
First you will have to find a salt
that gives your contract a more efficient address.
In order to find the we will use create2crunch.
You can get the contract hash with the following code on a borwnie console:
from eth_utils import keccak
b_init_code = bytes.fromhex(Test.bytecode)
print(keccak(b_init_code).hex())
Once you have found the ideal salt:
salt = "ADD SOME SALT"
factory = Contract("FACTORY ADDRESS")
factory.deploy(factory, salt)
You can get the predicted contract using pure python or calling the contract computeAddress view function. Examples can be found on the test file.
Check create2crunch