> ## Documentation Index
> Fetch the complete documentation index at: https://docs.layerzero.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Interactive Solana Program Playground

> Test LayerZero Solana programs directly from your browser. Build and send instructions without writing code. Explore key program instructions for message...

Test LayerZero Solana programs directly from your browser. Build and send instructions without writing code. Explore key program instructions for message fee calculation, sending, receiving, and configuration management.

For production use, please use the official SDKs which provides proper type-safe instruction builders:

* [@layerzerolabs/lz-solana-sdk-v2](https://www.npmjs.com/package/@layerzerolabs/lz-solana-sdk-v2)
* [@layerzerolabs/oft-v2-solana-sdk](https://www.npmjs.com/package/@layerzerolabs/oft-v2-solana-sdk)

> [!TIP]
>
> ### Real Onchain Methods
>
> All instructions shown in this playground are **real methods** available in the LayerZero Solana programs today:
>
> * **Endpoint Program**: [Source Code](https://github.com/LayerZero-Labs/LayerZero-v2/tree/main/packages/layerzero-v2/solana/programs/programs/endpoint/src)
> * **OFT Program**: [Source Code](https://github.com/LayerZero-Labs/devtools/blob/main/examples/oft-solana/programs/oft/src)
>
> We only document OApp-relevant instructions, excluding admin-only functions. State variables are clearly marked as direct account data reads, not instructions.

## LayerZero EndpointV2

The main entry point for all crosschain messaging operations on Solana. This program handles message routing, fee calculation, and configuration management.

### Message Routing

Core functions for sending and receiving messages between smart contracts.

#### quote() - Get Fee Estimates

Get a quote for the LayerZero messaging fees required to send a crosschain message from Solana. Returns the native fee and lzToken fee required.

#### send() - Send Messages

Send a crosschain message from Solana to another blockchain. Returns a MessagingReceipt with guid, nonce, and fee information.

#### clear() - Clear Payload

Clear a nilified message payload and recover the rent. Returns the original payload hash.

> [!NOTE]
>
> ### Why is clear() under Message Routing instead of Message Recovery?
>
> On Solana, the `clear()` instruction placement differs from EVM:
>
> * **EVM**: The Endpoint handles clearing payloads directly during message delivery
> * **Solana**: The OApp must explicitly call `clear()` via CPI in its `lzReceive` implementation
>
> This architectural difference means Solana developers need to implement the CPI call to `clear()` within their OApp's message handling logic, giving them more control over the message lifecycle but requiring explicit implementation. See the architectural note at the top of this page for the complete message flow.

#### sendCompose() - Send Compose Messages

Send a composed message for sequential execution after the primary message. Used for complex crosschain workflows.

#### clearCompose() - Clear Compose Message

Clear a compose message after it has been processed. This cleans up the compose message state.

> [!NOTE]
>
> ### Architectural Difference: lzReceive
>
> If you're looking for `lzReceive` or `lzCompose` instructions in the Endpoint (as you might expect from EVM), note that on Solana these are implemented directly in the OApp (e.g., OFT program) due to architectural differences.
>
> **On Solana:**
>
> * The executor calls `lzReceive` directly on the OApp/OFT program
> * The OApp then makes a CPI (Cross-Program Invocation) call to the Endpoint's `clear` instruction to validate and clear the payload
> * After validation, the OApp continues with its business logic (e.g., minting tokens)
>
> This is different from EVM where the Endpoint calls back to the OApp's `_lzReceive` function. On Solana, the flow is inverted with the OApp calling into the Endpoint.
>
> See the [OFT lzReceive implementation](https://github.com/LayerZero-Labs/devtools/blob/73f732acf683ca18b74cd6c6adb3d656d2e0f36a/examples/oft-solana/programs/oft/src/instructions/lz_receive.rs#L72-L94) for an example.

### Configuration Management

Functions for setting custom verification, execution, and pathway management.

#### registerOapp() - Register OApp

Register an OApp with the endpoint. This establishes the OApp's delegate who can manage configurations.

#### setDelegate() - Set Delegate Address

Set the delegate address that can configure settings on behalf of the OApp.

#### setSendLibrary() - Configure Send Library

Set the messaging library to use for sending messages to a specific destination.

#### setReceiveLibrary() - Configure Receive Library

Set the messaging library to use for receiving messages from a specific source.

#### setConfig() - Set Configuration Parameters

Set configuration for DVNs, executors, and other protocol parameters.

#### initNonce() - Initialize Nonce

Initialize nonce tracking for messages between OApps. Must be called before sending messages.

#### initVerify() - Initialize Verification

Initialize the payload hash account for message verification. Must be called before verify().

#### initSendLibrary() - Initialize Send Library

Initialize send library configuration for an OApp on a specific destination chain.

#### initReceiveLibrary() - Initialize Receive Library

Initialize receive library configuration for an OApp on a specific source chain.

#### initConfig() - Initialize Configuration

Initialize configuration accounts for message library settings (DVN, executor, etc).

#### setReceiveLibraryTimeout() - Set Library Timeout

Set a timeout for transitioning between receive libraries. Allows graceful library upgrades.

### Message Recovery & Security

Functions for handling message exceptions, security threats, and recovery scenarios.

#### burn() - Permanently Block Message

Permanently marks a message as unexecutable and un-verifiable. This irreversible action prevents the message from ever being executed.

#### skip() - Skip Inbound Nonce

Skip a specific inbound message nonce. This allows the OApp to continue processing subsequent messages if one is stuck or problematic.

#### nilify() - Mark Message as Nil

Mark a message payload as nil, allowing it to be cleared later. This is a two-step process for safely handling problematic messages.

#### withdrawRent() - Withdraw Rent

Admin function to withdraw accumulated rent from closed accounts.

### Status Checks

Functions for querying current configuration settings, library assignments, nonce tracking, and message states.

#### eid() - Get Endpoint ID

Reads the endpoint ID (EID) from the EndpointSettings account. Each blockchain in the LayerZero network has a unique endpoint ID.

#### endpointAdmin() - Get Endpoint Admin

Reads the admin address from the EndpointSettings account.

#### oappDelegate() - Get OApp Delegate

Reads the delegate address for an OApp from its registry entry.

#### outboundNonce() - Get Outbound Nonce

Reads the current outbound nonce for messages to a specific destination.

#### inboundNonce() - Get Inbound Nonce

Reads the current inbound nonce for messages from a specific source.

## Omnichain Fungible Token (OFT)

Omnichain Fungible Token (OFT) enables seamless crosschain token transfers. Deploy once and bridge your SPL tokens to any supported blockchain.

Since Solana uses a rent-based storage model rather than EVM's gas-per-bytecode deployment costs, and has no restrictive contract size limits (like EVM's 24KB limit), we can include all of these extensions in the same program. While some OFT instances may not utilize all features (like fees or rate limits), having them built-in provides maximum flexibility without the contract splitting requirements common in EVM development.

> [!NOTE]
>
> ### Default OFT Program
>
> For Solana Mainnet, we use **PENGU OFT** as the default example:
>
> * **Program**: `EfRMrTJWU2CYm52kHmRYozQNdF8RH5aTi3xyeSuLAX2Y`
> * **OFT Store**: `qMNo1RFo11J9ZLGuq7dVmWAssuCZaNsSamk8g2q4UZA`
>
> You can replace these with your own OFT deployment addresses.

> [!NOTE]
>
> ### lzReceive Implementation
>
> The `lzReceive` instruction is implemented here in the OFT program (not in the Endpoint). This is a key architectural difference from EVM:
>
> * On Solana, executors call `lzReceive` directly on the OApp/OFT
> * The OFT program then makes a CPI call to the Endpoint's `clear` instruction to validate the message
> * After successful validation, the OFT continues with its logic (minting tokens, updating balances, etc.)
>
> The flow is: Executor → OFT.lzReceive → Endpoint.clear (via CPI) → Continue OFT logic

### Send Tokens

#### quoteSend() - Get Transfer Fees

Get messaging fees for sending tokens crosschain. Returns native fee and lzToken fee.

#### quoteOft() - Get Detailed Transfer Quote

Get a detailed quote for crosschain token transfer including fees, limits, and expected amounts.

#### send() - Transfer Tokens

Send SPL tokens from Solana to another blockchain. The tokens will be locked on Solana and minted on the destination chain.

#### lzReceiveTypes() - Get Receive Account Types

Get the required account types for lzReceive instruction. Returns array of account metadata. This is a Solana-specific helper for dynamic account resolution.

#### lzReceive() - Receive Tokens

Receive tokens from another blockchain. This instruction is called by the executor to deliver tokens to the recipient on Solana.

### Token Details

The **OFT Store** account is a [Program Derived Address (PDA)](https://solana.com/docs/core/pda), not the token mint itself. This account stores essential OFT related state variables.

#### oftAdmin() - Get OFT Admin

Reads the admin address from the OFT store account. The admin can configure settings and pause/unpause the OFT.

#### tokenMint() - Get Token Mint

Reads the SPL token mint address from the OFT store account. Note: The OFT store is NOT the token mint address itself, but a separate PDA account created by the OFT program.

#### tokenEscrow() - Get Token Escrow

Reads the token escrow account address from the OFT store account. This is where locked tokens are held.

#### sharedDecimals() - Get Shared Decimals

Reads the shared decimal precision from the OFT store account. This is typically 6 or 8 decimals to ensure compatibility across different chains. Note: This reads directly from account data at the correct offset.

#### decimalConversionRate() - Get Decimal Conversion Rate

Reads the ld2sdRate (local decimals to shared decimals rate) from the OFT store account. This is 10^(localDecimals - sharedDecimals). Note: This reads directly from offset 9 in the OFTStore account data.

#### oftVersion() - Get OFT Version

Returns the OFT implementation version as a Version struct with interface version (2) and message version (1).

#### tvlLd() - Get Total Value Locked

Reads the total value locked in local decimals from the OFT store account. This represents the total amount of tokens currently locked in the OFT.

#### isPaused() - Check Pause State

Checks if the OFT is currently paused. This is an optional feature - many OFTs operate without pause functionality. When enabled and paused, no transfers can be initiated.

#### defaultFeeBps() - Get Default Fee

Reads the default fee in basis points (bps) from the OFT store account. This is an optional feature - many OFTs operate with zero fees. When enabled, 100 bps = 1%.

### Peer Configuration

These functions read peer-specific configuration from PeerConfig accounts:

#### peerAddress() - Get Peer Address

Get the peer address for a specific destination chain (32 bytes)

#### enforcedOptions() - Check Enforced Options

Check enforced LayerZero message options for this peer

#### peerFeeBps() - Get Peer Fee

Get the peer-specific fee in basis points. This is an optional feature that allows different fees for different destination chains. Returns 'None' if no peer-specific fee is set.

#### outboundRateLimiter() - Check Outbound Rate Limiter

Check if outbound rate limiter is configured for this peer. This is an optional feature for controlling token flow rates. Most OFTs operate without rate limits.

#### inboundRateLimiter() - Check Inbound Rate Limiter

Check if inbound rate limiter is configured for this peer. This is an optional feature for controlling token flow rates. Most OFTs operate without rate limits.

> [!TIP]
>
> ### Finding PeerConfig Account
>
> The PeerConfig account is a PDA (Program Derived Address) derived from:
>
> * OFT program ID
> * Seeds: `[b"peer_config", oft_store.key().as_ref(), &dst_eid.to_be_bytes()]`
>
> You'll need to derive this address using the OFT store account and the destination chain's endpoint ID.

### Management Functions

#### initOft() - Initialize OFT

Initialize a new Omnichain Fungible Token. This sets up an SPL token to be transferable across multiple blockchains.

#### setPeerConfig() - Configure Remote Peer

Configure the connection to an OFT on another chain. This can set the peer address (required), and optionally configure peer-specific fees, enforced options, and rate limits. Many OFTs only set the peer address without using the optional features.

#### setOftConfig() - Update OFT Settings

Update various OFT configuration settings. Admin changes are common, while features like fees (DefaultFee) and pausability (Paused, Pauser, Unpauser) are optional and not used by all OFTs.

#### setPause() - Pause/Unpause OFT

Pause or unpause the OFT. This is an optional feature - many OFTs operate without pause functionality. When enabled and paused, no transfers can be initiated. Only the designated pauser (to pause) or unpauser (to unpause) can call this.

#### withdrawFee() - Withdraw Collected Fees

Withdraw collected fees from the OFT. This is an optional feature - many OFTs operate with zero fees and never use this function. When fees are enabled, only the admin can withdraw them.

## Events and Errors

### Endpoint Events

Key events emitted by the Endpoint program during crosschain operations.

#### PacketSentEvent - Message Sent

Emitted when a packet is sent through the endpoint. Contains the encoded packet data and execution options for tracking crosschain messages.

#### PacketVerifiedEvent - Message Verified

Emitted when an inbound message has been verified by the DVNs and is ready for execution. Indicates the message passed all security checks.

#### PacketDeliveredEvent - Message Delivered

Emitted when a message is successfully delivered to the destination OApp. This confirms the crosschain transaction completed.

#### ComposeSentEvent - Compose Message Queued

Emitted when a compose message is queued for sequential execution after the primary message. Used for complex multi-step operations.

#### ComposeDeliveredEvent - Compose Message Executed

Emitted when a compose message is successfully executed. Indicates the secondary operation completed successfully.

#### DelegateSetEvent - Delegate Updated

Emitted when an OApp delegate is set or changed. The delegate can configure settings on behalf of the OApp.

#### SendLibrarySetEvent - Send Library Configured

Emitted when the send library is configured for a specific destination. Tracks library changes for outbound messages.

#### ReceiveLibrarySetEvent - Receive Library Configured

Emitted when the receive library is configured for a specific source. Tracks library changes for inbound messages.

#### OAppRegisteredEvent - OApp Registration

Emitted when a new OApp is registered with the endpoint. This establishes the OApp's ability to send and receive messages.

### Endpoint Errors

Common errors returned by the Endpoint program.

#### Unauthorized - Permission Denied

Thrown when the caller lacks required permissions for the operation. Only authorized addresses can perform certain actions.

#### InvalidNonce - Nonce Mismatch

Thrown when processing a message with an invalid nonce. Ensures messages are processed in the correct sequential order.

#### InvalidSender - Unauthorized Sender

Thrown when receiving a message from an unauthorized sender. Only configured peers can send messages to the OApp.

#### InvalidReceiver - Invalid Destination

Thrown when the specified receiver address is invalid or not configured properly for the destination chain.

#### LzTokenUnavailable - LayerZero Token Error

Thrown when LayerZero token operations fail or tokens are unavailable for fee payment.

### OFT Events

Key events emitted by the OFT program during token operations. ([Source](https://github.com/LayerZero-Labs/devtools/blob/main/examples/oft-solana/programs/oft/src/events.rs))

#### OFTSent - Tokens Sent Crosschain

Emitted when tokens are sent to another chain. Contains the message GUID, destination chain ID, sender and recipient addresses, and the amount sent in both shared and local decimals.

#### OFTReceived - Tokens Received

Emitted when tokens are received from another chain. Contains the source chain ID, sender address, and the amount received after decimal conversion.

### OFT Errors

Common errors returned by the OFT program. ([Source](https://github.com/LayerZero-Labs/devtools/blob/main/examples/oft-solana/programs/oft/src/errors.rs))

#### Paused - OFT Operations Paused

Thrown when attempting operations while the OFT is paused. No transfers can be initiated until unpaused by the designated unpauser.

#### SlippageExceeded - Insufficient Received Amount

Thrown when the received amount after crosschain transfer falls below the minimum acceptable amount due to decimal conversions or fees.

#### RateLimitExceeded - Transfer Rate Limit Hit

Thrown when a transfer exceeds the configured rate limits for the peer connection. Wait for the rate limit window to reset.

#### InvalidOptions - Invalid Message Options

Thrown when the provided LayerZero message options are invalid or incompatible with the OFT configuration.

#### InvalidAmount - Invalid Transfer Amount

Thrown when the transfer amount is zero, exceeds limits, or is otherwise invalid for the operation.

#### InvalidPeer - Peer Not Configured

Thrown when attempting to interact with a destination chain where no peer OFT has been configured. Use setPeerConfig() first.

## Usage Tips

### Getting Started

1. **Connect Your Wallet**: Click "Connect Phantom Wallet" to connect your Solana wallet
2. **Select Network**: Choose between Solana Mainnet and Devnet
3. **Custom RPC (Optional)**: If you encounter rate limits (403 errors), add a custom RPC URL:
   * [Helius](https://helius.dev) - Generous free tier
   * [QuickNode](https://quicknode.com) - Free tier available
   * [Alchemy](https://alchemy.com) - Professional services

### Common Workflows

#### Sending Tokens Crosschain (OFT)

1. Initialize your OFT with `initOft()`
2. Configure peers with `setPeerConfig()`
3. Get a quote with `quoteOft()` or `quoteSend()`
4. Send tokens with `send()`

#### Setting Up Messaging (Endpoint)

1. Register your OApp with `registerOapp()`
2. Initialize nonce tracking with `initNonce()`
3. Set up libraries with `initSendLibrary()` and `initReceiveLibrary()`
4. Configure DVNs/executors with `setConfig()`
5. Get quotes with `quote()` and send messages with `send()`

### Troubleshooting

* **403 Errors**: Use a custom RPC URL instead of public endpoints
* **"Account does not exist"**: Ensure all required accounts have been initialized
* **"Invalid arguments"**: Check that byte arrays are properly formatted (0x prefix)
* **Simulation failures**: This playground uses simplified encoding - use official SDKs for production

For production applications, always use the official LayerZero SDKs which provide proper type safety and encoding.
