Skip to main content
Send tokens to any Spark address with single or batch transfers.
Transfer Tokens

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);

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);
}