Spark is a Bitcoin scaling solution that enables instant, low-cost transfers while maintaining Bitcoin’s security. Privy offers BTC support This guide walks through creating a Spark wallet, transferring BTC, and claiming pending transfers using Privy’s API. Privy’s Spark integration utilizes the Spark Wallet SDK. For more information on the Spark wallet methods, check out the Spark docs.

1. Create a Spark wallet

Create a Spark wallet by calling the wallet creation endpoint with chain_type: 'spark'. Learn more about creating wallets here.
import {useCreateWallet} from '@privy-io/react-auth/extended-chains';

const {createWallet} = useCreateWallet();

const {user, wallet} = await createWallet({chainType: 'spark'});
The response will include your new Spark wallet with a unique Spark address format (e.g., sprt1pgss...).
Spark supports both mainnet and testnet environments:
  • MAINNET: Production Bitcoin network
  • REGTEST: Test network for development
When you create a wallet, the MAINNET address is automatically returned. To get the REGTEST address, you can use the returned public key and the encodeSparkAddress method from the Spark SDK.On subsequent wallet requests, your request will need to include the network you want to take the operation on.

2. Transfer BTC

Transfer Bitcoin to another Spark address using the transfer endpoint. The amount is specified in satoshis.
Most Spark wallet operations (transferring BTC and checking balances) require authorization signatures using user keys. Only wallet creation can be done without authorization signatures. Learn more about signing requests with user keys.
import {useAuthorizationSignature} from '@privy-io/react-auth';

const {generateAuthorizationSignature} = useAuthorizationSignature();

// Build the request input for authorization signature
const input = {
  version: 1,
  url: `https://api.privy.io/v1/wallets/${walletId}/rpc`,
  method: 'POST',
  headers: {
    'privy-app-id': 'your-app-id'
  },
  body: {
    method: 'transfer',
    network: 'MAINNET',
    params: {
      receiver_spark_address: 'sprt1pgss8z35rpycv4duqdk5u3sclhjnztjunv5yajlwk69tyv5fsvwwe9mg8n4d49',
      amount_sats: 16
    }
  }
} as const;

// Generate authorization signature
const authorizationSignature = await generateAuthorizationSignature({input});

// Make the transfer request
const transferResponse = await fetch(input.url, {
  method: input.method,
  headers: {
    ...input.headers,
    Authorization: `Bearer ${accessToken}`,
    'Content-Type': 'application/json',
    'privy-authorization-signature': authorizationSignature
  },
  body: JSON.stringify(input.body)
});

const transfer = await transferResponse.json();
The transfer response includes the transfer ID, status, and detailed transaction information.

3. Check balance and claim transfers

Use the getBalance endpoint to retrieve your wallet balance and automatically claim any pending transfers.
import {useAuthorizationSignature} from '@privy-io/react-auth';

const {generateAuthorizationSignature} = useAuthorizationSignature();

// Build the request input for authorization signature
const input = {
  version: 1,
  url: `https://api.privy.io/v1/wallets/${walletId}/rpc`,
  method: 'POST',
  headers: {
    'privy-app-id': 'your-app-id'
  },
  body: {
    method: 'getBalance',
    network: 'MAINNET'
  }
} as const;

// Generate authorization signature
const authorizationSignature = await generateAuthorizationSignature({input});

// Make the balance request
const balanceResponse = await fetch(input.url, {
  method: input.method,
  headers: {
    ...input.headers,
    Authorization: `Bearer ${accessToken}`,
    'Content-Type': 'application/json',
    'privy-authorization-signature': authorizationSignature
  },
  body: JSON.stringify(input.body)
});

const balance = await balanceResponse.json();
console.log(`Balance: ${balance.data.balance} satoshis`);
The balance response includes:
  • Your native Spark balance in satoshis
  • Any token balances with metadata
  • Automatically claims pending incoming transfers

4. Execute more wallet requests

This guide demonstrates how to use transfer and getBalance, but Privy supports many Spark wallet methods including: All methods (except wallet creation) require authorization signatures using the same pattern shown in the examples above. For additional Spark functionality and advanced features, see the Spark developer documentation.