buildSolanaTransaction
Builds a Solana transaction for token transfers, handling both native SOL and SPL tokens with required program instructions.
Function Signature
Parameters
chainId
: The chain identifier in CAIP-2 format (e.g., "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" for Solana mainnet)params
: ABuildTransactionParam
object containing:to
: Recipient's Solana addresstoken
: Token identifier ("SOL" for native transfers, mint address for SPL tokens)amount
: Amount to transfer as a string (in lamports for SOL, raw amount for SPL tokens)
Returns
A BuildSolanaTransactionResponse
containing:
transaction
: The serialized transaction string ready for signingmetadata
: ABuildTransactionMetaData
object containing:amount
: Formatted transaction amountfromAddress
: Sender's addresstoAddress
: Recipient's addresstokenAddress
: Optional token mint address for SPL tokenstokenDecimals
: Number of decimal places for the tokentokenSymbol
: Optional token symbolrawAmount
: Raw transaction amount value
error
: Optional error message if the build process encounters issues
Example Usage
Native SOL Transfer:
SPL Token Transfer:
Implementation Notes
Amount Formatting
For native SOL:
For SPL tokens:
Token Identifiers
Address Validation
Solana addresses must be Base58 encoded
Must be between 32 and 44 characters in length
Example validation:
Error Handling
Related Documentation
For more information about Solana transaction building, see:
Last updated
Was this helpful?