data.erc20s
Fetches ERC20 datasets and returns them as polars.Dataframe.
Using ERC20Data you can:
Get the timeseries of the wallet balances
Get all transfers for the wallet
Get top volumes breakdown by the wallet
etc.
Examples
from datetime import datetime
from web3cat.data import ERC20Data
dates = [datetime(2021, 6, 1), datetime(2021, 7, 1), datetime(2021, 8, 1), datetime(2021, 9, 1)]
addresses = ["0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643", "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7"]
erc20_data = ERC20Data("Dai", addresses, min(dates), max(dates))
# All erc20 transfers for addresses
erc20_data.transfers
# All erc20 mints and burns
erc20_data.emission
# All token volumes by address
erc20_data.volume
# Historical total supply
erc20_data.total_supply(dates)
# Historical balances for addresses
erc20_data.balances(addresses, dates)
- class web3cat.data.erc20s.ERC20Data(token: str, address_filter: Optional[List[str]], start: int | datetime.datetime, end: int | datetime.datetime, **kwargs)
Bases:
DataCoreDatasets for ERC20 token.
- Parameters:
token – Token name or address
address_filter – Limit token transfer data only to these addresses. All transfers for mainstream tokens is a big chunk of data. This optimization makes fetches faster. This filter doesn’t apply to mints, burns, and total_supply.
start – Starting timepoint
end – Ending timepoint
- property contract: Contract
A
web3.contract.Contractfor this token
- property address_filter: List[str]
Address filter for this data (transfers only for these addreses)
- property transfers: DataFrame
Dataframe with transfers for addresses specified by the
address_filter.Schema
Field
Type
Description
timestampTimestamp of the transfer event
dateDate for the timestamp
block_numberBlock number for this transfer
transaction_hashTransaction hash for this transfer
log_indexLog index inside the transaction for this transfer
fromThe address from which erc20 token was sent
toThe address to which erc20 token was sent
valueTransfer value
- property emission: DataFrame
All mints and burns.
Schema
Field
Type
Description
timestampTimestamp of the transfer event
dateDate for the timestamp
block_numberBlock number for this mint / burn
transaction_hashTransaction hash for this mint / burn
log_indexLog index inside the transaction for this mint / burn
fromIf non-zero: the burn address
toIf non-zero: the mint address
valueTransfer value
- property volume: DataFrame
Dataframe with transfer volumes and balance changes by address.
Schema
Name
Type
Description
addressAddress
volumeVolume for the period
changeChange for the period (aka net volume)
- total_supply(timepoints: List[int | datetime.datetime])
Dataframe with total supply of the token
Schema
Field
Type
Description
timestampTimestamp of total supply snapshot
dateDate for the timestamp
block_numberBlock number for this total supply snapshot
total_supplyTotal supply in natural tokens (e.g. eth for weth, not wei)
- balances(addresses: List[str], timepoints: List[int | datetime.datetime]) DataFrame
Dataframe with balances for addresses over time.
- Parameters:
addresses – The list of addresses
timepoints – A list of timepoints
Returns a Dataframe with fields
Field
Type
Description
timestampTimestamp for the snapshot of the balance
dateDate for the timestamp
block_numberNumber of the block
addressEthereum Address
balanceBalance of an address at the time