💻
Developer Guide
  • Wallet SDK
    • Wallet Overview
    • Getting Started
      • 1. Start the RAILGUN Privacy Engine
      • 2. Build a persistent store for artifact downloads
      • 3. Load a Groth16 prover for each platform
      • 4. Add networks and RPC providers
      • 5. Set up a debug logger
    • Private Wallets
      • RAILGUN Wallets
      • View-Only Wallets
      • Encryption Keys
    • Private Balances
      • Balance and Sync Callbacks
      • Updating Balances
      • QuickSync
    • Transactions
      • Shielding
        • Shield ERC-20 tokens
        • Shield base token
        • Shield NFTs
      • Private Transfers
        • Private ERC-20 Transfers
        • Private NFT Transfers
      • Cross-Contract Calls
      • Unshielding
        • Unshield ERC-20 tokens
        • Unshield base token
        • Unshield NFTs
      • UX: Private Transactions
    • Broadcasters
  • Cookbook SDK
    • Cookbook Overview
    • Recipe Guide: Write a zkApp
      • "Step" — A smart contract call
      • "Recipe" — Steps in series
      • "Combo Meal" — 2+ Recipes
    • Use your zkApp privately
  • Engine SDK
    • Engine Overview
  • ZK Account Abstraction
    • Account Abstraction Overview
    • Getting started with the contracts
    • Wallets
    • State Structure
    • Example Primitives
Powered by GitBook
On this page
  1. Wallet SDK
  2. Private Balances

Updating Balances

In certain scenarios, you may want to manually refresh all private balances.

Example: Manually refresh balances

import { NETWORK_CONFIG, NetworkName } from '@railgun-community/shared-models';
import { refreshBalances } from '@railgun-community/wallet';

const { chain } = NETWORK_CONFIG[NetworkName.Ethereum];
const railgunWalletID = '...'; // Obtained after a previous call to `createRailgunWallet`

// Optional filter to only scan the provided wallet IDs. Leave undefined to scan all wallets.
const walletIdFilter = [railgunWalletID];

try {
    await refreshBalances(chain, walletIdFilter);
    // During scan, `onMerkletreeScanCallback` callback from the previous section will trigger.
    // When scan is completed, `onBalanceUpdateCallback` callback from the previous section will trigger.
    // This may take a few minutes on first sync, but only a few seconds on subsequent calls.
} catch (err) {
    // Scan failed to run.
}
PreviousBalance and Sync CallbacksNextQuickSync

Last updated 10 months ago