Skip to content

Helper smart contract to make easier and safer usage of the `CREATE` EVM opcode.

License

Notifications You must be signed in to change notification settings

pcaversaccio/create-util

Repository files navigation

CREATE Factory

🕵️‍♂️ Test smart contracts License: MIT

Helper smart contract Create to make easier and safer usage of the CREATE Ethereum Virtual Machine (EVM) opcode. CREATE, in a way, does a built-in call. What actually happens is that the data passed to that call isn't the contract bytecode, it's the init bytecode (a.k.a. creation bytecode).

When the CREATE opcode is executed, the EVM creates a call frame in the context of the new contract (e.g. address(this) is the new contract's address). This executes the data passed to CREATE as the code, which in higher level languages is basically the constructor. At the end of this init stuff, it returns the actual code of the contract that is stored in the state trie.

The easiest way to think about it, which is also fairly accurate, is that the Solidity compiler takes all the executional code of the contract, compiles it to bytecode, and adds it as a return statement at the end of the constructor.

The smart contract Create also provides a function computeAddress that returns (via the Recursive Length Prefix (RLP) encoding scheme) the address where a contract will be stored if deployed via CREATE.

Test Deployments

CREATE2 Factory

A helper smart contract to make easier and safer usage of the CREATE2 EVM opcode can be found here (a.k.a. Create2Deployer) and here (a.k.a. CreateX; a versatile, trustless, and stateless successor to Create2Deployer).

About

Helper smart contract to make easier and safer usage of the `CREATE` EVM opcode.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published