Skip to main content
A developer guide to using the LayerZero OFT Transfer API to simply orchestrate OFT transfers between chains.

Overview

The LayerZero OFT Transfer API provides a simple way to fetch the calldata necessary to call the send 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

Installation

Environment Setup

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 across
  • symbols (optional, string): Comma-separated list of token symbols to filter by
Common Usage Patterns:
Response Structure:
Key Response Fields:
  • name: Token display name
  • sharedDecimals: Number of decimals used across all chains for LayerZero transfers
  • endpointVersion: LayerZero endpoint version (β€œv2”)
  • deployments: Object with chain names as keys, containing deployment details for each chain
  • address: The OFT contract address on that specific chain (Program ID for Solana)
  • localDecimals: Number of decimals the token uses on that specific chain
  • type: 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 of sharedDecimals and localDecimals concepts, including the decimal conversion process and overflow considerations, see the OFT Technical Reference.
Using the Response:

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:
Parameters:
  • 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 ID
  • amount (string): Transfer amount in token’s smallest unit
  • from (string): Sender wallet address (public key for Solana)
  • to (string): Recipient wallet address on destination chain
  • validate (boolean): Pre-validate balances and parameters
  • options (string, optional): Structured LayerZero execution options as JSON string
Complete Example Workflow:
Response Structure:
Key Response Fields:
  • populatedTransaction: The main transfer transaction ready to be sent via wallet.sendTransaction()
  • approvalTransaction: Token approval transaction (if required for OFT adapters)
  • Both transactions contain pre-built calldata and gas estimates
Executing the Transactions:

(Optional) Add extraOptions

For advanced use cases, you can include LayerZero execution options to extend the base OFT functionality. The options parameter allows you to specify additional gas limits, native token drops, and compose message settings. Example with extraOptions:
How extraOptions work:
  • lzReceive gas 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: Usage Tips:
  • Import Chain constants to avoid typos and get autocomplete
  • Use /list API without chain filters to discover all supported chains
  • If you see a chain missing, make sure your @layerzerolabs/lz-definitions package is updated to the latest version
  • Check the LayerZero API reference for the complete list of supported chains

Complete Transfer Examples

Example: Send $PENGU from BSC to Abstract

Expected Output

After running the EVM example, you should see:

Common Issues & Solutions

Amount Validation Errors

Error:
Cause: This error occurs due to the decimal conversion rate between 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:
For detailed explanation of how sharedDecimals and localDecimals work together to enforce minimum transfer amounts, see the OFT Technical Reference.

Insufficient Balance

Error:
Cause: This error occurs when the API validates that your wallet doesn’t have enough OFT tokens to perform the requested transfer. The error message shows your current balance vs. the requested transfer amount (both in the token’s smallest unit). In this example: 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.