Prerequisites

  • A funded Spark wallet
  • The recipient’s Spark Address or identifier
  • Basic understanding of Spark network operations

Receiving Spark Payments

To receive a payment, you’ll need to share your Spark Address. For Spark ↔ Spark transfers, we use Spark Addresses. The Spark Address format is similar to the usual Bitcoin address format:

Address Example: sp1pgssyuuuhnrrdjswal5c3s3rafw9w3y5dd4cjy3duxlf7hjzkp0rqx6dj6mrhu

Checkout Spark Addresses for more details.

Code Sample:

const sparkAddress = await wallet.getSparkAddress();
console.log("Spark Address:", sparkAddress);

Sending Spark Payments

Send Bitcoin payments to other Spark users:

const transfer = await wallet.transfer({
  receiverSparkAddress:
    "sp1pgssyuuuhnrrdjswal5c3s3rafw9w3y5dd4cjy3duxlf7hjzkp0rqx6dj6mrhu",
  amountSats: 100,
});

console.log("Transfer:", transfer);

Using a Spark Wallet you can also send and receive Tokens to other Spark users:

 const transfer = await wallet.transferTokens({
        tokenPublicKey: "0226ec76414bcf3f87e37882912a595f1d6701b609b97d0ed464284b418a395dba",
        tokenAmount: 100n,
        receiverSparkAddress: "sp1pgssyuuuhnrrdjswal5c3s3rafw9w3y5dd4cjy3duxlf7hjzkp0rqx6dj6mrhu"
  });

console.log("Transfer:", transfer);

Receiving Spark Payments

Run claimTransfers() to claim all transfers, or claimTransfer(transfer) for specific transfer. and then run getBalance() to view the balance. Checkout claim-transfers for more details.

const claimed = await wallet.claimTransfers();
console.log("Transfers claimed:", claimed);

// Check updated balance
const balance = await wallet.getBalance();
console.log("New balance:", balance);

If you want to claim a specific transfer:

const pendingTransfers = await wallet.getPendingTransfers();
if (pendingTransfers.length > 0) {
    const transfer = pendingTransfers[0];
    await wallet.claimTransfer(transfer);
    console.log("Transfer claimed successfully");
}

The getBalance() method returns a Promise resolving to an object containing:

  • balance: A bigint representing the total amount in satoshis
  • tokenBalances: A Map of token balances, where each entry contains:
    • The public key of the token
    • An object with bigint representing the token amount

Features and Benefits

  • Instant settlements
  • Lower fees compared to on-chain transactions
  • Standard pubkey addressing system

Next Steps

After mastering Spark payments, you can:

Need Help?