- A standard token deployed through the
OptimismMintableERC20Factory. Tokens created by this factory contract are compatible with the Standard Bridge system and include basic logic for deposits, transfers, and withdrawals. Choose this path if you don’t need any specialized logic in your L2 token. - A custom token that implements the
IOptimismMintableERC20interface itself. A custom token allows you to do things like trigger extra logic whenever a token is deposited. Choose this path if you need specialized behavior like that.
The Standard Bridge does not support fee on transfer tokens or rebasing tokens because they can cause bridge accounting errors.
About OptimismMintableERC20s
The Standard Bridge system requires that L2 representations of L1 tokens implement theIOptimismMintableERC20 interface.
This interface is a superset of the standard ERC-20 interface and includes functions that allow the bridge to properly verify deposits/withdrawals and mint/burn tokens as needed.
Your L2 token contract must implement this interface in order to be bridged using the Standard Bridge system.
This tutorial will show you how to deploy a basic standardized ERC-20 token through the OptimismMintableERC20Factory, or how to write a custom token that implements the interface itself.
Dependencies
- cast, used on the standard-token path to deploy through the factory
- A web browser with a wallet extension, used on the custom-token path to deploy with Remix
Get ETH on Sepolia and OP Sepolia
This tutorial explains how to create a bridged ERC-20 token on OP Sepolia. You will need to get some ETH on both of these testnets.Get an L1 ERC-20 token address
You will need an L1 ERC-20 token for this tutorial. If you already have an L1 ERC-20 token deployed on Sepolia, you can skip this step. Otherwise, you can use the testing token located at0x5589BB8228C07c4e15558875fAf2B859f678d129 that includes a faucet() function that can be used to mint tokens.
Create an L2 ERC-20 token
Once you have an L1 ERC-20 token, you can create a corresponding L2 ERC-20 token on OP Sepolia. Pick the tab that matches the kind of token you want to create.- Standard token
- Custom token
You can deploy your L2 ERC-20 token using the
OptimismMintableERC20Factory.
All tokens created by the factory implement the IOptimismMintableERC20 interface and are compatible with the Standard Bridge system.1
Add a private key to your environment
You need a private key in order to sign transactions.
Set your private key as an environment variable with the
export command.
Make sure this private key corresponds to an address that has ETH on .Want to create a new wallet for this tutorial?
If you have
cast installed you can run cast wallet new in your terminal to create a new wallet and get the private key.2
Add an OP Sepolia RPC URL to your environment
You’ll need an RPC URL in order to connect to OP Sepolia.
Set your RPC URL as an environment variable with the
export command.3
Add your L1 ERC-20 token address to your environment
You’ll need to know the address of your L1 ERC-20 token in order to create a bridged representation of it on OP Sepolia.
Set your L1 ERC-20 token address as an environment variable with the
export command.4
Deploy your L2 ERC-20 token
You can now deploy your L2 ERC-20 token using the
OptimismMintableERC20Factory.
Use the cast command to trigger the deployment function on the factory contract.
This example command creates a token with the name “My Standard Demo Token” and the symbol “L2TKN”.
The resulting L2 ERC-20 token address is printed to the console.Bridge some tokens
Now that you have an L2 ERC-20 token, you can bridge some tokens from L1 to L2. Check out the tutorial on Bridging ERC-20 tokens with viem to learn how to bridge your L1 ERC-20 to L2s using viem. If you deployed the custom example token from this tutorial, remember that the withdrawal step will not work for it: the example contract’sburn function always reverts, which is exactly what that example was meant to demonstrate.