Skip to Content
Provider

SbtcProvider

The root provider. It auto-detects the platform adapter, resolves API endpoints (defaults merged with your overrides), and supplies the context every hook reads. Mount it once, near the top of your tree.

import { SbtcProvider } from '@baoku26/sbtc-sdk'; <SbtcProvider network="testnet"> <App /> </SbtcProvider>;

Props

PropTypeRequiredDescription
network'mainnet' | 'testnet'yesNetwork all hooks target.
adapterPlatformAdapternoOverrides auto-detection — e.g. a custom HSM / hardware-wallet adapter. See Platform Adapters.
apiConfigPartial<NetworkConfig>noOverrides the default Hiro / Emily / Bitcoin endpoints and sBTC contract ids.
childrenReactNodeyesYour app.

apiConfig overrides

apiConfig is a partial of NetworkConfig; any field you omit falls back to the network default.

FieldDescription
hiroApiUrlStacks (Hiro) API base URL.
emilyApiUrlEmily (sBTC bridge) API base URL.
bitcoinApiUrlBitcoin API base URL (mempool.space-compatible).
sbtcTokenAssetIdSIP-010 asset id "<contract>::<asset>" for reading the sBTC balance.
sbtcWithdrawalContract"<address>.sbtc-withdrawal" for initiate-withdrawal-request.
sbtcContractAddresssBTC deployer principal (the address under which sbtc-registry / sbtc-deposit live). Used by the deposit flow.

Defaults

MainnetTestnet
hiroApiUrlhttps://api.hiro.sohttps://api.testnet.hiro.so
emilyApiUrlhttps://sbtc-emily.comhttps://beta.sbtc-emily.com
bitcoinApiUrlhttps://mempool.space/apihttps://mempool.space/testnet/api

Testnet contract churn. sBTC testnet deployments change over time. If deposits fail with a NoSuchContract/EMILY_API_ERROR, point sbtcContractAddress (and sbtcWithdrawalContract / sbtcTokenAssetId as needed) at the live testnet deployment you’re targeting. Mainnet defaults are stable.

<SbtcProvider network="testnet" apiConfig={{ sbtcContractAddress: 'ST1F7QA2MDF17S807EPA36TSS8AMEFY4KA9TVGWXT', }} > <App /> </SbtcProvider>

All endpoints must be HTTPS — an HTTP endpoint throws NETWORK_SECURITY_ERROR (see Security).

Reading the context

Most apps only use the hooks, but you can read the resolved context directly:

import { useSbtcContext } from '@baoku26/sbtc-sdk'; const { network, adapter, apiConfig } = useSbtcContext();

Native polyfill guard

On native, if SbtcProvider mounts before @baoku26/sbtc-sdk/polyfills was imported (so global.Buffer is missing), it throws POLYFILL_NOT_INITIALIZED. Import the polyfills as the first line of your entry file — see Polyfills.

SSR

During server-side rendering the no-op SsrAdapter is selected and hooks return their loading/empty state without touching storage, auth, or the network. No configuration required.

Last updated on