📂Wallet Examples

After completing the authentication process and loading the required packages, you can directly access BigQuery from the Co-lab IDE. Below are some examples:

Sample Code To Track All Token Movement for a Wallet

# Example 1: SQL query moved to colab

result_1 = client.query("""

SELECT
  token_address,
  from_address,
  to_address,
  value,
  DATE(block_timestamp) as date
FROM
  `bigquery-public-data.crypto_ethereum.token_transfers`
WHERE
  from_address = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' or to_address = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
order by 
  DATE(block_timestamp) ASC  

""").result()

Note you have to specify a wallet address.

The result can then be loaded into a pandas dataframe for additional processing.

# Example 1: Moving the query data to a pandas.DataFrame

df_1 = result_1.to_dataframe()

df_1.head()

In this example, we aggregate the token transfers to find the median value of token transfers

# Example 1: Analysing the median number of token transfers over time, by token, and sorting in descending order

df_pivot = pandas.pivot_table(data=df_1, values = ['value'],index=['date'], columns=['token_address'], aggfunc='count')
df_pivot.index = pandas.to_datetime(df_pivot.index)

pandas.DataFrame(df_pivot.median(axis=0).sort_values(ascending=False),columns=['median_num_token_transfers'])

Last updated