Skip to main content

API Reference

Complete API reference for the Privacy Boost React Native SDK (version 0.2.14). Everything below is derived from the generated UniFFI bindings — signatures match what consumers actually see.

Module exports

Top-level functions:
See Stateless shield helpers for buildShieldPayload and finalizeShield.

PrivacyBoost

Main SDK class. One instance per app; hold it in a module-level ref or a context provider.

Constructor

Configs are created via the factory:
Throws: SdkError.ConfigError if initialization fails, including unsupported persistence storage or passkey unlock configuration.

State

Authentication

Connect a wallet, derive privacy keys, authenticate with the backend. Returns an AuthResult tagged union — see AuthResult for all variants and handling.
Complete an authentication flow that returned CredentialRequired.
Complete an authentication flow that returned MnemonicGenerated (first-time user). Call this after the user confirms they’ve saved the recovery phrase.

Operations

unwrapWeth unwraps WETH the user already holds in their wallet back to native ETH — it does not interact with the shielded pool. prepareShield builds a deposit payload without submitting it — for callers that relay the transaction themselves (a gasless relayer, an EIP-7702 session key, or a plain raw transaction). It returns the calldata to relay plus the note commitment; nothing is sent on-chain. Pass undefined for recipient to shield to yourself, or a privacy address to shield to someone else. After relaying, pass the mined receipt to the top-level finalizeShield to recover the on-chain request id.

Status polling

Balances & tokens

History & notes

Merkle tree

Audit APIs

For auditable operations — returns all-party visible data, not just the calling user’s. Intended for compliance dashboards and regulators, not for end-user UIs.

App metadata

Session persistence

Identity lookup

Pending transactions

Local bookkeeping for optimistic UI — not persisted across SDK instances.

Chain context

Create a handle scoped to a different chain while sharing the same SDK identity.
See ChainContextHandle below.

Utilities


ChainContextHandle

Returned by sdk.createChainContext(). Mirrors the main SDK’s chain-scoped operations against a different chain, without requiring a second authentication.

Stateless shield helpers

Top-level named exports for building a deposit payload without a signed-in session — for a backend that holds only a recipient’s privacy address. No wallet, no private keys.
buildShieldPayload builds a recipient-targeted deposit payload from public material only. Resolve tokenId, shieldContractAddress, and teePublicKey from the token catalog / config. An ephemeral sender keypair is generated and discarded internally, and the note is spendable only by recipient. wethContractAddress is required only when shielding native ETH; minShieldAmount (per-token minimum in wei) rejects below-minimum deposits; emitApprove emits the ERC-20 approve call (pass true by default). finalizeShield recovers the on-chain shield request id from the mined receipt of a relayed deposit. Stateless — the caller obtained the receipt from its own relay/RPC. Throws if the deposit reverted or the DepositRequested log is absent. The TransactionReceipt is the same shape returned by WalletDelegate.waitForTransactionReceipt (see WalletDelegate).

Delegate interfaces

WalletDelegate

TokenProvider


Types

PrivacyBoostConfig

React Native currently rejects configured persistence backends at construction. Keep persistenceStorage and persistenceUnlock unset until native persistence is wired through this package.

ChainContextConfig

KeySource

Tagged union — each variant is constructable.

StorageBackend

These enum values are shared with other SDK targets, but React Native currently rejects them at construction.

UnlockMethod

Passkey is rejected on React Native because iOS and Android do not expose the WebAuthn PRF extension needed for reproducible vault unlock keys.

AuthResult

Tagged union returned by authenticate(). You must handle all four variants.
See Getting Started → Connecting a Wallet for worked handling of each variant.

LoginResult

ShieldResult

finalizeShield also returns a ShieldResult.

Call / PreparedShield

Returned by prepareShield and buildShieldPayload. Each Call is a single on-chain call to relay; value and data are 0x-hex.

UnshieldResult / TransferResult

