⚙️

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.

Arachnid Proxy

To enable CREATE2 capabilities, we have deployed the Arachnid proxy to the following address.
0x4e59b44847b379578588920ca78fbf26c0b4956c
To read more about how CREATE2 works under the hood, visit the following page from OpenZeppelin.

Deploy contracts using CREATE2 on Kinto

Our contract factory exposes the following two methods: deployContract and getContractAddress.
interface IContractFactory {
function deployContract(address owner, uint amount, bytes memory bytecode, bytes32 salt) external returns (address);
function getContractAddress(bytes32 salt, bytes32 bytecodeHash) external view returns (address);
}

deployContract

This function deploys a contract with the bytecode passed as an argument and value sent to the constructor. Ownership will be transferred to the address passed as owner if the contract is Ownable. Salt is used as a randomizer. If you change the salt, deploying the same bytecode will generate a different address.
Parameter
Type
Explanation
owner
address
Address to set as owner
amount
uint
Ether value to be sent on contract creation
bytecode
bytes memory
The bytecode of the contract to create
salt
bytes32
Random bytes

getContractAddress

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