- Contract name:
- ImmutableOwnerCreate2Factory
- Optimization enabled
- false
- Compiler version
- v0.8.9+commit.e5eed63a
- Verified at
- 2023-11-08T19:57:01.757095Z
Constructor Arguments
00000000000000000000000004c8c6c56dab836f8bd62cb6884371507e706806
Arg [0] (address) : 0x04c8c6c56dab836f8bd62cb6884371507e706806
contracts/ImmutableOwnerCreate2Factory.sol
// SPDX-License-Identifier: CC0-1.0 pragma solidity 0.8.9; import { Create2 } from "@openzeppelin/contracts/utils/Create2.sol"; contract ImmutableOwnerCreate2Factory { address public owner; event Deployed(address addr); modifier onlyOwner() { require(msg.sender == owner, "ImmutableOwnerCreate2Factory: Only Owner can call this function."); _; } constructor(address _owner) { owner = _owner; } function deploy(bytes32 salt, bytes memory bytecode) onlyOwner external returns (address addr) { addr = Create2.deploy(0, salt, bytecode); emit Deployed(addr); } function computeAddress(bytes32 salt, bytes32 bytecodeHash) external view returns (address) { return Create2.computeAddress(salt, bytecodeHash, address(this)); } }
@openzeppelin/contracts/utils/Create2.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Create2.sol) pragma solidity ^0.8.0; /** * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer. * `CREATE2` can be used to compute in advance the address where a smart * contract will be deployed, which allows for interesting new mechanisms known * as 'counterfactual interactions'. * * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more * information. */ library Create2 { /** * @dev Deploys a contract using `CREATE2`. The address where the contract * will be deployed can be known in advance via {computeAddress}. * * The bytecode for a contract can be obtained from Solidity with * `type(contractName).creationCode`. * * Requirements: * * - `bytecode` must not be empty. * - `salt` must have not been used for `bytecode` already. * - the factory must have a balance of at least `amount`. * - if `amount` is non-zero, `bytecode` must have a `payable` constructor. */ function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) { require(address(this).balance >= amount, "Create2: insufficient balance"); require(bytecode.length != 0, "Create2: bytecode length is zero"); /// @solidity memory-safe-assembly assembly { addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt) } require(addr != address(0), "Create2: Failed on deploy"); } /** * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the * `bytecodeHash` or `salt` will result in a new destination address. */ function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) { return computeAddress(salt, bytecodeHash, address(this)); } /** * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. */ function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) // Get free memory pointer // | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... | // |-------------------|---------------------------------------------------------------------------| // | bytecodeHash | CCCCCCCCCCCCC...CC | // | salt | BBBBBBBBBBBBB...BB | // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA | // | 0xFF | FF | // |-------------------|---------------------------------------------------------------------------| // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC | // | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ | mstore(add(ptr, 0x40), bytecodeHash) mstore(add(ptr, 0x20), salt) mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff mstore8(start, 0xff) addr := keccak256(start, 85) } } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"event","name":"Deployed","inputs":[{"type":"address","name":"addr","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"computeAddress","inputs":[{"type":"bytes32","name":"salt","internalType":"bytes32"},{"type":"bytes32","name":"bytecodeHash","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"addr","internalType":"address"}],"name":"deploy","inputs":[{"type":"bytes32","name":"salt","internalType":"bytes32"},{"type":"bytes","name":"bytecode","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]}]
Contract Creation Code
0x608060405234801561001057600080fd5b506040516108cc3803806108cc833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b6107b5806101176000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063481286e6146100465780638da5cb5b14610076578063cdcb760a14610094575b600080fd5b610060600480360381019061005b919061035a565b6100c4565b60405161006d91906103db565b60405180910390f35b61007e6100d9565b60405161008b91906103db565b60405180910390f35b6100ae60048036038101906100a9919061053c565b6100fd565b6040516100bb91906103db565b60405180910390f35b60006100d18383306101d9565b905092915050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461018e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101859061061b565b60405180910390fd5b61019a60008484610204565b90507ff40fcec21964ffb566044d083b4073f29f7f7929110ea19e1b3ebe375d89055e816040516101cb91906103db565b60405180910390a192915050565b6000604051836040820152846020820152828152600b810160ff815360558120925050509392505050565b600083471015610249576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161024090610687565b60405180910390fd5b60008251141561028e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610285906106f3565b60405180910390fd5b8282516020840186f59050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610309576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103009061075f565b60405180910390fd5b9392505050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b61033781610324565b811461034257600080fd5b50565b6000813590506103548161032e565b92915050565b600080604083850312156103715761037061031a565b5b600061037f85828601610345565b925050602061039085828601610345565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006103c58261039a565b9050919050565b6103d5816103ba565b82525050565b60006020820190506103f060008301846103cc565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61044982610400565b810181811067ffffffffffffffff8211171561046857610467610411565b5b80604052505050565b600061047b610310565b90506104878282610440565b919050565b600067ffffffffffffffff8211156104a7576104a6610411565b5b6104b082610400565b9050602081019050919050565b82818337600083830152505050565b60006104df6104da8461048c565b610471565b9050828152602081018484840111156104fb576104fa6103fb565b5b6105068482856104bd565b509392505050565b600082601f830112610523576105226103f6565b5b81356105338482602086016104cc565b91505092915050565b600080604083850312156105535761055261031a565b5b600061056185828601610345565b925050602083013567ffffffffffffffff8111156105825761058161031f565b5b61058e8582860161050e565b9150509250929050565b600082825260208201905092915050565b7f496d6d757461626c654f776e657243726561746532466163746f72793a204f6e60008201527f6c79204f776e65722063616e2063616c6c20746869732066756e6374696f6e2e602082015250565b6000610605604083610598565b9150610610826105a9565b604082019050919050565b60006020820190508181036000830152610634816105f8565b9050919050565b7f437265617465323a20696e73756666696369656e742062616c616e6365000000600082015250565b6000610671601d83610598565b915061067c8261063b565b602082019050919050565b600060208201905081810360008301526106a081610664565b9050919050565b7f437265617465323a2062797465636f6465206c656e677468206973207a65726f600082015250565b60006106dd602083610598565b91506106e8826106a7565b602082019050919050565b6000602082019050818103600083015261070c816106d0565b9050919050565b7f437265617465323a204661696c6564206f6e206465706c6f7900000000000000600082015250565b6000610749601983610598565b915061075482610713565b602082019050919050565b600060208201905081810360008301526107788161073c565b905091905056fea2646970667358221220fb30dbe30638a0a359d62727baaa5fdca713c5564af1271868365bbae385876d64736f6c6343000809003300000000000000000000000004c8c6c56dab836f8bd62cb6884371507e706806
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063481286e6146100465780638da5cb5b14610076578063cdcb760a14610094575b600080fd5b610060600480360381019061005b919061035a565b6100c4565b60405161006d91906103db565b60405180910390f35b61007e6100d9565b60405161008b91906103db565b60405180910390f35b6100ae60048036038101906100a9919061053c565b6100fd565b6040516100bb91906103db565b60405180910390f35b60006100d18383306101d9565b905092915050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461018e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101859061061b565b60405180910390fd5b61019a60008484610204565b90507ff40fcec21964ffb566044d083b4073f29f7f7929110ea19e1b3ebe375d89055e816040516101cb91906103db565b60405180910390a192915050565b6000604051836040820152846020820152828152600b810160ff815360558120925050509392505050565b600083471015610249576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161024090610687565b60405180910390fd5b60008251141561028e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610285906106f3565b60405180910390fd5b8282516020840186f59050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610309576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103009061075f565b60405180910390fd5b9392505050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b61033781610324565b811461034257600080fd5b50565b6000813590506103548161032e565b92915050565b600080604083850312156103715761037061031a565b5b600061037f85828601610345565b925050602061039085828601610345565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006103c58261039a565b9050919050565b6103d5816103ba565b82525050565b60006020820190506103f060008301846103cc565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61044982610400565b810181811067ffffffffffffffff8211171561046857610467610411565b5b80604052505050565b600061047b610310565b90506104878282610440565b919050565b600067ffffffffffffffff8211156104a7576104a6610411565b5b6104b082610400565b9050602081019050919050565b82818337600083830152505050565b60006104df6104da8461048c565b610471565b9050828152602081018484840111156104fb576104fa6103fb565b5b6105068482856104bd565b509392505050565b600082601f830112610523576105226103f6565b5b81356105338482602086016104cc565b91505092915050565b600080604083850312156105535761055261031a565b5b600061056185828601610345565b925050602083013567ffffffffffffffff8111156105825761058161031f565b5b61058e8582860161050e565b9150509250929050565b600082825260208201905092915050565b7f496d6d757461626c654f776e657243726561746532466163746f72793a204f6e60008201527f6c79204f776e65722063616e2063616c6c20746869732066756e6374696f6e2e602082015250565b6000610605604083610598565b9150610610826105a9565b604082019050919050565b60006020820190508181036000830152610634816105f8565b9050919050565b7f437265617465323a20696e73756666696369656e742062616c616e6365000000600082015250565b6000610671601d83610598565b915061067c8261063b565b602082019050919050565b600060208201905081810360008301526106a081610664565b9050919050565b7f437265617465323a2062797465636f6465206c656e677468206973207a65726f600082015250565b60006106dd602083610598565b91506106e8826106a7565b602082019050919050565b6000602082019050818103600083015261070c816106d0565b9050919050565b7f437265617465323a204661696c6564206f6e206465706c6f7900000000000000600082015250565b6000610749601983610598565b915061075482610713565b602082019050919050565b600060208201905081810360008301526107788161073c565b905091905056fea2646970667358221220fb30dbe30638a0a359d62727baaa5fdca713c5564af1271868365bbae385876d64736f6c63430008090033