As you know, in the EVM there are two opcodes to make a create and create2 smart contract from another smart contract. Such contracts are also called a factory.
Each of the opcodes has its own characteristics and pitfalls.
Let's see the differences between the CREATE
An important difference lies in how the address of the new contract is determined.
the address is determined by the factory contract's nonce. Everytime CREATE
is called in the factory, its nonce is increased by 1.
This approach is very controversial and the recent hack with Optimism was just related to this. https://rekt.news/wintermute-rekt/
, the address is determined by an arbitrary salt value and the init_code.
The big advantage of CREATE2
is that the destination address is not dependent on the exact state (i.e. the nonce) of the factory when it's called. This allows transaction results to be simulated off-chain, which is an important part of many state channel based approaches to scaling.