Skip to content

Latest commit

 

History

History
 
 

standard-bridge-standard-token

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Bridging your Standard ERC20 token to Optimism using the Standard Bridge

Discord Twitter Follow

This is a practical guide to getting your ERC20 token deployed on Optimism and bridging it using the Standard Bridge implementation.

For an L1/L2 token pair to work on the Standard Bridge the L2 token contract has to implement IL2StandardERC20.

Deploying a standard token

If there is no need for custom logic on Optimism, it's easiest to use the standard token, available as the L2StandardERC20 contract as part of the @eth-optimism/contracts package. The standard token factory can deploy the standard contract for you.

You can use the deployment script under scripts/deploy-standard-token.js to call this token factory. The Hardhat config hardhat.config.js is already setup for both Optimism (the production network) and Optimism Goerli (the testnet).

Configuration

  1. Install the necessary packages.

    yarn
  2. Copy the example configuration to the production one:

    cp .env.example .env
  3. Get an Alchemy application for Optimism, either Optimism Goerli for testing or Optimism Mainnet for deployment.

  4. Edit .env to set the deployment parameters:

    • MNEMONIC, the mnemonic for an account that has enough ETH for the deployment.
    • L2_ALCHEMY_KEY, the key for the alchemy application for the endpoint.
    • L1_TOKEN_ADDRESS, the address of the L1 ERC20 which you want to bridge. The default value, 0x32B3b2281717dA83463414af4E8CfB1970E56287 is a test ERC-20 contract on Goerli that lets you call faucet to give yourself test tokens.
    • L2_TOKEN_NAME and L2_TOKEN_SYMBOL are the parameters for the L2 token contract. In almost all cases, these would be the same as the L1 token name and symbol.

Running the deploy script

  1. Run the script:

    yarn hardhat run scripts/deploy-standard-token.js --network optimism-goerli

The script uses our token factory contract OVM_L2StandardTokenFactory available as a predeploy at 0x4200000000000000000000000000000000000012 to deploy a standard token on L2. At the end you should get a successful output with the text for a data.json file you'll be able to use to add the token to the bridge. Note that if you have the token both on the test network and the production network you should not use that data.json by itself, but combine it the information in the two files.

Adding a token to the bridge

You can find the directions to add a token to the bridge here. If you want an empty logo for testing purposes, you can use this file from Wikipedia.

The PR you submit should be similar to this one.

Deploying a Custom Token

When the L2StandardERC20 implementation does not satisfy your requirements, we can consider allowing a custom implemetation. See this tutorial on getting a custom token implemented and deployed to Optimistic Ethereum.

Testing

For testing your token, see tutorial on depositing and withdrawing between L1 and L2.