App Devs
Issuing new assets with SuperchainERC20
💡

The SuperchainERC20 standard is ready for production deployments. However, the OP Stack interoperability upgrade, required for crosschain messaging, is currently still in active development.

Issuing new assets with SuperchainERC20

Overview

This guide explains how to issue new assets with the SuperchainERC20 (opens in a new tab) contract. Those assets can then be bridged quickly and safely using the SuperchainTokenBridge (opens in a new tab) contract (once interop is operational). For more information on how it works, see the explainer.

Note that bridging assets through the Superchain using SuperchainTokenBridge never affects the total supply of your asset. The supply remains fixed, bridging only changes the chain on which the asset is located. The token's total amount across all network always remains the same, ensuring value stability.

To ensure fungibility across chains, SuperchainERC20 assets must have the same contract address on all chains. This requirement abstracts away the complexity of cross-chain validation. Achieving this requires deterministic deployment methods. There are multiple ways to do this. Here we will use the SuperchainERC20 Starter Kit.

What you'll do

What you'll learn

  • How to deploy SuperchainERC20 tokens on different chains at the same address.

Prerequisites

Before starting this tutorial, ensure your development environment meets the following requirements:

Technical knowledge

  • Understanding of smart contract development
  • Familiarity with blockchain concepts

Development environment

  • Unix-like operating system (Linux, macOS, or WSL for Windows)
  • Git for version control

Required tools

The tutorial uses these primary tools:

  • Foundry: For sending transactions to blockchains.

Step by step explanation

Install the prerequisites and the SuperchainERC20 Starter Kit

Follow the setup steps in the SuperchainERC20 Starter Kit.

Prepare for deployment

The Starter Kit already deploys a SuperchainERC20 token to Supersim. Here we will deploy it to the Interop devnet.

  1. Edit packages/contracts/foundry.toml to add the RPC endpoints for the devnet (add the bottom two rows).

    [rpc_endpoints]
    op_chain_a = "http://127.0.0.1:9545"
    op_chain_b = "http://127.0.0.1:9546"
    devnet0 = "https://interop-alpha-0.optimism.io"
    devnet1 = "https://interop-alpha-1.optimism.io"

    You can import most RPC endpoints with this command, but it does not include the Interop devnet.

    pnpm contracts:update:rpcs
  2. Edit packages/contracts/configs/deploy-config.toml for the deployment settings.

    • Set these parameters in the [deploy-config] section:

      ParameterMeaningExample
      saltA unique identifierCarthage
      chainsThe chains to deploy the contract1["devnet0","devnet1"]

      (1) These names must correspond to the chain names in the [rpc-endpoints] section of foundry.toml you updated in the previous step.

    • Set these parameters in the [token] section:

      ParameterMeaningExample
      owner_addressOwner of the tokenYour address1
      nameToken nameQuick Transfer Token
      symbolToken symbolQTT
      decimalsNumber of decimal places18

      (1) This should be an address you control (for which you know the private key), which has some ETH on the devnets. See here to add ETH to the devnets.

    Here is a sample packages/contracts/configs/deploy-config.toml file you can use, as long as you update owner_address.

    [deploy_config]
    salt = "is the source of our word salary"
    chains = ["devnet0","devnet1"]
     
    [token]
    owner_address = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
    name = "Quick Transfer Token"
    symbol = "QTT"
    decimals = 18
  3. Set the private key. Edit packages/contracts/.env to set DEPLOYER_PRIVATE_KEY to the private key of an account that has ETH on both devnet blockchains.

    DEPLOYER_PRIVATE_KEY= <<<private key goes here>>>

Deploy the contracts

Run the deployment script.

pnpm contracts:deploy:token
Sanity check
  1. Set TOKEN_ADDRESS to the address where the token is deployed.

    TOKEN_ADDRESS=0x322f4aF25D370BE2A2C74eEFf0DD0d2AF2e7eD75
  2. Set PRIVATE_KEY to the private key for the owner address.

    PRIVATE_KEY= <<<private key goes here>>>
  3. Mint tokens for an address you control on both chains. The owner address is the easiest to use.

    OWNER_ADDRESS=`cast wallet address --private-key $PRIVATE_KEY`
    RPC_DEV0=https://interop-alpha-0.optimism.io
    RPC_DEV1=https://interop-alpha-1.optimism.io
    cast send --private-key $PRIVATE_KEY $TOKEN_ADDRESS "mintTo(address,uint256)" $OWNER_ADDRESS 1000 --rpc-url $RPC_DEV0
    cast send --private-key $PRIVATE_KEY $TOKEN_ADDRESS "mintTo(address,uint256)" $OWNER_ADDRESS 2000 --rpc-url $RPC_DEV1       
  4. Check the balance of the owner address on both blockchains.

    cast call $TOKEN_ADDRESS "balanceOf(address)" $OWNER_ADDRESS --rpc-url $RPC_DEV0 | cast to-dec        
    cast call $TOKEN_ADDRESS "balanceOf(address)" $OWNER_ADDRESS --rpc-url $RPC_DEV1 | cast to-dec

Next steps