Prerequisites
- Node.js 18+
- An API key from LayerZero
- A funded wallet on Base (source chain)
Installation
- pnpm
- npm
- yarn
Environment setup
Create a.env file in your project root:
Validate transfer path
Before requesting a quote, verify that the destination token is reachable from your source token.Query the tokens endpoint with filters to check if your destination exists in the list of transferrable tokens:
- TypeScript (viem)
Get quotes
Request a quote for your cross-chain transfer. The API returns available routes with fees, estimated duration, and the steps needed to execute.Quote response structure:For native token transfers (like ETH), the response contains a single bridge step. For ERC20 transfers (like USDC), the response contains two steps — an approve followed by a bridge. See Executing userSteps safely for details on the two-step flow.
- TypeScript (viem)
Execute user steps
Process each user step in the quote. The quote contains an array of steps—execute them in order.
Never approve the LZMulticall (Wrapper) as a token spenderLZMulticall executes bridge transactions. It is not the right spender, and approving it will lose you tokens. The correct spender is the TransferDelegate, and the API’s approve step already has this set in the calldata. Execute every
userStep as returned.See Contracts Overview for details on the contract architecture.- TypeScript (viem)
Step types: Most EVM routes use
TRANSACTION steps. Intent-based routes (like Aori) may include SIGNATURE steps for EIP-712 signed messages.Track transfer status
Poll the status endpoint until the transfer completes. The API returns the current status and explorer link.Status values:
- TypeScript (viem)
| Status | Description |
|---|---|
PENDING | Transfer initiated, waiting for confirmation |
PROCESSING | Transfer in progress across chains |
SUCCEEDED | Transfer completed successfully |
FAILED | Transfer failed |
UNKNOWN | Status cannot be determined |
Complete example
Next steps
- Solana Example — Transfer tokens from Solana
- API Reference — Explore all endpoints