Concept

Balances tell the amount of assets held by each address at a specific block height. We track balances across all major token standards:

  • Native tokens (e.g., ETH, MATIC)

  • ERC20 tokens (e.g., USDC, WETH)

  • ERC721 tokens (NFTs)

  • ERC1155 tokens (Multi-tokens)

Balance Tracking Methodology

For Fungible Tokens (Native & ERC20):

  1. We detect balance-changing events (transfers, mints, burns)

  2. At each relevant block height, we read the actual on-chain balance

  3. This ensures accuracy by capturing any non-standard balance modifications

For Non-Fungible Tokens (ERC721 & ERC1155):

  1. We track transfers through standard events:

    • ERC721: Transfer() events

    • ERC1155: TransferSingle() and TransferBatch() events

  2. Build credit-debit tables to calculate cumulative ownership

  3. Account for minting, burning, and transfers between addresses

Precision Handling

To maintain numerical precision, especially for tokens with large supplies or many decimal places:

  1. Raw balances are stored as VARCHAR to preserve exact values

  2. Normalized balances are calculated using high-precision arithmetic

  3. Custom UDFs (User-Defined Functions) handle mathematical operations

  4. Both raw and human-readable balances are provided

This approach ensures:

  • No loss of precision from floating-point arithmetic

  • Accurate balance tracking over time

  • Reliable historical data for analysis

Sample Query

How to generate daily balances from block-level balances table.