ERC20 Tokens with Zircuit Canonical Bridge
Zircuit's canonical bridge is derived from the bridge in the OP-stack framework. Therefore, the ERC20 tokens on Zircuit with their counterparts deployed on Ethereum mainnet follow the same architecture. If you would like to deploy an ERC20 token with no special logic, you can do so by using the prepared factory available on address 0x4200000000000000000000000000000000000012 on Zircuit.
In some cases, developers may desire to deploy ERC20 contracts with additional functionality that is not available in the templated contract that the factory creates, and they may want for these contracts to work with Zircuit's canonical bridge. This is certainly possible --- you may use any custom implementation provided that it meets the following conditions (you can reference the template implementation show below):
The token implements the
IOptimismMintableERC20
interface together with EIP165, and reports that this interface is implemented. See functionsupportsInterface
in the sample implementation below.The canonical bridge is given the privilege to mint tokens to the users when they lock their tokens on L1 by calling the
depositERC20
function on the L1StandardBridge contract, and to burn tokens from the users' accounts when they callbridgeERC20
function on the L2StandardBridge contract. See the modifieronlyBridge
, and functionsmint
andburn
in the reference implementation. Note that upon deposit, the bridge on L1 locks the respective amount of tokens and mints them to the user on L2. Upon withdrawal, it burns the respective number of tokens on L2 from the user's balance, and releases them on L1. The canonical bridge inherently assumes that the number of tokens in circulation on L2 matches the number of tokens locked in the bridge on L1. The developers should not violate this principle. This might happen by allowing parties other than the bridge to mint and burn tokens, or by implementing features such as rebasing, or fees on transfer.The
REMOTE_TOKEN
,BRIDGE
, andDECIMALS
storage variables are properly initialized. TheREMOTE_TOKEN
address should match the token deployed on L1 as the bridge performs a check while bridging. The address of theL2StandardBridge
on Zircuit is 0x4200000000000000000000000000000000000012.
Below is a template implementation of an ERC20 that can be further extended with custom logic.
PreviousVerifying ContractsNextDevelopment Frameworks
Last updated 11 days ago