ShieldStatus / TransactionStatus

TokenBalance

RegisteredToken

FeeRates

Transaction / TransactionNote / TransactionsResult

UnspentNote

MerkleTreeStats

Audit result types

See the generated bindings for full field lists; they’re stable but verbose.

PendingTransaction

ExportedSession

data is an opaque serialized core session. Store and pass it back unchanged; do not parse or persist individual key fields.

IdentityResult

AppInfoEntry


SdkError

Tagged union. Every variant is a constructable class, checked via .instanceOf(err). See the Error Handling guide for patterns and the full variant table.
The string tag is also available at runtime via SdkError_Tags:

Gift Methods

Claimable transfers (gifts) — instance methods on sdk, taking positional arguments. See the Claimable Transfers guide and the concept page.
Preview feature — pending external audit, and enabled per deployment. These methods may not be present in the checked-in generated bindings.
Each fund/claim/refund method returns a TransferResult whose giftRecord and claimLink fields are populated for gift operations.
Fund a gift bound to an Ethereum wallet address that may not be registered with Privacy Boost. amount is wei; refundAfterBlock/currentBlock are block numbers. Returns a TransferResult with claimLink and giftRecord populated.
Fund a gift when the recipient is already a Privacy Boost user, sealing the ciphertext to their viewing key. The third argument is the 194-char privacy address.
Claim a pending gift by its position in getPendingGifts(). acknowledgeUnknownSender must be true — it acknowledges accepting funds from an unknown sender.
Claim a pending gift by its stable commitment cGift (preferred when the list may shift as gifts settle).
Claim a gift directly from a pbgift:v1:... claim link, without a server lookup first.
Refund an unclaimed gift after its deadline, using a local gift record. index is the positional index into getGiftRecords().
Refund an unclaimed gift by supplying every field manually — the fallback when the local gift record is unavailable.
List the pending gifts addressed to the authenticated wallet.
Return the local records the SDK persisted for gifts you funded. These make a gift refundable and travel inside an exported session. Synchronous.
Decode a claim link into a preview offline, with no network call. Synchronous.
A third funding mode, giftFundSecretBearer, binds a gift to a secret instead of a wallet. It is experimental, disabled by default, and a bearer instrument (whoever holds the link can claim). See the concept page before considering it.

GiftRecord

PendingGift

GiftLinkPreview

The gift fields (giftRecord, claimLink) on TransferResult are populated only for gift operations; see UnshieldResult / TransferResult.

Portal

Portal deposit addresses. See the Portal Deposits guide and the concept page.
Preview feature — pending external audit, and enabled per deployment. React Native exposes portal lifecycle methods on PrivacyBoost. Low-level portal functions are limited to custodial escape hatches.
The supported path is sdk.createPortal(...), which derives the portal EOA from the account seed and keeps the key inside core.
Derive portal E, gaslessly delegate and register it via the server relays, then publish the discovery entry. Omit index to use the next free derivation index.
List the authenticated account’s portals with status and derivation index.
List deposits observed at portal.
Return registry/on-chain status for one portal.
Send requestPortalDeposit from the connected wallet and return the transaction hash.
Send cancelPortalDeposit from the connected wallet and return the transaction hash.
Build a signed EIP-1559 transaction that withdraws raw funds resting at the seed-derived portal E. Broadcast the returned raw transaction yourself.

Low-level escape hatches

These module-level functions are imported from @sunnyside-io/privacy-boost-react-native and are for custodial integrations that manage their own portal EOA key. The seed-derived createPortal flow does not expose a private key.
Generate a fresh portal EOA E and its secret private key.
Encode raw withdraw calldata for a custodial integration that already controls its own portal EOA.
Publish the discovery registry entry (E → blind) — the supported submit path so the indexer can credit deposits to the right account.
Return the portal delegate address advertised by the server’s /info, or undefined if the server does not support portals.

PortalEoa