Prerequisites

  • A funded Spark wallet
  • A Bitcoin address to receive funds
  • Understanding of Bitcoin transaction fees

Withdraw

Understanding Cooperative Exits

A cooperative exit involves coordination between your wallet and the SSP to process your withdrawal efficiently. This is the preferred method because:

  • Lower fees than unilateral exits
  • It’s faster
  • No timelocks

Initiating the Withdraw

const withdraw_result = await wallet.withdraw({
  onchainAddress:
    "bcrt1pf8hed85p94emupfpfhq2g0p5c40cgzqs4agvvfmeuy32nxeh549syu2lwf",
  targetAmountSats: 17000,
});
console.log("Withdraw Result:", withdraw_result);

Fee Considerations

  • Network fees are required for the Bitcoin transaction and they will be deducted from the targetAmountSats
  • The total cost will include:
    • Bitcoin network fee
    • Spark service fee (if applicable, charged by the SSP)
    • Example: If you are setting targetAmountSats to 10,000 sats, the bitcoin fees are 2000 sats, and the SSP fees are 1000 sats, you will receive 7000 sats at your L1 address.

Best Practices

  • Keep your withdrawal address secure
  • Verify the withdrawal address before confirming
  • Keep track of your exit transaction ID
  • Wait for sufficient confirmations

Common Issues

  • Network congestion delays
  • Address format issues
  • Insufficient balance for fees

Next Steps

If cooperative exit isn’t possible, you can:

  • Try a unilateral exit (coming soon)
  • Review the API Reference for advanced options

Need Help?