Deposit from Bitcoin
Learn how to deposit Bitcoin into your Spark wallet
Generate a Deposit Address
To deposit Bitcoin into your Spark wallet from L1, you’ll first need to generate a deposit address. Once you have a deposit address, you can send Bitcoin to it. As deposited funds are mapped to the Spark statechain, Spark deposit address can only be used a single time.
Once the transaction is confirmed, you can claim the deposit by calling claimDeposit(txId)
. Once claimed you can call getBalance()
to view the updated balance. For Layer 1 Bitcoin deposits, Spark generates Pay to Taproot (P2TR) addresses. These addresses start with “bc1p” for mainnet and can be used to receive Bitcoin from any wallet.
Mainnet Address Example:
bc1p5d7rjq7g6rdk2yhzks9smtbqtedr4dekq08ge8ztwac72sfr9rusxg3297
Code Sample:
Watch for the deposit transaction
After sending Bitcoin to the deposit address, you can watch the mempool for the transaction to be confirmed.
use below utility function to poll the mempool for the transaction to be confirmed.
Once confirmed, you can run claimDeposit(txId)
to claim the deposit and view the balance.
The getBalance()
method returns a Promise resolving to an object containing:
balance
: Abigint
representing the total amount in satoshistokenBalances
: A Map of token balances, where each entry contains:balance
: Abigint
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?
- Check our FAQ
- Review the API Reference
- Follow our Testing Guide
- Check our Code Samples