Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 3.28 KB

balances.md

File metadata and controls

41 lines (29 loc) · 3.28 KB

Balances

Availability

{% hint style="success" %} This table is available for the Ethereum, Polygon, Arbitrum and Base. {% endhint %}

Points-of-Presence Tables
eu-west-1

token_balances_ethereum_mainnet_v1
token_balances_polygon_mainnet_v1
token_balances_arbitrum_mainnet_v1
token_balances_base_mainnet_v1

Methodology

The table is built by the following process:

  1. Identify all Transfer events (shared by ERC-20 and ERC-721) emitted in a block
  2. Call the balanceOf method for each pair of (token, wallet) extracted from these events

{% hint style="info" %} Some smart contracts have very inefficient implementations of the balanceOf method. To ensure the timely execution of our indexer, we decided to put a hard cap of gas usage for every balanceOf call we make. The current value is 2000000 gas. {% endhint %}

Table Schema

Column NameColumn TypeDescription
chain_namestringName of the chain (ethereum, arbitrum, polygon, ...).
chain_network_namestringname of the network (mainnet).
block_hashstringBlock hash encoded as binary string
block_numberuint64Block height
timestampdatetimeUNIX timestamp for when the block was collated
wallet_addressstringThe address of the wallet
token_addressstringThe address of the token
valueuint256The amount of token held

Usage

The below query makes use of the token_balances_ethereum_mainnet_v1 to list all the latest non-zero balances for every ERC-20 and ERC-721 token for the Binance 14 (0x28C6c06298d514Db089934071355E5743bf21d60) wallet.

select 
    token_address,
    argMax(value, block_number) as balance
from token_balances_ethereum_mainnet_v1
where wallet_address = '0x28C6c06298d514Db089934071355E5743bf21d60'
and value > 0
group by token_address
order by balance desc