Skip to content
Verified contractExactMIT

DeployHelper

Address0x94e55efa9c481f91e76220aba83f0e302983f17c
Balance

0 ETH

 

Transactions

17

 

Compiler

solc 0.8.26

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.26+commit.8a97fa7a
Language
solidity
Optimization
Yes, 1,000 runs
EVM version
cancun
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,393,579
Creation transaction
0xd456d97a22…9aa5bc2219

script/DeployHelper.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

/// @title DeployHelper
/// @notice Deploys the HOOKMIND contracts from one address with predictable nonces, so that every
///         address is known before anything is deployed. The contracts reference each other in
///         cycles (the registry names the factory and the factory names the registry), which rules
///         out plain CREATE2 for all of them: a CREATE2 address depends on constructor arguments.
///         This helper is itself deployed with CREATE2, so its address, and with it the address of
///         its n-th deployment, is the same on every chain for the same deployer and salt.
/// @dev Used once, by the deployer key, at deployment. It holds no funds and no role afterwards.
contract DeployHelper {
    /// @notice The only caller.
    address public immutable owner;

    error OnlyOwner();
    error DeploymentFailed();

    /// @param owner_ The deployer.
    constructor(address owner_) {
        owner = owner_;
    }

    /// @notice Deploys `initCode` with CREATE; the address depends only on this helper's nonce.
    /// @param initCode Creation code with constructor arguments appended.
    /// @return deployed The new contract.
    function create(bytes calldata initCode) external returns (address deployed) {
        if (msg.sender != owner) revert OnlyOwner();
        bytes memory code = initCode;
        assembly ("memory-safe") {
            deployed := create(0, add(code, 0x20), mload(code))
        }
        if (deployed == address(0)) revert DeploymentFailed();
    }

    /// @notice Deploys `initCode` with CREATE2 (used for the hook, whose address must carry its
    ///         permission bits).
    /// @param salt The mined salt.
    /// @param initCode Creation code with constructor arguments appended.
    /// @return deployed The new contract.
    function create2(bytes32 salt, bytes calldata initCode) external returns (address deployed) {
        if (msg.sender != owner) revert OnlyOwner();
        bytes memory code = initCode;
        assembly ("memory-safe") {
            deployed := create2(0, add(code, 0x20), mload(code), salt)
        }
        if (deployed == address(0)) revert DeploymentFailed();
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 1000,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "@uniswap/v4-core/=lib/v4-core/",
    "v4-core/=lib/v4-core/",
    "@uniswap/v4-periphery/=lib/v4-periphery/",
    "v4-periphery/=lib/v4-periphery/",
    "uniswap-hooks/=lib/uniswap-hooks/",
    "permit2/=lib/v4-periphery/lib/permit2/",
    "solmate/=lib/v4-core/lib/solmate/",
    "@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
    "ds-test/=lib/v4-core/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "hardhat/=lib/v4-core/node_modules/hardhat/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.