Bridging Module
Last updated
Last updated
BridgeableToken.sol allows an already deployed ERC-20 token to be bridgeable by leveraging LayerZero's OFT standard. The Parallel Bridging Module codebase is available here, licensed under MIT License and has been audited by BailSecurity. You can find the report here. Deployed addresses can be seen here.
The key features of BridgeableToken
are:
Ability to burn principal tokens (named XXX
) and send a message to LayerZero to mint the mirrored token on the other chain.
Ability to mint principal tokens by receiving a message from LayerZero from the mirrored BridgeableToken contract on the other chain.
Ability to cap the principal token amount to mint and burn (per day and globally). Since minting tokens from a received message must not revert, when the mint limit is reached, the user will receive OFT tokens (named lz-XXX
) instead of principal tokens.
Ability to swap OFT tokens to principal tokens if the limits are not reached.
The OFT standard from LayerZero allows fungible tokens to be transferred across multiple blockchains without asset wrapping or middlechains. The BridgeableToken contract is designed to comply with this standard to mint/burn the OFT tokens if the mint/burn limit is reached. More details about the OFT standard can be found here.
When the contract receives a message from LayerZero to mint principal tokens on its chain, it must not revert. Due to the mint limit on the principal token, we still have to credit the user with something. This is why we mint OFT tokens instead of principal tokens XXX. The user can then swap these OFT tokens for principal tokens if the limit is not reached.
When the contract receives a message from LayerZero, it will mint tokens to the specified receiver address. Depending on the mint limits, the receiver will be credited with principal tokens and/or OFT tokens.
Users can send principal tokens or OFT tokens to a receiver address on another chain by calling the send
function. A check regarding burn limits and isIsolateMode is performed before sending the message to LayerZero. If any check fails, the function will revert. The user's tokens will be burned before sending the message to LayerZero.