How to create a standard ERC20 token in L2
This section will provide step-by-step instructions on creating an ERC20 token for L2 that works with L1.
Last updated
This section will provide step-by-step instructions on creating an ERC20 token for L2 that works with L1.
Last updated
We will cover two approaches: creating a standard ERC20 token and developing a customized ERC20 token.
You can use the L2StandardTokenFactory
contract to create ERC20 tokens conveniently.
Using Titan block explorer, navigate to the L2StandardTokenFactory
contract page. (Titan / Titan Sepolia)
You can see the Write Contract tab in the middle of the screen, as shown below.
Click the Connect wallet button to connect your wallet.
Use the createStandardL2Token
first function in L2StandardTokenFactory.
Enter each element in the input box below and click the Write button:
_L1Token(address)
: The address of the L1 token to be connected through the bridge.
_name(string)
: Token name
_symbols(string)
: Token symbols
You can check the L2 token address through the event of the transaction executed through (2) above.
You can check the transaction sent on the Transactions tab in the middle of the L2StandardTokenFactory
contract page.
You can click on the transaction that takes you to the Transaction details page, where you can see the details of the transaction.
You can see the value you entered in the middle of the transaction page. You'll see what you entered, as shown in the image below.
And just below that, you'll see the Internal Transactions tab. In the below screenshot, the red boxed area is the L2Token
that was created. The screenshot below shows the name, but it might look like an address in your case.
Let's see how to verify the L2 token shown above (this part is not mandatory).
This method is for those who know using hardhat. (If you don't have experience using hardhat, please check the verify request box when registering the bridge token below, and the team will verify it.)
The code is available at https://github.com/tokamak-network/tokamak-titan/tree/L2Token_verify/packages/contracts
Following code can be used to verify the contract:
After creating an L2 token, you need to register on Bridge. Fill in the token information on the token registration form (link to the token registration form on Bridge) and submit it. The team will check it, register it on Bridge, and notify you of the result.
With the L2StandardTokenFactory
, you can create a standard ERC20 with decimals
18 associated with L1. However, if your L1 token is not decimal 18, you cannot use L2StandardTokenFactory
.
In this case, you can inherit L2StandardERC20
and add the necessary functions to create a contract.
This is an example hardhat.config.ts
file.
Below is contracts/L2CustomERC20.sol
contract code.
Following is a sample script scripts/deploy.ts,
to deploy the L2CustomERC20
contract created above.
You can compile, deploy, and verify as follows.
After creating an L2 token, you can register on Bridge. Please fill in the token information on the token registration form (link to the token registration form on Bridge) and submit it. The team will check and register your token on Bridge and notify you of the result.