Transfering tokens

Once you have the recipient’s Spark address (e.g. from user input) and the token identifier, you can transfer tokens. For now, only single-token transfers are supported. Sending multiple tokens (e.g. token_a, token_b, token_c) in one transaction isn’t yet possible
const transactionId = await wallet.transferTokens({
    tokenIdentifier: "btkn1qwertyuiopasdfghjklzxcvbnm1234567890abcdef",
    tokenAmount: 100000n,
    receiverSparkAddress: "sprt1pgssyuuuhnrrdjswal5c3s3rafw9w3y5dd4cjy3duxlf7hjzkp0rqx6dj6mrhu",
  });

console.log("Spark Transaction ID:", transactionId);

Receiving tokens

Receiving tokens on Spark requires no action. They show up as soon as they’re sent to your address. To check your balance:
const balance = await wallet.getBalance();
console.log(`Token balances:`, balance.tokenBalances);
This returns both your sats balance and a map of token balances keyed by token ID.