API Reference
Complete API reference for the Privacy Boost TypeScript SDK.Generated Documentation
Full API documentation can be generated using TypeDoc:- All exported types and interfaces
- JSDoc comments and examples
- Type signatures and inheritance
PrivacyBoost
Main SDK class.PrivacyBoost.create(config)
Creates and initializes a new SDK instance.
| Name | Type | Description |
|---|---|---|
config.appId | string | Application identifier |
config.serverUrl | string | Privacy Boost server URL |
config.chainId | number | (Optional) EVM chain ID (auto-discovered from server) |
config.shieldContractAddress | string | (Optional) Shield contract address (auto-discovered from server) |
config.wethContractAddress | string | (Optional) WETH contract address |
sdk.auth
Authentication resource.auth.authenticate(adapter, options?)
Connect a wallet, derive privacy keys, and authenticate with the server in a single call.
| Name | Type | Description |
|---|---|---|
adapter | WalletAdapter | Wallet adapter implementation |
options | AuthenticateOptions | (Optional) Options object with keySource and tokenProvider |
options.keySource | KeySource | (Optional) Key derivation source. Defaults to walletDerived when no persistence is configured. |
options.tokenProvider | function | (Optional) Callback to obtain a JWT from the login payload |
AuthResult - either { status: 'authenticated', privacyAddress, mpk } or { status: 'credentialRequired', action, unlockType, submit }. If credential is required, call result.submit(credential) to complete authentication.
auth.logout()
End session completely, clear all state.
auth.clearSession()
Clear JWT only, keep keys for quick re-auth.
auth.isConnected()
Check if wallet is connected.
auth.isAuthenticated()
Check if user is authenticated.
auth.getPrivacyAddress()
Get user’s privacy address.
auth.getMpk()
Get user’s master public key.
sdk.vault
Vault resource for privacy operations.vault.shield(params)
Deposit tokens to private balance.
vault.unshield(params)
Withdraw tokens to public address.
vault.send(params)
Send private transfer.
vault.prepareShield(params)
Build a deposit payload without submitting it — for callers that relay the
transaction themselves (a gasless relayer, an EIP-7702 session key, or a plain
eth_sendRawTransaction). Returns the calldata to relay plus the note
commitment; nothing is sent on-chain and no wallet is used. After relaying, call
the top-level finalizeShield with the mined receipt to
recover the on-chain request id. recipient shields to another privacy address;
omit it to shield to yourself.
vault.getBalance(tokenAddress)
Get the cached balance entry for a token. Reads from the local store and may
fetch from the server on a cache miss. To force a network refresh, call
vault.refreshBalance(tokenAddress) first.
vault.getAllBalances()
Get all token balances.
vault.refreshBalance(tokenAddress)
Refresh a single token balance from the server.
vault.refreshBalances()
Refresh all tracked balances from the server.
vault.getToken(address)
Get token metadata for a single token.
vault.getTokens()
Get metadata for every token registered with the protocol.
parseAmount(amount, decimals)
Parse a human-readable amount to a bigint. Exported as a standalone utility from the SDK package.
formatAmount(amount, decimals)
Format a bigint amount as a human-readable string. Exported as a standalone utility from the SDK package.
Stateless shield helpers
Top-level functions 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. Imported from the package root.buildShieldPayload(params)
Build 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.
finalizeShield(params)
Recover the on-chain shield request id from the mined receipt of a relayed
deposit (see vault.prepareShield). Stateless — the
caller obtained the receipt from its own relay/RPC, so no signed-in session is
needed. Throws if the deposit reverted or the DepositRequested log is absent.
sdk.transactions
Transactions resource.transactions.fetchHistory(params?)
Get transaction history.
sdk.portal
Hidden-recipient portal deposit addresses. Preview feature — pending external audit.portal.create(opts?)
Derive a portal address E, delegate it, register the owner binding, and publish
the discovery entry — in one call.
portal.list()
portal.deposits(address)
portal.status(address)
delegated always reports false.
portal.sweep(address, tokenId)
Self-service sweep backstop (operator-run at launch). Returns the tx hash.
portal.reclaim(depositId)
Reclaim an un-credited deposit after the cancel delay; funds return to E.
Returns the tx hash.
portal.withdraw(params)
Build a signed raw EIP-1559 tx that withdraws funds resting at E (escape
hatch). Broadcast it yourself.
portal.delegateAddress()
The portal delegate address from /info, or undefined if unsupported.
Portal,
PortalInfo, PortalStatus, PortalDeposit, PortalDepositState,
CreatePortalOptions, and WithdrawPortalParams types.
Gift Methods (sdk.wasm)
Claimable transfers. Preview feature — exposed on the underlying WASM SDK viasdk.wasm. Each fund/claim/refund returns
a TransferResult (extended with optional giftRecord and claimLink).
| Method | Description |
|---|---|
giftFundToWallet(params) | Fund a gift bound to a wallet (no privacy address) |
giftFund(params) | Fund a gift bound to a wallet, sealed to a privacy address |
giftClaim(params) | Claim a pending gift by index |
giftClaimByCGift(params) | Claim by stable commitment cGift |
giftClaimFromLink(params) | Claim directly from a pbgift:v1:... link |
giftRefundByRecord(index) | Refund an unclaimed gift via a saved record |
giftRefund(params) | Refund by supplying every gift field manually |
getPendingGifts() | List claimable gifts addressed to the wallet |
getGiftRecords() | Local records of gifts you funded (for refunds) |
decodeGiftLink(link) | Decode + decrypt a claim link offline into a preview |
giftFundSecretBearer(params) also exists but is experimental, disabled by
default, and a bearer instrument — see the
concept page. Full parameter shapes and the
GiftRecord / PendingGift / GiftLinkPreview types are in the
gift guide.
Utility Functions
isValidPrivacyAddress(address)
Check if address is valid privacy address.
validatePrivacyAddress(address)
Validate a privacy address.
encodePrivacyAddress(mpk, viewingPublicKey)
Encode MPK and viewing public key to privacy address.
decodePrivacyAddress(address)
Decode privacy address to components.
extractMpkFromPrivacyAddress(address)
Extract MPK from privacy address.
isEvmAddress(address)
Check if valid EVM address.
isNativeEth(address)
Check if address represents native ETH.
Types
KeySource
Key derivation source, passed to authenticate().
| Variant | Description |
|---|---|
walletDerived | Derive keys from a wallet signature (default when no persistence is configured) |
mnemonic | Derive keys from a BIP-39 mnemonic phrase |
rawSeed | Derive keys from a raw 32-byte hex seed |
Hex
PrivacyAddress
0x prefix the string is 194 characters.
WalletAdapter
OnProgress
FeeRates
Fee schedule applied to vault operations.
feeModel is 'app_pays', the fee is settled out of band by the application — users see the gross amount. Shield fee schedules are available from vault.getFees(); the shield response does not currently surface the actual charged fee.
ComplianceStatus
| Status | Meaning |
|---|---|
PENDING | Compliance check is in progress; the deposit cannot be spent yet. |
LEGIT | Cleared; funds are usable. |
ILLICIT | Rejected by compliance; funds are quarantined. See Error Handling. |