API Reference
Complete API reference for the Privacy Boost CLI library (Rust).Generated Documentation
Full API documentation can be generated usingcargo doc:
PrivacyBoostCLI
Main CLI SDK interface for Rust applications.Constructor
config- CLI configuration
Result<PrivacyBoostCLI, CliError>
Example:
Connection & Authentication Methods
authenticate
private_key- Hex-encoded private keykey_source- Optional key derivation source.Nonedefaults toWalletDerived. Options:KeySource::WalletDerived,KeySource::Mnemonic { phrase },KeySource::RawSeed { hex_seed }token_provider- Optional custom token provider for server-mediated auth flows
Result<AuthResult, CliError> - either Authenticated(LoginResult) or CredentialRequired(CredentialChallenge)
submit_credential
authenticate() returns CredentialRequired.
Returns: Result<LoginResult, CliError>
logout
clear_session
is_authenticated
State Accessors
Balance Methods
get_balance
get_all_balances
Vault Operations
deposit
token_address- Token contract addressamount- Amount in wei (as string)
withdraw
token_address- Token contract addressamount- Amount in wei (as string)recipient- Recipient Ethereum address
send
token_address- Token contract addressamount- Amount in wei (as string)recipient_privacy_address- Recipient’s 194-char privacy address
send_batch
token_address- Token contract addressrecipients-(recipient, amount)pairs in output order, at least one. Amounts are wei strings
(inputs, outputs)
combinations, so a longer recipient list limits how many input notes can be
spent — past two recipients, at most four. Requests no enabled circuit can
serve fail with UNSUPPORTED_TRANSFER_SHAPE before submission.
prepare_shield
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 (use0x0for ETH)amount- Amount in wei (as string)recipient- Recipient privacy address;Noneshields to yourself
CLI subcommandsprepare-shieldandfinalize-shieldwrap these for shell use — see the Commands Reference.
list_shields_by_status
pending, processing,
preconfirmed, completed, failed), oldest first; an empty slice asks the
server for its default of pending. Served by the server, so it needs no chain
access.
Returns: UnsettledShieldResponse per row — request_id, status, and the
optional tx_hash, block_number, created_at, updated_at and error.
deposit_request_ids_from_transaction
DepositRequested id the pool emitted,
in log order — more than one when an aggregating relayer settled several callers
in one transaction. Empty means the transaction emitted no DepositRequested
from the configured pool.
CLI subcommandsdeposit listanddeposit idswrap these for shell use. See the Commands Reference.
get_deposit_cancellation
get_shield_status will tell you the shield failed, but nothing server-side
describes the escrow behind it — whether the pool still holds it, who may reclaim
it, and when — so this reads the pool directly through the connected wallet.
Costs three eth_calls plus one eth_blockNumber.
Parameters:
deposit_request_id- TheDepositRequestedevent’s indexed topic1, auint256. It’s the same request id a shield reports. Decimal or0x-hex; the result normalizes it to decimal.
DepositCancellation with the escrowed amount, the block the delay
expires at, and a reason you can print as-is
cancel_deposit
get_deposit_cancellation and fails locally,
before anything is signed, when the pool would revert. The error carries the
status reason, so a deposit that can’t be cancelled reports why instead of
burning gas on an opaque revert. If the wallet can’t run the preflight, the
transaction is submitted anyway and the chain arbitrates.
Only the address that submitted the deposit can cancel it, and the refund goes to
that address. For a relayer-submitted shield that’s the relayer, not the note
recipient.
CLI subcommandsdeposit statusanddeposit cancelwrap these for shell use. See the Commands Reference.
Transaction History
Session Persistence
export_session
import_session
Address Lookup
resolve_identity
identifier- MPK or Ethereum address
Result<IdentityResult, CliError>
Utilities
Module Functions
CliConfig
CLI configuration struct.Constructor
Builder Methods
File Operations
Environment
NetworkPreset
Network preset enumeration.Methods
Local:"local","localhost","dev"OpSepolia:"op-sepolia","optimism-sepolia","opsepolia"
Types
KeySource
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 byprepare_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.
DepositCancellation
Returned byget_deposit_cancellation. Re-exported from
privacy_boost_core::operations. Amounts are decimal strings and blocks are
absolute chain heights.
DepositCancelState mirrors the reverts in the pool’s cancelDeposit, reported
permanent-blocker first rather than in the pool’s own check order: the pool
checks the depositor before anything else, and that check would mask the two
conditions no caller can clear. A gateway-origin deposit stores the gateway
contract as its depositor, so it reports GatewayOrigin for every caller and at
every point in the delay window — waiting never makes it cancellable.
cancelDelay().
Read the deployed value instead of hardcoding a delay, using cancel_delay,
cancellable_at_block, and blocks_remaining from the status.
Transaction
StatusInfo
IdentityResult
ExportedSession
Re-exported fromprivacy_boost_core::sdk_state::ExportedSession:
CliError
Default Values
Complete Example
Gift & Portal Commands
Claimable transfers and portal deposit addresses are exposed as CLI subcommands:- Claimable Transfers —
gift-fund-to-wallet,gift-fund,gift-list,gift-claim,gift-claim-from-link,gift-refund-by-record,gift-refund,gift-decode-link - Portal Deposits —
portal create | list | status | deposits | sweep | reclaim | withdraw
See Also
- Getting Started - Basic CLI usage
- Commands Reference - CLI commands
- Claimable Transfers - Send to an unregistered wallet
- Portal Deposits - Reusable public deposit addresses
- Network Presets - Network configuration