Credit Debit tables contain the amount and direction (credit/debit) of every transfer event of all assets (ETH, ERC20, ERC721 and ERC1155) across all Ethereum wallets. This table will include two rows for every event, with one row representing credit and one row representing debit. Asset-specific tables are also available for query.

Difference with transfers

Unlike token transfers, data here is organized into credit and debit rows (similar to the accounting concept called “double entry book”).

Methodology

Using an ERC20 token as an example, a token transfer will be represented as follows:

from_addressto_addressamountevent
XY1250X transfers 1250 tokens to Y

In credit debit, it will be represented as two rows.

addresscounterparty_addressamountevent
XY-1250X decrease 1250 tokens to Y
YX1250Y increase 1250 tokens from X

Advantages Over Transfer Tables

  1. Balance Calculation

    • Easy summation of all credits and debits for an address
    • Simplified queries for net position calculations
    • Natural handling of complex transactions
  2. Flow Analysis

    • Clear visualization of token inflows and outflows
    • Simple aggregation of total volume by address
    • Easy identification of major senders/receivers
  3. Data Consistency

    • Built-in verification through balanced entries
    • Self-auditing through equal total credits and debits
    • Simplified reconciliation process

Sample Query

Debit and credit of ETH from a particular transaction.

select * from ethereum.assets.credit_debit
where block_number = '5030097'
and transaction_hash = '0x1c2eb8b98e9917b30e402d519c1545116e7432699dffced4041c980cd8b6a4d6'

Getting the cumulative change of USDC holdings in Uniswap v3 USDC-WETH pool in the last 30 days

select
  date(block_timestamp) as date,
  token_name, 
  sum(amount) as delta,
  sum(delta) over (order by date) as net_change
from
  ethereum.assets.credit_debit
  where address = '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640' -- USDC-ETH Uniswap v3 5bp
  and token_address = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' -- USDC Token Address
and current_date - date(block_timestamp) < 30
group by date, token_name
order by date desc 

Table Columns

Column NameDescriptionExample (Credit)Example (Debit)
addressAddress of the account that was credited or debited value amount of token0x72e77c9c17ca1c99bd9eb2f1011c7524316255330xd387a6e4e84a6c86bd90c158c6028a58cc8ac459
counterparty_addressThe address of counter party of this credit or debit transfer.0xd387a6e4e84a6c86bd90c158c6028a58cc8ac4590x72e77c9c17ca1c99bd9eb2f1011c752431625533
token_addressToken address of the asset transferred. Note: Native ETH does not have a contract address, but for convention, it is labelled as: 0x00000000000000000000000000000000000000000x00000000000000000000000000000000000000000x0000000000000000000000000000000000000000
token_nameName of the asset transferred.ETHETH
token_symbolToken symbol of the asset transferred.ETHETH
raw_amountAmount of tokens moved (unnormalized). For ERC721 and ERC1155 tokens, there are no decimals division involved.-9E+159E+15
amountAmount of token moved, normalized.-0.0090.009
usd_amountThe amount of tokens moved, in $USD.-7.7317.731
usd_exchange_rateToken symbol of this token.859859
transaction_hashTransaction hash that this transfer belongs to.0x1c2eb8b98e9917b30e402d519c1545116e7432699dffced4041c980cd8b6a4d60x1c2eb8b98e9917b30e402d519c1545116e7432699dffced4041c980cd8b6a4d6
block_timestampThe timestamp of the block that the corresponding transaction of this transfer belongs to. This is also the timestamp when this transfer occurred.2018-02-04T16:10:482018-02-04T16:10:48
block_numberThe block number that the corresponding transaction of this transfer belongs to.50300975030097
block_hashThe block hash that the corresponding transaction of this transfer belongs to.0xea0ad2b10c2815f54a925c13161a252848ff9814cc49b16060c4a0782630bd380xea0ad2b10c2815f54a925c13161a252848ff9814cc49b16060c4a0782630bd38
token_typeThe type of asset transferred. Currently supports ETH, ERC20, ERC721 and ERC1155 tokens.ETHETH
unique_idUnique id generated to each transfer. Includes transaction hash, log index and credit and debit transaction type.trace-call_0x1c2eb8b98e9917b30e402d519c1545116e7432699dffced4041c980cd8b6a4d6_6_credittrace-call_0x1c2eb8b98e9917b30e402d519c1545116e7432699dffced4041c980cd8b6a4d6_6_debit