TokenDeployer

0x005f841e201079cc047ac707b5f1b634719b7474

Verification
Verified
v0.8.20+commit.a1b79de6
Type
Contract
10,434 bytes
ABI entries
8
3 read · 2 write
License
none

Contract information

Address
0x005f841e201079cc047ac707b5f1b634719b7474
Chain
Robinhood Chain (4663)
Compiler
v0.8.20+commit.a1b79de6
Optimization
Enabled
Creation tx
0x8773deb809…7dc0639bf4

Token

Not a token

This contract does not expose ERC-20 metadata.

Read contract (3)

admin()address
factory()address
tokenInitCodeHash(uint16)bytes32

Events (2)

FactorySetTokenDeployed

ABI

[
  {
    "inputs": [],
    "stateMutability": "nonpayable",
    "type": "constructor"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "factory",
        "type": "address"
      }
    ],
    "name": "FactorySet",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "token",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "bytes32",
        "name": "salt",
        "type": "bytes32"
      },
      {
        "indexed": false,
        "internalType": "uint16",
        "name": "slippageBps",
        "type": "uint16"
      }
    ],
    "name": "TokenDeployed",
    "type": "event"
  },
  {
    "inputs": [],
    "name": "admin",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "salt",
        "type": "bytes32"
      },
      {
        "internalType": "uint16",
        "name": "slippageBps",
        "type": "uint16"
      }
    ],
    "name": "deploy",
    "outputs": [
      {
        "internalType": "address",
        "name": "token",
        "type": "address"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "factory",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_factory",
        "type": "address"
      }
    ],
    "name": "setFactory",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint16",
        "name": "slippageBps",
        "type": "uint16"
      }
    ],
    "name": "tokenInitCodeHash",
    "outputs": [
      {
        "internalType": "bytes32",
        "name": "",
        "type": "bytes32"
      }
    ],
    "stateMutability": "pure",
    "type": "function"
  }
]

Source code

pragma solidity ^0.8.20;

import {Token} from "./Token.sol";

contract TokenDeployer {
    address public immutable admin;
    address public factory;

    event TokenDeployed(address indexed token, bytes32 salt, uint16 slippageBps);
    event FactorySet(address indexed factory);

    constructor() {
        admin = msg.sender;
    }

    function setFactory(address _factory) external {
        require(msg.sender == admin, "ONLY_ADMIN");
        require(factory == address(0), "FACTORY_SET");
        require(_factory != address(0), "ZERO_FACTORY");
        factory = _factory;
        emit FactorySet(_factory);
    }

    function deploy(bytes32 salt, uint16 slippageBps) external returns (address token) {
        require(msg.sender == factory, "ONLY_FACTORY");
        bytes memory bytecode = abi.encodePacked(
            type(Token).creationCode,
            abi.encode(slippageBps)
        );
        assembly {
            token := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
        }
        require(token != address(0), "CREATE2_FAILED");
        emit TokenDeployed(token, salt, slippageBps);
    }

    function tokenInitCodeHash(uint16 slippageBps) external pure returns (bytes32) {
        return keccak256(abi.encodePacked(type(Token).creationCode, abi.encode(slippageBps)));
    }

}
Chain explorer1518msChain node79ms