Prerequisites

  • A Spark wallet created following the Create First Wallet guide
  • Some Bitcoin (BTC) in a Bitcoin wallet

Generate a Deposit Address

To deposit Bitcoin into your Spark wallet, you’ll first need to generate a deposit address. Once you have a deposit address, you can send Bitcoin to it. And once the broadcasted transaction is confirmed, you can complete the deposit by calling getBalance(). Get Balance will claim the deposit into Spark and display the updated balance. For Layer 1 Bitcoin deposits, Spark generates Pay to Taproot (P2TR) addresses. These addresses start with “bc1p” for mainnet and “bcrt1p” for regtest and can be used to receive Bitcoin from any wallet.

Mainnet Address Example: bc1p5d7rjq7g6rdk2yhzks9smtbqtedr4dekq08ge8ztwac72sfr9rusxg3297

Regtest Address Example: bcrt1pz0sg3yd9r7gwhax2gn2dr8gk2jj0f5n59c8kx5mkxknmh2lm9y6q2yskt4

Code Sample:

const depositAddress = await wallet.getDepositAddress();
console.log("Deposit Address:", depositAddress);

Faucet funds on Regtest

Once you have the deposit address, you can use the below link to get funds for your Spark wallet.

https://regtest-mempool.dev.dev.sparkinfra.net/faucet

  • Username: hackathon
  • Password: MakeBitcoinMoneyAgain

Watch for the deposit transaction

After sending Bitcoin to the deposit address, you can watch the mempool for the transaction to be confirmed. Once confirmed, you can run getBalance() with the forceRefetch option to claim the deposit.

const balance = await wallet.getBalance(true /* force refetch */);
console.log(`Balance:`, balance);

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:
    • balance: A bigint representing the token amount

Confirmation Requirements

  • Deposits require 3 confirmations on L1
  • Once you’re deposit is final you’ll receive BTC on Spark
  • Funds will be available in your Spark wallet after confirmation

Best Practices

  • Start with a small test amount for your first deposit
  • Keep track of your deposit transaction IDs
  • Wait for the required confirmations before considering the deposit complete

Next Steps

Once your deposit is confirmed, you can:

Need Help?