Skip to main content
This example demonstrates a complete cross-chain transfer from Solana to Arbitrum using TypeScript and the Solana Web3.js library.

Prerequisites

  • Node.js 18+
  • An API key from LayerZero
  • A funded Solana wallet with the token you want to transfer

Installation

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:
Why validate first? Validating the transfer path before requesting quotes prevents unnecessary API calls and provides immediate feedback if a route doesn’t exist.
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:
3

Build and execute user steps

Call /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:
User steps response:

Execute the transaction

Deserialize, sign, and submit the transaction using Solana Web3.js:
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:

Complete example

Key differences from EVM

Next steps