Unichain Docs

Deploy a Token

Learn how to deploy a SuperchainERC20 contract on Unichain

Deploying a token on Unichain is as simple as deploying a smart contract. For additional reading, developers should see deploy a smart contract

Summary

Deploy a token contract, minting 1,000,000 tokens to the deployer

Requirements

ETH on Unichain is required, see Funding a Wallet

  1. The guide uses foundry

    for deployments. Install it by running:

    curl -L https://foundry.paradigm.xyz | bash
  2. Add Unichain to your foundry.toml

    [rpc_endpoints]
    unichain = "https://sepolia.unichain.org"
  3. Install SuperchainERC20 implementation from Optimism's Interop-lib

    :

    forge install ethereum-optimism/interop-lib

    Unichain's cross-chain interoperability standard is built on SuperchainERC20, a token implementation that extends traditional ERC20 functionality with cross-chain capabilities. While maintaining full ERC20 compatibility, it enables seamless token movement across the OP Stack ecosystem. For more information, please see Optimism's SuperchainERC20 documentation

    .

    Other community ERC20 implementations are available such as:

Steps

  1. Define the Token Contract

    Most tokens inherit an existing ERC-20 implementation. For this guide, we use Optimism's SuperchainERC20 implementation to deploy a token with crosschain-interoperability.

    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.20;
     
    import {SuperchainERC20} from "interop-lib/src/SuperchainERC20.sol";
     
    contract ExampleToken is SuperchainERC20 {
     
        constructor() {
            _mint(msg.sender, 1_000_000e18);
        }
        
        function name() public pure override returns (string memory) {
            return "MyExampleToken";
        }
     
        function symbol() public pure override returns (string memory) {
            return "MET";
        }
    }

    In the example, the deployer is minted 1,000,000 EXT tokens. Developers can configure:

    • Token name, i.e. ExampleToken

    • Token symbol, i.e. EXT

    • Minting mechanisms

  2. Deploy the Token

    Deploy the token (smart contract) with foundry:

    forge create src/ExampleToken.sol:ExampleToken \
        --rpc-url unichain \
        --private-key {YourPrivateKey} \
        --etherscan-api-key {EtherscanAPIKey} \
        --verify

    See deploy a smart contract

    for more information

  3. Transferring Tokens (Optional)

    Upon creation of the token, the deployer is the owner of all 1,000,000 tokens. To transfer the tokens, use the transfer function:

    /// @notice Moves `amount` tokens from the caller's account to `to`.
    function transfer(address to, uint256 amount) external returns (bool);

    The transfer function is callable from a block explorer, a web framework, or a backend language such as typescript, python, or rust. To transfer tokens using cast

    :

    cast send {TOKEN_ADDRESS} "transfer(address,uint256)" {RECIPIENT_ADDRESS} {AMOUNT} \
        --rpc-url unichain \
        --private-key {YourPrivateKey}
  4. Create a Trading Pool on Uniswap v4

    This step is also optional, but developers enable trading of their new token on Uniswap v4:

Last updated on

On this page