Overview
Solana deposits are straightforward because the Layerswap API returns a fully constructed, serialized transaction incall_data. You only need to decode it, set a fresh blockhash, sign it, and send it.
Prerequisites:
- @solana/web3.js for transaction handling and RPC communication
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
TheServer-side tab signs locally with a Keypair. The Browser tab uses a connected wallet adapter (Phantom, Solflare, etc.) and its signTransaction method.