Skip to main content

API Reference

Complete API reference for the Privacy Boost CLI library (Rust).

Generated Documentation

Full API documentation can be generated using cargo doc:

PrivacyBoostCLI

Main CLI SDK interface for Rust applications.

Constructor

Creates a new CLI SDK instance. Parameters:
  • config - CLI configuration
Returns: Result<PrivacyBoostCLI, CliError> Example:

Connection & Authentication Methods

authenticate

Connect wallet using a private key, derive privacy keys, and authenticate with the Privacy Boost backend in a single call. Parameters:
  • private_key - Hex-encoded private key
  • key_source - Optional key derivation source. None defaults to WalletDerived. Options: KeySource::WalletDerived, KeySource::Mnemonic { phrase }, KeySource::RawSeed { hex_seed }
  • token_provider - Optional custom token provider for server-mediated auth flows
Returns: Result<AuthResult, CliError> - either Authenticated(LoginResult) or CredentialRequired(CredentialChallenge)

submit_credential

Submit a credential when authenticate() returns CredentialRequired. Returns: Result<LoginResult, CliError>

logout

End session completely, clear all state.

clear_session

Clear JWT only, keep keys for quick re-auth.

is_authenticated

Check if authenticated.

State Accessors

Balance Methods

get_balance

Get balance for a specific token.

get_all_balances

Get all token balances.

Vault Operations

deposit

Deposit tokens into the shielded pool. Parameters:
  • token_address - Token contract address
  • amount - Amount in wei (as string)

withdraw

Withdraw tokens from the shielded pool. Parameters:
  • token_address - Token contract address
  • amount - Amount in wei (as string)
  • recipient - Recipient Ethereum address

send

Send a private transfer. Parameters:
  • token_address - Token contract address
  • amount - Amount in wei (as string)
  • recipient_privacy_address - Recipient’s 194-char privacy address

prepare_shield

Build a deposit payload without submitting it — for relaying the transaction yourself (a gasless relayer, an EIP-7702 session key, or a plain raw transaction). Returns the wrap/approve/requestDeposit calldata plus the note commitment; nothing is sent on-chain. Needs an authenticated session (keys) but no wallet. After relaying, settle from the mined receipt with privacy_boost_core::operations::finalize_shield. Parameters:
  • token_address - Token contract address (use 0x0 for ETH)
  • amount - Amount in wei (as string)
  • recipient - Recipient privacy address; None shields to yourself
CLI subcommands prepare-shield and finalize-shield wrap these for shell use — see the Commands Reference.

Transaction History

Get transaction history.

Session Persistence

export_session

Export session data for persistence.

import_session

Import session from persistence.

Address Lookup

resolve_identity

Look up a user’s privacy address by MPK or Ethereum address. Parameters:
  • identifier - MPK or Ethereum address
Returns: Result<IdentityResult, CliError>

Utilities


Module Functions

Returns the SDK version string.

CliConfig

CLI configuration struct.

Constructor

Builder Methods

File Operations

Environment


NetworkPreset

Network preset enumeration.

Methods

Parse aliases:
  • Local: "local", "localhost", "dev"
  • OpSepolia: "op-sepolia", "optimism-sepolia", "opsepolia"
Example:

Types

KeySource

Key derivation source, passed to authenticate(). WalletDerived derives keys from a wallet signature, Mnemonic from a BIP-39 phrase, and RawSeed from a raw 32-byte hex seed.

AuthResult

LoginResult

TokenBalance

ShieldResult

UnshieldResult

TransferResult

PreparedShield

Returned by prepare_shield. Re-exported from privacy_boost_core::operations. Carries no private material, so it is safe to hand to a relayer. Each Call is a single on-chain call to relay; value and data are 0x-hex.

Transaction

StatusInfo

IdentityResult

ExportedSession

Re-exported from privacy_boost_core::sdk_state::ExportedSession:

CliError


Default Values


Complete Example

Gift & Portal Commands

Claimable transfers and portal deposit addresses are preview features (pending external audit), exposed as CLI subcommands:
  • Claimable Transfersgift-fund-to-wallet, gift-fund, gift-list, gift-claim, gift-claim-from-link, gift-refund-by-record, gift-refund, gift-decode-link
  • Portal Depositsportal create | list | status | deposits | sweep | reclaim | withdraw

See Also