API Reference
Complete API reference for the Privacy Boost React SDK.Generated Documentation
Full API documentation can be generated using TypeDoc:- All hook signatures and return types
- JSDoc comments with usage examples
- Type definitions and interfaces
Provider
PrivacyBoostProvider
Main provider component that initializes the SDK.
Context Hooks
usePrivacyBoost()
Get direct access to the SDK instance.
usePrivacyBoostState()
Get provider initialization state.
useAuth
Authentication hook.useVault
Vault operations hook.useFees
Reactive ordinary or Gateway-specific fee quotes.tokenAddress, the hook calls the ordinary getFees API. Supplying
gatewayAddress switches to getGatewayFees; add gatewaySelector for an
exact selector override. A selector without an address is rejected. For a
Gateway quote, calculateFee(..., 'gateway') and formatFeeRate('gateway')
use the Gateway rate that replaces the ordinary unshield fee.
useBalances
Reactive balance data hook.useTransactions
Transaction history hook.useChain
Get a chain-scoped client for multi-chain operations.ChainClient exposes the same vault, transactions, audit, and campaigns resources as the root SDK, scoped to the target chain. Authentication is a method rather than a resource — call chain.authenticate(walletBridge). Returns null until the provider has finished initializing. The hook memoizes by serverUrl, so changing other fields between renders is ignored — pass a stable config or a new serverUrl to switch chains.
useCampaignProgress
Read the authenticated user’s Startale mission progress.null with an error rather than falling back to
{ false, false }. The server answers 503 when a shield token price is
unavailable, and rendering that as “mission incomplete” would tell a user who
qualified that they did not. See the sdk.campaigns section of the
TypeScript API reference for what each mission
counts, why hasDepositedAtLeast10Usd is not monotonic, and what
campaignTokenId changes about which deposits count.
usePortal
Hidden-recipient portal deposits: create portals, list them and their deposits, and drive the sweep / reclaim / withdraw actions.refresh pages through listPage until the cursor runs out and runs
automatically once the session is authenticated; it records failures in error
rather than rejecting. Portals are bound to the chain the root SDK was
configured for and ChainClient has no portal resource, so this hook reads the
root client and does not follow the provider’s active client.
See the Portal Deposits guide.
useGifts
Claimable transfers: fund a gift in any of the three modes, claim one by commitment or link, refund an unclaimed one, and read the pending gifts plus this session’s funding records.pendingGifts and
giftRecords are the read surface and no imperative getter is needed.
Block heights are decimal strings, not numbers, because they cross the vault
boundary. giftRecords is the SDK’s in-memory ledger rather than a server
query: an app that funds gifts must persist the records itself to stay able to
refund after a reload. Gifts are bound to the root SDK’s chain, so this hook
reads the root client.
See the Claimable Transfers guide.
useEarn
ERC-4626 Gateway operations: the vault catalog, gateway configuration, deposit and redeem, history charts, and the on-chain output preview.refresh runs as soon as the SDK is available rather
than waiting for authentication. Earn runs inside the shared key vault, which
is bound to the root SDK’s chain and rejects the whole surface on a
ChainClient, so this hook reads the root client rather than the provider’s
active client.
useSwap
Server-quoted Gateway swaps, plus the gateway fee lookup a swap UI prices against.isSwapQuoteExecutable and swapQuoteEconomics are pure and need no hook
state, so import them from @sunnyside-io/privacy-boost-react directly rather
than through this return.
Hand a quote back to swapFromQuote unchanged: callData and
minOutputAmount are what get signed, so reshaping any field means signing
something other than what was quoted. Like earn, swaps run in the root-bound
key vault, so this hook reads the root client.
useContacts
The private treasury address book, stored encrypted per wallet on the server.refresh runs automatically once the session is authenticated and pages through
the whole list. create, update and remove keep contacts in step from
their own results, so a refresh is only needed to pick up a change made
elsewhere; bulkCreate returns ids rather than rows, so it re-reads the list
itself. A contact the server can no longer
decrypt arrives with decryptionFailed: true and empty content fields: show it
as unreadable rather than dropping it, because the row still exists.
useLabels
Private memos and contact links keyed by transaction hash. Same storage and session model as contacts.upsert is a PUT that replaces the whole label, so a field you omit is cleared
on an existing one. It and remove keep labels in step from their own
results, so a refresh is only needed to pick up a change made elsewhere. Like contacts, a row the server cannot decrypt comes back
with decryptionFailed: true.
Helper Functions
createWalletAdapter()
Create wallet adapter from window.ethereum.
Types
PrivacyBoostConfig
Transaction
TokenBalance
useBalances() returns FormattedBalance values, which extend TokenBalance with formattedShielded / formattedWallet strings already formatted with the token’s decimals.
FeeRates
gatewayAddress. The
Gateway fee replaces the ordinary unshield fee for that operation.
OnProgress
Gifts and Portals
Both features have dedicated hooks;usePrivacyBoost()
reaches the same resources directly when you want to drive them yourself.
- Claimable Transfers:
useGifts(), orsdk.gifts - Portal Deposits:
usePortal(), orsdk.portal