The sBTC protocol operates across multiple layers:
Bitcoin: The original funds are sourced from Bitcoin. A depositor sends these funds to a group of signers, which manage a (rotating) multisignature address formatted for sBTC transactions.
sBTC API (Emily): This API is responsible for tracking deposits and notifying the signers about pending deposits.
Stacks: The network where sBTC is minted. Once the deposit is confirmed, the signers mint the corresponding amount of sBTC to the depositor's specified address on the Stacks network.
Structure a Bitcoin transaction to send funds to the group of signers.
Use a specialized format that includes:
Deposit Script: Identifies which Stacks address the sBTC will be minted to and what the maximum fee (in satoshis) the signers may take in exchange for minting.
Reclaim Script: Allows the sender to reclaim their funds if the transaction is not processed by the signers.
Sign and Broadcast the Transaction:
Sign the transaction with the sender's private key.
Broadcast the transaction to the Bitcoin network (Bitcoin Regtest for Stacks Testnet).
Notify the sBTC API (Emily):
Inform the API about the transaction by submitting its details. This step ensures that the signers are aware of the deposit and can track it.
Processing by Signers: (no action required)
The signers retrieve and verify the deposit transaction from the Bitcoin blockchain.
Once verified, the signers mint the equivalent amount of sBTC on the Stacks network.
Receive sBTC (Stacks): (no action required)
The minted sBTC is sent to the depositor's designated Stacks address, completing the deposit process.
sBTC is SIP-010 compatible and will show up in Stacks wallets and explorers.
The buildSbtcDepositTx function is similar to buildSbtcDepositAddress, but instead of returning just a deposit address, it constructs a complete Bitcoin transaction for depositing sBTC.
import{ buildSbtcDepositTx }from'sbtc';
// 1. BUILD THE DEPOSIT TRANSACTION AND METADATA
constdeposit=buildSbtcDepositTx({
amountSats:DEPOSIT_AMOUNT,// the amount in sats/sBTC to deposit; <=maxSignerFee is taken from this amount
// same options as `buildSbtcDepositAddress`
network,
stacksAddress,
signersPublicKey,
maxSignerFee,
reclaimLockTime,
});
// `deposit.transaction` has one output, which is the combined taproot of the deposit and reclaim scripts
Additionally, there are two API helpers, which make it easier to get all the data needed to create the above transactions:
SbtcApiClientMainnet — a client for communicating with the different pieces of the sBTC deployment
SbtcApiClientTestnet — a client for communicating with the different pieces of the sBTC deployment on Testnet
SbtcApiClientDevenv — a client for developing against a local deployment of sBTC
While the final adjustments are still being made in the pre-release phase, this package may change default URLs and contract addresses on every minor release.