Comment on page
Create2
Learn how to deploy deterministic contracts on Kinto.
The
CREATE2
opcode lets us predict the address where a contract will be deployed beforehand. This opens up lots of possibilities to improve user onboarding and scalability.In Kinto, all our contracts use CREATE2 to ensure proxy addresses are deployed to deterministic addresses. In practice, this means that given the same code and random number (salt) the contract will be deployed at the same address.
To enable CREATE2 capabilities, we have deployed the Arachnid proxy to the following address.
0x4e59b44847b379578588920ca78fbf26c0b4956c
Our contract factory exposes the following two methods: deployContract and getContractAddress.
interface IContractFactory {
function deployContract(uint amount, bytes memory bytecode, bytes32 salt) external returns (address);
function getContractAddress(bytes32 salt, bytes32 bytecodeHash) external view returns (address);
}
This function deploys a contract with the bytecode passed as an argument and value sent to the constructor. Salt is used as a randomizer. If you change the salt, deploying the same bytecode will generate a different address.
Parameter | Type | Explanation |
---|---|---|
amount | uint | Ether value to be sent on contract creation |
bytecode | bytes memory | The bytecode of the contract to create |
salt | bytes32 | Random bytes |
Calculate the contract address given the bytecode and salt. You can use this method to calculate the address of a deployment in advance of the actual process.
Parameter | Type | Explanation |
---|---|---|
bytecode | bytes memory | The bytecode of the contract to create |
salt | bytes32 | Random bytes |
Last modified 1mo ago