Omnichain Fungible Token (OFT)
The Omnichain Fungible Token (OFT) Standard allows fungible tokens to be transferred across multiple blockchains without asset wrapping, middlechains, or liquidity pools.
This standard work by burning tokens on the source chain whenever an omnichain transfer is initiated, sending a message via the protocol and delivering a function call to the destination contract to mint the same number of tokens burned, creating a unified supply across both networks.
Using this design pattern, LayerZero can extend any fungible token to interoperate with other chains using the protocol. The most widely used of these standards is OFT.sol
, an extension of the OApp Contract Standard and the ERC20 Token Standard.
Contract Standards
ERC20: the default fungible token standard for EVM compatible blockchains, supported across all LayerZero pathways.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
import "@layerzerolabs/lz-evm-oapp-v2/contracts/standards/oft/OFT.sol";
contract MyOFT is OFT {
constructor(
string _name, // token name
string _symbol, // token symbol
address _lzEndpoint, // LayerZero Endpoint address
uint8 _localDecimals) // token decimals
OFT(_name, _symbol, _localDecimals, _lzEndpoint) {}
}
For deployment, usage, and best practices, see the OFT Quickstart.
OFT Adapter
OFT Adapter works as an intermediary contract that handles sending and receiving deployed fungible tokens. For example, when transferring an ERC20 from the source chain (Chain A), the token will lock in the OFT Adapter, triggering a new token to mint on the destination chain (Chain B) via the peer OFT.
When you want to unlock the ERC20 token in the source chain's OFT Adapter, you will call send on the OFT Contract (Chain B), triggering the minted OFT token to be burnt, and sending a message via the protocol to unlock the same amount of token from the Adapter and transfer to the receiving address (Chain A).
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
import "@layerzerolabs/lz-evm-oapp-v2/contracts/standards/oft/OFTAdapter.sol";
contract MyOFTAdapter is OFTAdapter {
constructor(
address _token, // deployed ERC20 token address
address _lzEndpoint, // LayerZero Endpoint address
uint8 _localDecimals) // token decimals
OFTAdapter(_token, _localDecimals, _lzEndpoint) {}
}
For deployment, usage, and best practices, see OFT Adapter.