Overview
The LayerZero OFT Transfer API provides a simple way to fetch the calldata necessary to call thesend implementation on any known OFT deployment. This guide demonstrates complete integration examples for both EVM and Solana chains, showing how the same API endpoints work across different blockchain environments.
Key Benefits:
- Universal API: Same endpoints work for EVM β EVM, Solana β EVM, and EVM β Solana transfers
- Chain-agnostic discovery: Find tokens across all supported chains with a single API call
- Pre-built transaction data: Get ready-to-execute transaction data for any OFT transfer between chains
- Built-in validation and error handling
- LayerZero transaction tracking
Crosschain Architecture
The LayerZero OFT API abstracts the complexity of crosschain transfers by providing the same interface regardless of source and destination chains. Whether youβre transferring from Ethereum to Solana or Solana to BSC, you use the same API endpoints with chain-specific transaction execution.Prerequisites
- Node.js 16+ and npm/yarn
- LayerZero API key (request here)
- Basic knowledge of the OFT standard
Installation
Environment Setup
- EVM Chains
- Solana
Create a
.env file in your project root:Understanding Chain Names
The LayerZero OFT API uses chain names to identify different blockchain networks. These chain names are standardized across the LayerZero ecosystem and can be imported from the@layerzerolabs/lz-definitions package for type safety.
Available Chain Names
You can import chain names as constants to avoid typos and get TypeScript autocomplete:Using Chain Names in API Calls
Chain names are used directly in API requests without any conversion needed:LayerZero OFT API Endpoints
The OFT API provides two main endpoints for token operations:1. Token Discovery API (/list)
Purpose: Discover available OFT tokens across chains and get their canonical contract addresses. Use this to find where a token is deployed and whether itβs an OFT.
Endpoint: GET https://metadata.layerzero-api.com/v1/metadata/experiment/ofts/list
Parameters:
chainNames(optional, string): Comma-separated list of chain names to search acrosssymbols(optional, string): Comma-separated list of token symbols to filter by
name: Token display namesharedDecimals: Number of decimals used across all chains for LayerZero transfersendpointVersion: LayerZero endpoint version (βv2β)deployments: Object with chain names as keys, containing deployment details for each chainaddress: The OFT contract address on that specific chain (Program ID for Solana)localDecimals: Number of decimals the token uses on that specific chaintype: Contract type (βOFT_ADAPTERβ for wrapped tokens, βOFTβ for native OFTs)innerToken: The underlying ERC20 token address (for OFT_ADAPTER types, not applicable to Solana)approvalRequired: Whether token approval is required before transfers (always false for Solana)
Understanding Decimals
For detailed explanations ofsharedDecimals and localDecimals concepts, including the decimal conversion process and overflow considerations, see the OFT Technical Reference.2. Transfer Transaction API (/transfer)
Purpose: Generate pre-built transaction data for executing OFT transfers from a source to destination network. The API returns chain-specific transaction data that can be executed using the appropriate blockchain SDK.
Endpoint: GET https://metadata.layerzero-api.com/v1/metadata/experiment/ofts/transfer
Authentication Required:
srcChainName(string): Source chain name (e.g., βsolanaβ, βethereumβ, βbscβ)dstChainName(string): Destination chain name (e.g., βethereumβ, βbscβ, βsolanaβ)srcAddress(string): Source chain OFT contract address or Program IDamount(string): Transfer amount in tokenβs smallest unitfrom(string): Sender wallet address (public key for Solana)to(string): Recipient wallet address on destination chainvalidate(boolean): Pre-validate balances and parametersoptions(string, optional): Structured LayerZero execution options as JSON string
populatedTransaction: The main transfer transaction ready to be sent viawallet.sendTransaction()approvalTransaction: Token approval transaction (if required for OFT adapters)- Both transactions contain pre-built calldata and gas estimates
(Optional) Add extraOptions
For advanced use cases, you can include LayerZero execution options to extend the base OFT functionality. Theoptions parameter allows you to specify additional gas limits, native token drops, and compose message settings.
Example with extraOptions:
-
lzReceivegas limit: The gas you specify here is added to the base gas limit already set by the OFT deployer. For example, if the OFT enforces 65,000 gas and you add 35,000, the total execution will have 100,000 gas available. -
nativeDrops: Allows you to send native chain currency (ETH, MATIC, BNB, etc.) to any receiver wallet address alongside your token transfer. The amount is specified in wei and sent directly to the specified receiver address. -
composeOptions: Used specifically for omnichain composers when your OFT transfer triggers additional smart contract logic on the destination chain. See the EVM Composer Overview for implementation details. - For detailed information about LayerZero message options, see Message Options and Message Execution Options.
Chain Name Reference
Here are common chain names available in the@layerzerolabs/lz-definitions package:
| Chain Constant | Chain Name | Network |
|---|---|---|
Chain.ETHEREUM | ethereum | Ethereum Mainnet |
Chain.BSC | bsc | BNB Smart Chain |
Chain.ARBITRUM | arbitrum | Arbitrum One |
Chain.OPTIMISM | optimism | Optimism |
Chain.BASE | base | Base |
Chain.POLYGON | polygon | Polygon |
Chain.ABSTRACT | abstract | Abstract |
- Import
Chainconstants to avoid typos and get autocomplete - Use
/listAPI without chain filters to discover all supported chains - If you see a chain missing, make sure your
@layerzerolabs/lz-definitionspackage is updated to the latest version - Check the LayerZero API reference for the complete list of supported chains
Complete Transfer Examples
- EVM to EVM
- Solana to EVM
Example: Send $PENGU from BSC to Abstract
Expected Output
- EVM Transfer
- Solana Transfer
After running the EVM example, you should see:
Common Issues & Solutions
Amount Validation Errors
Error:localDecimals and sharedDecimals. The OFT standard enforces that transfer amounts must be greater than or equal to the decimal conversion rate to prevent precision loss when transferring tokens between blockchains.
The minAmount in the error response represents the decimal conversion rate: 10^(localDecimals - sharedDecimals). In this example: 10^(18-6) = 10^12 = 1000000000000.
Solution: Ensure your amount (in minor units) is greater than or equal to the decimal conversion rate:
sharedDecimals and localDecimals work together to enforce minimum transfer amounts, see the OFT Technical Reference.
Insufficient Balance
Error:114000000000000 (current balance) < 100000000000000000000000 (requested amount).
Solution: Check both native token (for fees) and token balances:
Network Not Supported
Error:Unsupported source chain: chainName
Solution: Ensure the chain is configured in your RPC_URLS mapping and supported by the API.
By using the OFT API, you agree to the OFT API Terms of Use.