Skip to main content

API Reference

Complete API reference for the Privacy Boost TypeScript SDK.

Generated Documentation

Full API documentation can be generated using TypeDoc:
The generated docs include:
  • 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.
Parameters: Example:

sdk.auth

Authentication resource.

auth.authenticate(adapter, options?)

Connect a wallet, derive privacy keys, and authenticate with the server in a single call.
Parameters: Returns: 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)

Launch limitation: 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.
See the portal guide for the Portal, PortalInfo, PortalStatus, PortalDeposit, PortalDepositState, CreatePortalOptions, and WithdrawPortalParams types.

Gift Methods (sdk.wasm)

Claimable transfers. Preview feature — exposed on the underlying WASM SDK via sdk.wasm. Each fund/claim/refund returns a TransferResult (extended with optional giftRecord and claimLink). 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().

Hex

PrivacyAddress

The payload encodes the master public key (32 bytes) and the viewing public key X/Y (32 bytes each). Hex-encoded, that is 192 characters; including the 0x prefix the string is 194 characters.

WalletAdapter

OnProgress

FeeRates

Fee schedule applied to vault operations.
When 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


Constants