Prerequisites
- Node.js 18+
- An API key from LayerZero
- A funded Solana wallet with the token you want to transfer
Installation
- pnpm
- npm
- yarn
Environment setup
Create a.env file in your project root:
1
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
2
Get quotes
Request a quote for your cross-chain transfer. The API returns available routes with fees, estimated duration, and quote ID.Quote response structure:
- TypeScript
3
Build and execute user steps
Call User steps response:
/build-user-steps to get the transaction for the chosen quote, then sign and submit it.Build user steps
Solana transactions have short blockhash validity, so you must generate transaction data immediately before signing:- TypeScript
Execute the transaction
Deserialize, sign, and submit the transaction using Solana Web3.js:- TypeScript
Every chain uses build-user-steps: All routes get
userSteps from /build-user-steps, EVM included. On Solana, sign and submit immediately after the build, because the blockhash expires after approximately 60 seconds. If the transaction expires, request a new quote. A second call with the same quoteId returns the same transaction.4
Track transfer status
Poll the status endpoint until the transfer completes. The API returns the current status and explorer link.Status values:
- TypeScript
Complete example
Key differences from EVM
Next steps
- EVM Example — Transfer tokens between EVM chains
- API Reference — Explore all endpoints