Documentation Index
Fetch the complete documentation index at: https://docs.spark.money/llms.txt
Use this file to discover all available pages before exploring further.
Send tokens to any Spark address with single or batch transfers.
Transfer Tokens
Send tokens to another Spark wallet using the token identifier and amount.
transferTokens(params)
Transfers tokens to another user on the Spark network.
const transferResult = await wallet.transferTokens({
tokenIdentifier: "btkn1p...", // Bech32m token identifier
tokenAmount: BigInt(1000), // Amount of tokens to transfer
receiverSparkAddress: "spark1p...", // Recipient's Spark address
});
console.log("Transfer successful:", transferResult);
The Bech32m token identifier (e.g., btkn1…) of the token to transfer
The amount of tokens to transfer
The recipient’s Spark address
outputSelectionStrategy
"SMALL_FIRST" | "LARGE_FIRST"
Strategy for selecting token outputs. SMALL_FIRST uses smallest outputs first, LARGE_FIRST uses largest.
selectedOutputs
OutputWithPreviousTransactionData[]
Optional: Specific outputs to use for the transfer. Overrides outputSelectionStrategy.
The transaction ID of the token transfer
Get Token Balances
Before transferring tokens, check what tokens you own and their balances using getBalance().
const { balance, tokenBalances } = await wallet.getBalance();
console.log("Sats balance:", balance);
// Iterate over token balances
for (const [tokenId, tokenData] of tokenBalances) {
console.log(`Token ${tokenId}:`);
console.log(" Owned balance:", tokenData.ownedBalance);
console.log(" Available to send:", tokenData.availableToSendBalance);
console.log(" Name:", tokenData.tokenMetadata.tokenName);
console.log(" Ticker:", tokenData.tokenMetadata.tokenTicker);
}
// Check balance of a specific token
const specificToken = tokenBalances.get("btkn1...");
if (specificToken) {
console.log("Token balance (owned):", specificToken.ownedBalance);
console.log("Token balance (available):", specificToken.availableToSendBalance);
}