Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- Create2Factory
- Optimization enabled
- true
- Compiler version
- v0.8.17+commit.8df45f5f
- Optimization runs
- 200
- EVM Version
- london
- Verified at
- 2023-08-01T09:30:10.708741Z
/contracts/patterns/Create2Factory.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0 <0.9.0; /// @title Based on Singleton Factory (EIP-2470), authored by Guilherme Schmidt (Status Research & Development GmbH) /// @notice Exposes CREATE2 (EIP-1014) to deploy bytecode on deterministic addresses based on initialization code and salt. contract Create2Factory { /// @notice Deploys `_initCode` using `_salt` for defining the deterministic address. /// @param _initCode Initialization code. /// @param _salt Arbitrary value to modify resulting address. /// @return createdContract Created contract address. function deploy(bytes memory _initCode, bytes32 _salt) public returns (address payable createdContract) { assembly { createdContract := create2(0, add(_initCode, 0x20), mload(_initCode), _salt) } } /// @notice Determine singleton contract address that might be created from this factory, given its `_initCode` and a `_salt`. /// @param _initCode Initialization code. /// @param _salt Arbitrary value to modify resulting address. /// @return expectedAddr Expected contract address. function determineAddr(bytes memory _initCode, bytes32 _salt) public view returns (address) { return address( uint160(uint(keccak256( abi.encodePacked( bytes1(0xff), address(this), _salt, keccak256(_initCode) ) ))) ); } }
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{},"evmVersion":"london"}
Contract ABI
[{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"createdContract","internalType":"address payable"}],"name":"deploy","inputs":[{"type":"bytes","name":"_initCode","internalType":"bytes"},{"type":"bytes32","name":"_salt","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"determineAddr","inputs":[{"type":"bytes","name":"_initCode","internalType":"bytes"},{"type":"bytes32","name":"_salt","internalType":"bytes32"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b506101e8806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80634af63f021461003b578063d3933c291461006a575b600080fd5b61004e6100493660046100fd565b6100d4565b6040516001600160a01b03909116815260200160405180910390f35b61004e6100783660046100fd565b8151602092830120604080516001600160f81b0319818601523060601b6bffffffffffffffffffffffff191660218201526035810193909352605580840192909252805180840390920182526075909201909152805191012090565b6000818351602085016000f59392505050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561011057600080fd5b823567ffffffffffffffff8082111561012857600080fd5b818501915085601f83011261013c57600080fd5b81358181111561014e5761014e6100e7565b604051601f8201601f19908116603f01168101908382118183101715610176576101766100e7565b8160405282815288602084870101111561018f57600080fd5b82602086016020830137600060209382018401529896909101359650505050505056fea2646970667358221220edfbe1be27e3eea3caaaae26d5d9e5b895a5f34558ed1efa4a8c100d6643aca064736f6c63430008110033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100365760003560e01c80634af63f021461003b578063d3933c291461006a575b600080fd5b61004e6100493660046100fd565b6100d4565b6040516001600160a01b03909116815260200160405180910390f35b61004e6100783660046100fd565b8151602092830120604080516001600160f81b0319818601523060601b6bffffffffffffffffffffffff191660218201526035810193909352605580840192909252805180840390920182526075909201909152805191012090565b6000818351602085016000f59392505050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561011057600080fd5b823567ffffffffffffffff8082111561012857600080fd5b818501915085601f83011261013c57600080fd5b81358181111561014e5761014e6100e7565b604051601f8201601f19908116603f01168101908382118183101715610176576101766100e7565b8160405282815288602084870101111561018f57600080fd5b82602086016020830137600060209382018401529896909101359650505050505056fea2646970667358221220edfbe1be27e3eea3caaaae26d5d9e5b895a5f34558ed1efa4a8c100d6643aca064736f6c63430008110033