Skip to main content

Overview

Solana deposits are straightforward because the Layerswap API returns a fully constructed, serialized transaction in call_data. You only need to decode it, set a fresh blockhash, sign it, and send it. Prerequisites:

call_data Format

For Solana, call_data is a base64-encoded serialized Transaction. It contains all the instructions, accounts, and program IDs already set up by the Layerswap backend — including SPL token transfers when applicable.

Transaction Construction

1

Decode the transaction

Convert the base64 call_data string into a Transaction object.
2

Set a fresh blockhash

Fetch the latest blockhash from the Solana RPC and update the transaction. This ensures the transaction doesn’t expire before it’s confirmed.
3

Validate balances (optional)

Estimate the transaction fee and verify the sender has enough SOL for fees and enough of the source token for the transfer amount.
4

Sign the transaction

Sign the transaction with the sender’s keypair or wallet adapter.
5

Send and confirm

Submit the signed transaction to the network and wait for confirmation.

Full Example

The Server-side tab signs locally with a Keypair. The Browser tab uses a connected wallet adapter (Phantom, Solflare, etc.) and its signTransaction method.

Sending with Retry Logic

Solana transactions can sometimes fail to land due to network congestion. A robust implementation resends the transaction periodically until it’s confirmed or the blockhash expires:

Next Step

After the transaction is submitted, notify Layerswap so it can match your deposit faster:
See the full deposit flow for details.