Have you ever wondered what sets CREATE apart from CREATE2? Let's find out..
In Solidity, `create` and `create2` are important opcodes for smart contract creation. `create` deploys a new contract, while `create2` creates a contract at a deterministic address based on input.
Here's an example of how `create` works:
This deploys a new instance of `NewContract` and returns the address of the new contract. The formula for determining the contract address is `keccak256(sender, nonce).`
create2 is more complex. It calculates a deterministic contract address using four inputs: sender address, salt, bytecode, and constructor arguments. The formula is keccak256(0xFF, sender, salt, keccak256(bytecode)).
Here's an example of how `create2` works:
Here, `bytecode` is the bytecode of the contract to be deployed, and `salt` is a random value. The `keccak256` function is used to calculate the deterministic address.
Each method has unique characteristics that can affect the resulting contract address and deployment process.
One advantage of create2 is that it enables the creation of contracts with predictable addresses in advance.
Elevate your skills and gain amazing insights in #Solidity and #SmartContracts by following @Quill_Academy. Let's take your expertise to the next level! 💪🏼
• • •
Missing some Tweet in this thread? You can try to
force a refresh