Skip to main content

Balance Management

This guide covers querying and managing token balances in the Privacy Boost SDK.

Understanding Balances

Privacy Boost tracks two types of balances:

Get Single Token Balance

Get All Balances

Balance Type

Refreshing Balances

Balances are cached locally. Refresh to get the latest:

Token Metadata

Get information about a token:

Token Metadata Type

Supported Tokens

Get list of all supported tokens:

Formatting Amounts

parseAmount and formatAmount are standalone utilities exported from the SDK package.

Parse Human-Readable to BigInt

Format BigInt to Human-Readable

Native ETH

Native ETH is represented by the zero address:

UI Example

Balance Polling

Keep balances updated with polling:

Balance Calculations

Total Portfolio Value

Check Sufficient Balance

Error Handling

Best Practices

1. Cache Token Metadata

2. Handle Zero Balances

3. Refresh After Operations

Next Steps