Skip to main content
Version: Endpoint V2

OFT Adapter

OFT Adapter allows an existing token to expand to any supported chain as a native token with a unified global supply, inheriting all the features of the OFT Standard. This works as an intermediary contract that handles sending and receiving tokens that have already been deployed.

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 selected destination chain (Chain B) via the paired OFT Contract.

OFT Example OFT Example

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).


Use this extension by following the normal OFT deployment guide, substituting OFT Adapter for the normal OFT Contract on the chain that has the already deployed ERC20 token, and approving OFT Adapter as a spender of your ERC20 token.


There can only be one OFT Adapter used in an OFT deployment. Multiple OFT Adapters break omnichain unified liquidity by effectively creating token pools. If you create OFT Adapters on multiple chains, you have no way to guarantee finality for token transfers due to the fact that the source chain has no knowledge of the destination pool's supply (or lack of supply). This can create race conditions where if a sent amount exceeds the available supply on the destination chain, those sent tokens will be permanently lost.

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { OFTAdapter } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/OFTAdapter.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

contract OFTAdapterMock is OFTAdapter {
address _token, // a deployed, already existing ERC20 token address
address _layerZeroEndpoint, // local endpoint address
address _owner // token owner used as a delegate in LayerZero Endpoint
) OFTAdapter(_token, _layerZeroEndpoint, _owner) Ownable(_owner) {
// your custom contract logic here

Sending a Message

  1. Deploy your OFTAdapter contract using your ERC20 token's address.

  2. Deploy your OFT contract on the other chain(s) you want to connect.

  3. Set your contracts to trust one another using setPeer. Pair them to one another's endpoint and address.

  4. Set how much gas to use when receiving a cross-chain transfer call. This can either be enforced (i.e., every caller must pay this amount) or extra (i.e., each caller can decide how much gas to deliver). It is recommended to set a baseline enforced gas amount, where extra gas options will be added on top of the baseline. Read more in Execution Options.

  5. Required only for OFTAdapter: Approve your OFTAdapter as a spender of your ERC20 token by calling your deployed token's approve function. This comes standard in the ERC20 interface, and is required when using an intermediary contract to spend token amounts on behalf of the caller.


If you prefer reading the contract code, see the OFT Adapter Github.