Skip to main content

Wallet Integration

The wallet adapter is the bridge between the Privacy Boost SDK and your wallet integration. This guide covers implementing adapters for various wallet providers.

Interface Definition

Implementation Requirements

Return Values

  • Addresses: Checksummed hex strings with 0x prefix (42 characters)
  • Signatures: Hex strings with 0x prefix (132 characters for 65 bytes: r + s + v)
  • Transaction hashes: Hex strings with 0x prefix (66 characters)
  • Receipts: transactionHash, boolean status, and logs with address, topics, and data
  • Chain ID: Number matching expected network

Error Handling

Throw standard JavaScript errors with descriptive messages:

MetaMask / Injected Provider

WalletConnect

Coinbase Wallet

Safe (Gnosis Safe)

Testing Adapter

For testing, create a mock adapter:

Adapter Factory

Create a unified factory for multiple wallet types:

Best Practices

  1. Validate chain ID - Check that the wallet is on the expected network
  2. Handle rejections - Users may reject signing requests
  3. Timeout long operations - Set reasonable timeouts for wallet interactions
  4. Cache address - Avoid repeated getAddress() calls
  5. Handle disconnections - Watch for wallet disconnect events

Next Steps