Note

ctc is in beta, please report bugs to the issue tracker

These docs are also a work in progress. Some sections are not yet complete. Feel free to report any documentation-related issues to the issue tracker.

Check the Chain (ctc)

ctc is a tool for historical data analysis of Ethereum and other EVM chains

It can be used as either 1) a cli tool or 2) a python package

Features

  • data collection: collects data from archive nodes robustly and efficiently

  • data storage: stores collected data on disk so that it only needs to be collected once

  • data coding: handles data encoding and decoding automatically by default

  • data analysis: computes derived metrics and other quantitative data summaries

  • data visualization: plots data to maximize data interpretability and sharing

  • protocol specificity: includes functionality for protocols like Chainlink and Uniswap

  • command line interface: performs many block explorer tasks in the terminal

Guide

Datatypes

Datatype

CLI

Python

Source

ABIs

CLI

Python

Source

Addresses

CLI

Python

Source

Binary Data

CLI

Python

Source

Blocks

CLI

Python

Source

ERC20s

CLI

Python

Source

ETH Balances

CLI

Python

Source

Events

CLI

Python

Source

Transactions

CLI

Python

Source

Specific Protocols

Protocol

CLI

Python

Source

Aave V2

CLI

Python

Source

Balancer

CLI

Python

Source

Chainlink

CLI

Python

Source

Compound

-

Python

Source

Curve

CLI

Python

Source

ENS

CLI

Python

Source

Fei

CLI

Python

Source

Gnosis Safe

CLI

Python

Source

Multicall

CLI

Python

Source

Rari

CLI

Python

Source

Uniswap V2

CLI

Python

Source

Uniswap V3

CLI

Python

Source

Yearn

CLI

Python

Source

External Data Sources

Data Source

CLI

Python

Source

4byte

CLI

Python

Source

CoinGecko

CLI

Python

Source

Defi Llama

CLI

Python

Source

Etherscan

CLI

Python

Source

Installation

Basic Installation

Installing ctc takes 2 steps:

  1. pip install checkthechain

  2. ctc setup in the terminal to run the setup wizard (can skip most steps by pressing enter)

See Configuration for additional setup options.

If your shell’s PATH does not include python package scripts, you need to do something like python3 -m pip ... and python3 -m ctc ...

Installation requires python 3.7 or greater. see Dependencies for more information.

Upgrading

Upgrading to a new version of ctc takes two steps:

  1. pip install checkthechain -U

  2. Rerun the setup wizard by running ctc setup (can skip most steps by pressing enter)

If you previously installed ctc directly from a git commit, you may need to first pip uninstall checkthechain before upgrading.

When upgrading you should also check the changelog for

Uninstalling

Fully removing ctc from a machine takes three steps:

  1. Uninstall the package pip uninstall checkthechain

  2. Remove the config folder: rm -rf ~/.config/ctc

  3. Remove the data folder: rm -rf ~/ctc_data

You can always check whether a package has been uninstalled from your python environment by attempting to import it in a fresh shell. If you see a ModuleNotFoundError, the package has been uninstalled.

>>> import ctc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ctc'
>>> # ctc is not uninstalled

Special Installations

Installing from source

If you would like to install the latest version of ctc you can clone the repo directly:

git clone 
cd checkthechain
python -m pip install ./
Installing in develop mode / edit mode

If you would like to make edits to the ctc codebase and actively use those edits in your python programs, you can install the package in developer mode with the -e flag:

git clone 
cd checkthechain
python -m pip install -e ./

Libraries

On a fresh installation of Ubuntu or Debian, you may need to manually install the build-essential and python-dev packages. Machines that are used for active python development probably already have these packages installed.

PYTHON_VERSION=$(python3 -c "import sys; print('python' + str(sys.version_info.major) + '.' + str(sys.version_info.minor))")

python3 -m pip install $PYTHON_VERSION-dev
sudo apt-get install build-essential

Dependencies

TLDR

This page is only aimed at users that would like know what ctc depends on under the hood.

If you just want to install ctc then check out the Installation docs.

OS Dependencies

Usage of ctc requires python 3.7 or greater.

When using a fresh installation of Debian or Ubuntu, you may need to manually install build-essential and python-dev. These are libraries required by many python packages including ctc. If you are an active python user it’s likely that these are already installed on your machine. If you are setting up a new machine or environment, you may need to install them according to your operating system and python version.

To install these os dependencies on a fresh Debian / Ubuntu machine, can use the following:

PYTHON_VERSION=$(python3 -c "import sys; print('python' + str(sys.version_info.major) + '.' + str(sys.version_info.minor))")

python3 -m pip install $PYTHON_VERSION-dev
sudo apt-get install build-essential

Libraries

ctc depends on a few different types of external packages:

  1. data science dependencies include standard python library packages including numpy and pandas.

  2. IO dependencies include packages like aiohttp for network communication and toml for file io.

  3. toolsuite dependencies are general python utilities coming the toolsuite set of repos. These are written by the same authors as ctc.

  4. EVM/Cryptography dependencies include pycryptodome, rlp, and eth_abi.

Each of these dependencies has its own dependencies.

Reliance on these packages will be minimized in future releases to minimize attack surface and to maximize the number of environments in which ctc can be run. Some of the common libraries in the EVM ecosystem have incompatible requirements. For example, ethereum-etl requires older versions of web3py and eth_abi, and so a single environment cannot contain the most recent versions of all of these packages.

Type Checking

ctc uses mypy for static analysis of type annotations. This helps catch errors before they can appear at runtime. Custom types used by ctc can be found in the ctc.spec subpackage.

Checks are currently performed using mypy=0.930. Future mypy versions and features will be used as they become available. End users of ctc do not need mypy unless they are interested in running these type checks.

New python type annotation features will be used as they become available using typing_extensions. By using typing_extensions and from __future__ import annotations, new typing features can be used as they are released without sacrificing backward compatibility.

Testing

ctc tests are run using pytest 7.0.0 with the pytest-asyncio extension. These can be run using pytest . in the /tests directory.

Documentation

ctc documentation is built using sphinx 4.5.0. Source files and build instructions can be found in the Documentation Repository.

Databases

ctc stores much of the data it downloads in sql databases. Support for sqlite is currently in beta and support for postgresql is coming soon.

For more details see Data Storage

Configuration

TLDR

Run ctc setup on the command line to create the config. Run it again to edit the config.

ctc uses a configuration file to control its behavior.

Setting Config Parameters

Users do not need to directly create or edit ctc config files. Instead, all config parameters can be adjusted by using the setup wizard by running ctc setup on the command line. This can be used both for creating new configs and modifying the current config.

By default ctc will looks for a config file at ~/.config/ctc/config.json. But if the CTC_CONFIG_PATH environment variable is set, it will use that path instead.

ctc can also function under a “no-config” mode, where ctc setup does not need to be run. To use this mode, simply set the ETH_RPC_URL to an RPC provider url.

Config Parameters

The config file consists of key-value pairs. The keys:

  • config_spec_version: the ctc version used to create the config

  • data_dir: the directory where ctc stores its data

  • providers: metadata about RPC providers

  • networks: metadata about networks including their names and chain_id’s

  • default_network: default network to use

  • default_providers: default provider for each network

  • db_configs: database configuration information

  • log_rpc_calls: whether to log rpc calls

  • log_sql_queries: whether to log sql queries

A python type specification for the config can be found in the config typedefs file.

Reading Config Parameters

On the command line, running ctc config will print information about the config including its location on the filesystem and its current values.

In python, the ctc.config module has many functions for getting config data:

from ctc import config

config_path = config.get_config_path()
data_dir = config.get_data_dir()
providers = config.get_providers()

Changelog

until version 1.0.0 is reached, will use 0.X.Y versioning where X is for breaking changes / major feature upgrades, and Y is for bug fixes / minor feature upgrades

0.3.0

September 25, 2022

This is a significant release that includes features such as: sql database integration, refactored documentation, streamlined syntax, performance optimizations, and many new types of data queries. This release also includes lots of small bug fixes and quality-of-life improvements not listed below.

DB
  • integrate sql db for storing collected data

  • create tables for: blocks, contract abis, contract creation blocks, ERC20 metadata, 4byte signatures, and Chainlink feeds

  • add flags to functions for whether db should be used

  • auto-intake collected data into db by default

Documentation
  • create external documentation page https://ctc.readthedocs.io/en/latest

CLI
  • add help messages and examples to each subcommand

  • add color to cli output

  • optimize cli startup times

  • allow all cli commands to use ens names in place of addresses

  • add many subcommands including

    • storage, limits, encode, proxy, bytecode, chains, selector

    • abi decompile command for decoding ABI of solidity and vyper contracts

    • (see ctc -h for proper full list)

    • XX do a diff with 3.10?

  • add commands for events, candlestick charting

  • add --json to many cli commands to output data as json

Config
  • make configuration file optional by using a default config and looking for RPC provider in ETH_RPC_URL env var

  • when loading old config versions, attempt to transparently convert it to new config version

  • added better config validation

  • add shell alias configuration to ctc setup

Protocols
  • new protocol-specific functionality for Gnosis and Etherscan

  • add subcommands to previous covered protocols

  • use binary search to implement trade-to-price function for Uniswap V3 and other AMMs

Data Operations
  • new transaction and call data decoding system

  • automatically query proxy ABI when querying a contract’s ABI

    • if a function ABI or event ABI cannot be found, re-query contract proxy to check for ABI updates

  • add functionality for fetching all transactions of a given address

  • add functionality for predicting block numbers of future timestamps

Testing
  • use tox for testing each python version

  • create legacy test environment with minimal version of each dependency

  • test that all cli commands have examples and test that the examples work

  • enforce many coding conventions using tests

Performance
  • utilize caches and concurrency when possible

  • add appropriate rate limits for etherscan and 4byte for scraping

Python
  • upgrade from setuptools / setup.py to flit / pyproject.toml

  • use black for all py files in repo

  • use strict mode for mypy typing annotations

  • reduce number of implicit package dependencies by more than 50%

    • fork eth-abi package as eth-abi-lite to remove dependence on eth-abi, eth-utils, toolz and cytools

    • specify min and max version of each dependency to prevent future backwards incompability

Other
  • add logging system and allow use of ctc log command to follow logs

  • populate default data directory with metadata of: 22 networks, >1000 ERC20 tokens, and all Chainlink feeds

  • add functions for converting block numbers into timestamps for x-axis labels of plots

Upgrade Guide
  1. Run pip install -U checkthechain

  2. Run ctc setup

  3. There are some minor api changes (see below)

API Changes

Version 0.3.0 contains some breaking changes to make the API more consistent and intuitive. Care was taken to minimize these breaking changes. Future versions of ctc will aim to maximize backward compatilibity as much as possible.

  • config (running ctc setup command will automatically upgrade old config and data directory)

    • new config schema using flat structure instead of nested hierarchy (see ctc.spec.typedefs.config_types)

    • new data directory schema that better reflects underlying data relationships (see ctc.config.upgrade_utils.data_dir_versioning)

  • directory deprecated in favor of functions in config, db, and evm

  • evm

    • decode_function_output() arg: package_named_results –> package_named_outputs

    • async_get_proxy_address() –> async_get_proxy_implementation()

    • erc20 balance and allowance functions:

      • arg address –> wallet

      • arg addresses –> wallets

      • async_get_erc20_holdings_from_transfers –> async_get_erc20_balances_from_transfers

      • async_get_block_timestamp() modes renamed from before, after, equal to <=, >=, ==

      • async_get_erc20_balance_of –> async_get_erc20_balance

      • async_get_erc20_balance_of_addresses –> async_get_erc20_balances_of_addresses

      • async_get_erc20s_balance_of –> async_get_erc20s_balances

      • async_get_erc20_balance_of_by_block –> async_get_erc20_balance_by_block

      • async_get_erc20s_allowances_by_address –> async_get_erc20s_allowances_of_addresses

  • protocols

    • curve_utils.async_get_pool_addresses –> curve_utils.async_get_pool_tokens

    • rari_utils.get_pool_tvl_and_tvb –> rari_utils.async_get_pool_tvl_and_tvb

    • use for blockwise functions always use by_block rather than per_block

    • uniswap_v2_utils.async_get_pool_swaps –> uniswap_v2_utils.async_get_pool_trades

    • functions for querying data from specific DEX’s now all use unified a unified DEX syntax and API

  • spec

    • ConfigSpec –> Config

    • PartialConfigSpec –> PartialConfig

    • ProviderSpec –> ProviderReference

  • toolbox

    • move toolbox.amm_utils, toolbox.twap_utils, and toolbox.lending_utils under toolbox.defi_utils

  • cli

    • all commands are standardized on --export rather than --output to specify data export targets

  • for functions that print out summary information, instead of using a conventions of print_<X>() and summarize_<X>, use single convention print_X()

  • only allow positional arguments for the first two arguments of every function

0.2.10

March 26, 2022

  • add functionality for G-Uni Gelato, multicall

  • add Fei yield dashboard analytics

  • add commands for ABI summarization

  • signficantly improve test coverage

0.2.9

March 18, 2022

  • add Uniswap V3 functionliaty

  • improve Chainlink functions, commands, and feed registry

  • add twap_utils

  • add cli aliases

  • many small fixes

  • handle various types of non-compliant erc20s

0.2.8

March 2, 2022

  • fix str processing bug

0.2.7

March 2, 2022

  • add robustness and quality-of-life improvements to data cache

  • add 4byte functionality

  • add Coingecko functionality

0.2.6

February 24, 2022

  • fix many typing annotation issues

  • add Curve functionality

  • add Fei functionality

0.2.5

February 16, 2022

  • add ENS functionality

  • add hex, ascii, checksum, and lower cli commands

  • add Rari lens

0.2.4

February 15, 2022

  • python 3.7 compatibility fixes

0.2.3

February 14, 2022

  • add many cli commands

  • refactor existing cli commands

0.2.2

February 11, 2022

  • add python 3.7 and python3.8 compatibility

0.2.1

February 9, 2022

initial public ctc release

FAQ

What are the goals of ctc?

  • Treat historical data as a first-class feature: This means having historical data functionality well-integrated into each part of the of the API. It also means optimizing the codebase with historical data workloads in mind.

  • Protocol-specific functionality: This means having built-in support for popular on-chain protocols.

  • Terminal-based block explorer: This means supporting as many block explorer tasks as possible from the terminal. And doing so in a way that is faster than can be done with a web browser.

  • Clean API emphasizing UX: With ctc most data queries can be obtained with a single function call. No need to instantiate objects. RPC inputs/outputs are automatically encoded/decoded by default.

  • Maximize data accessibility: Blockchains contain vast amounts of data, but accessing this data can require large amounts of time, effort, and expertise. ctc aims to lower the barrier to entry on all fronts.

Why use async?

async is a natural fit for efficiently querying large amounts of data from an archive node. All ctc functions that fetch external data use async. For tips on using async see this section in the docs. Future versions of ctc will include some wrappers for synchronous code.

Do I need an archive node?

If you want to query historical data, you will need an archive node. You can either run one yourself or use a third-party provider such as Alchemy, Quicknode, or Moralis. You can also use ctc to query current (non-historical) data using a non-archive node.

Is ctc useful for recent, non-historical data?

Yes, ctc has lots of functionality for querying the current state of the chain.

Obtaining Data

ctc collects data from a variety of sources, including RPC nodes, metadata databases, block explorers, and market data aggregators. After initial collection, much of this data is then stored.

Sources of Historical Data

ctc collects the majority of its data from RPC nodes using the EVM’s standard JSON-RPC interface. Collection of historical data (as opposed to recent data) requires use of an archive node.

There are 3 main ways to gain access to an RPC node:

  1. Run your own node: Although this requires more time, effort, and upfront cost than the other methods, it often leads to the best results. Erigon is the most optimized client for running an archive node.

  2. Use a 3rd-party private endpoint: Private RPC providers (e.g. Alchemy, Quicknode, or Moralis) provide access to archive nodes, either through paid plans or sometimes even through free plans.

  3. Use a 3rd-party public endpoint: You can query data from public endpoints like Infura. This approach is not recommended for any significant data workloads, as it often suffers from rate-limiting and poor historical data availability.

ctc’s RPC config is created and modified by running the setup wizard.

Other types of data

Beyond RPC data there are other types of data that ctc collects, including:

Storing Data

ctc places much of the data that it retreives into local storage. This significantly improves the speed at which this data can be retrieved in the future and it also reduces the future load on data sources.

The default configuration assumes that most data is being queried from a remote RPC node. Some performance-minded setups, such as running ctc on the same server as an archive node, might achieve better tradeoffs between speed and storage space by tweaking ctc’s local storage features.

Data Storage Backends

ctc uses two main storage backends.

Filesystem

ctc stores some files on the filesystem. By default, ctc will place its data folder in the user’s home directory at ~/ctc_data. This is suitable for many setups. However, there are situations where it would be better to store data somewhere else, such as if the home directory is on a drive of limited size, or it the home directory is on a network drive with significant latency. The data directory can be moved by running the setup wizard ctc setup.

Total storage usage of ctc on the filesystem can be found by checking the size of the ctc data directory.

SQL Databases

ctc also stores lots of data in SQL database tables. Schemas for these tables can be found here. ctc currently supports sqlite with Postgresql support coming soon.

Total storage usage of ctc in the database can be found by running ctc db -v in the terminal.

You can connect to the currently configured database by running ctc db login in the terminal. Don’t do this unless you know what you’re doing.

Performance

TLDR

Even in suboptimal conditions, ctc uses optimizations that allow running many types of workloads at acceptable levels of performance. This page is for those who wish to squeeze additional performance out of ctc.

Optimizing Performance

There are many levers and knobs available for tuning ctc’s performance.

RPC Provider

Different 3rd party RPC providers can vary significantly in their reliability and speed. For example, some providers have trouble with large historical queries.

Operations in ctc that fetch external data are usually bottlenecked by the RPC provider, specifically the latency to the RPC provider. This latency can be reduced by running ctc as closely as possible to the archive node:

  • Fastest = running ctc on the same server that is running the archive node

  • Fast = running ctc on the same local network as the archive node

  • Slower = running ctc in the same geographic region as the archive node

  • Slowest = running ctc in a different geographic region than the archive node

If using a 3rd party RPC provider, you should inquire about where their nodes are located and plan accordingly.

ctc’s default configuration assumes that the user is querying an RPC node on a remote network. This leads ctc to locally store much of the data that it retrieves. However, it’s possible that alternate settings might be optimal in different contexts. For example if ctc is run on the same server as an archive node, then it’s possible that certain caches might hurt more than they help. Cache settings are altered using ctc setup on the command line.

Python Versions

More recent versions of python are generally faster. Upgrading to the latest python version is one of the easiest ways to improve code performance. In particular, the upcoming python 3.11 has much faster startup times and shows improvement across many benchmarks. This will make ctc’s cli commands feel especially quick and responsive.

Python Packages

By default, ctc tries to minimize its dependencies and minimize the number of build steps that happen during installation. This does carry a bit of performance cost. Faster versions of various packages can be installed using:

pip install checkthechain[performance]

If ctc detects that these additional performance packages are installed, it will use those instead of the default packages. This can produce a modest performance increase for some workloads.

Data Storage

ctc’s default data directory is ~/.config/ctc/ in the user’s home directory. If this directory is on a slow drive (especially a network drive), this will negatively impact performance. To optimize performance, place the data directory on as fast a drive as possible. This can be done by running the setup wizard ctc setup.

Data Caching

For tasks that require many RPC requests, or require lots of post-processing (or are demanding in other ways), you should consider caching the result in-memory or on-disk. One way to do this is with the toolcache package. With toolcache a simple decorator adds an in-memory or on-disk cache to the expensive function.

For example, if you are using ctc to create data payloads for a historical analytics dashboard, you might use a pattern similar to this:

import toolcache


async def create_data_payload(timestamps):
    return [
        compute_timestamp_stats(timestamp=timestamp)
        for timestamp in timestamps
    ]


# create an on-disk cache entry for each timestamp
@toolcache.cache('disk')
async def compute_timestamp_stats(timestamp):
    super_expensive_operation()
Logging

Logging of RPC requests and SQL queries consumes a non-zero amount of resources. If you don’t need logging, disabling it can squeeze out a bit of extra performance. This can be done by running the setup wizard ctc setup.

Benchmarking Performance

To truly optimize your environment and implementation, you will need to run your own benchmarks.

Benchmarking Speed

The simplest way to benchmark the speed of a CLI command is time. Running time <command> will run a given command and report the run time.

Benchmarking the speed of python code snippets is slightly more complicated but also has many tools available:

  1. Synchronous code can be easily profiled used IPython’s built-in magics %timeit, %%timeit, %prun, and %%prun

  2. If using a Jupyter notebook, the Execute Time extension can be extremely useful for getting a crude estimate of how long each code cell takes to run. This works for both synchronous and asynchronous code.

  3. For a more programmatic approach you can use python’s built-in profilers or 3rd party profilers such as Scalene or pyflame.

Measuring Storage Usage

It is also valuable to measure ctc’s storage usage to check whether it falls into an acceptable range for a given hardware setup. Storage usage in the ctc data folder can be found by running a storage profiling command like du -h or dust. Storage usage in databases can be found by running ctc db -v.

Monitoring

Logging

ctc can log outgoing RPC requests and SQL queries. This functionality can be enabled or disabled using ctc setup.

Logs are stored in logs subdirectory of the ctc data dir (default = ~/ctc_data).

Running ctc log in the terminal will begin watching for changes to the log files. This provides a detailed view of external queries as they happen, which can be useful for debugging and ensuring that external calls are happening as expected.

Logs are written to disk using a non-blocking queue, making it suitable for async applications and imparting minimal impact on performance. These logs are also rotated once they reach a certain size (default = 10MB). However, being non-blocking also means that the timestamps in the logs lose a bit of temporal precision, and so they do not provide a precise picture of event timing.

Logs are managed by the Loguru package. Loguru must be installed for logging to be enabled (pip install loguru).

Other monitoring

Beyond the built-in logging, the best way to monitor ctc is through standard 3rd party tools.

Recommended utilities for profiling resource usage:

If your situation calls for a more programmatic monitoring approach, then you probably already know what tools you need.

Basic Usage

The ctc cli command performs operations related to processing EVM data, especially operations related to historical data analysis. Many different EVM datasets can be generated by individual calls to ctc.

Typical usage is ctc <subcommand> [options], using Subcommands. To view the complete list of subcommands use ctc -h.

Most of the cli documentation pages are copied from ctc’s in-terminal help messages.

Subcommands

Note

Click on a subcommand to view its documentation page.

usage:
    ctc <subcommand> [options]

description:
    ctc is a tool for historical data analysis of Ethereum and other EVM chains
    
    if using ctc for the first time, run:
        ctc setup
    
    for quick lookups of an address, block, tx, or timestamp, run:
        ctc QUERY
    
        where QUERY is an address, block number, tx hash, or timestamp

    to view help about a specific subcommand run:
        ctc <subcommand> -h

available subcommands:

    admin subcommands
    aliases             view and manage ctc shell aliases
    chains              display information about configured chains
    config              print current config information
    db                  display database status
    log                 display logs
    setup               run ctc setup wizard

    compute subcommands
    ascii               convert hex to ascii
    checksum            compute checksum of address
    create address      generate address in the style of CREATE or CREATE2
    decode              decode encoded EVM datatypes
    decode call         decode EVM call data
    encode              encode data as EVM datatypes
    hex                 convert text data to hex representation
    int                 convert data to integer
    keccak              compute keccak hash of data
    limits              display limits of various datatypes
    lower               convert string to lower case
    rlp encode          RLP encode data
    selector            compute 4byte function selector using function signature

    data subcommands
    abi                 display abi of contract
    abi diff            display diff of two contract ABI's
    address             summarize address
    address txs         output all transactions from address
    block               summarize block
    blocks              output information about blocks
    bytecode            get raw bytecode stored at address
    call                output result of a call
    call all            display outputs of all contract's read-only functions
    calls               output the result of multiple contract eth_call's
    chain               display chain_id of provider
    decompile           decompile contract abi
    dex chart           display candlestick chart of DEX pool trades
    dex pool            show information about a pool
    dex pools           list dex pools
    dex trades          get DEX swaps
    erc20               display information about ERC20
    erc20 balance       output an ERC20 balance
    erc20 balances      output ERC20 balances of blocks / addresses / tokens
    erc20 transfers     output information about ERC20 transfers
    eth balance         output ETH balance of address
    eth balances        output ETH balance across blocks or addresses
    events              get contract events
    gas                 output gas summary of block range
    proxy               print proxy information about contract
    proxy register      register custom proxy implementation of a contract
    storage             get value of storage slot
    symbol              convert ERC20 address to symbol, or symbol to address
    timestamp           get block of timestamp
    tx                  display transaction data, receipt, call data, & logs

    protocol subcommands
    4byte               lookup 4byte signature
    4byte build         build local copy of 4byte database
    aave                output aave usage statistics
    aave addresses      output aave-related addresses
    cg                  output coingecko market data
    chainlink           output Chainlink feed data
    chainlink feeds     list all Chainlink feeds
    curve pools         list curve pools
    ens                 summarize ENS entry
    ens exists          output whether ENS name exists
    ens hash            output hash of ENS name
    ens owner           output owner of ENS name
    ens records         output text records of ENS name
    ens resolve         resolve ENS name
    ens reverse         reverse ENS lookup address
    etherscan           open etherscan query in browser or fetch
    fei analytics       output data payload for app.fei.money/analytics
    fei depth           output FEI liquidity depth information
    fei dex             show information related to FEI on DEX's
    fei pcv             output summary of Fei PCV
    fei pcv assets      output summary of Fei PCV assets
    fei pcv deposits    output summary of Fei PCV deposits
    fei psms            display recent FEI redemptions
    gnosis              print information about a gnosis safe
    llama               output data from Defi Llama api
    llama chain         output data about a chain tracked by Defi Llama
    llama chains        output data about chains tracked by Defi Llama
    llama pool          output data about a pool tracked by Defi Llama
    llama pools         output data about pools tracked by Defi Llama
    llama protocol      output data about a protocol tracked by Defi Llama
    llama protocols     output data about protocols tracked by Defi Llama
    rari                summarize fuse pool, token, or platform
    rari pools          list all Rari fuse pools
    uniswap burns       output information about pool burns
    uniswap chart       chart price action of uniswap pools
    uniswap mints       output information about pool mints
    uniswap pool        summarize pool
    uniswap swaps       output information about pool swaps
    yearn               display summary of Yearn vaults
    yearn addresses     output Yearn addresses

    other subcommands
    cd                  change working directory to ctc-related location
    help                output help
    version             print cli version

Admin Subcommands

Note

Click on a subcommand to view its documentation page.

usage:
    ctc <subcommand> [options]

description:
    ctc is a tool for historical data analysis of Ethereum and other EVM chains
    
    if using ctc for the first time, run:
        ctc setup
    
    for quick lookups of an address, block, tx, or timestamp, run:
        ctc QUERY
    
        where QUERY is an address, block number, tx hash, or timestamp

    to view help about a specific subcommand run:
        ctc <subcommand> -h

admin subcommands:
    aliases             view and manage ctc shell aliases
    chains              display information about configured chains
    config              print current config information
    db                  display database status
    log                 display logs
    setup               run ctc setup wizard
aliases
usage:
    ctc aliases  [options]

description:
    view and manage ctc shell aliases
    
    these aliases allow you to call ctc subcommands without typing the "ctc" part
    
        for example, you can type 4byte 0xa9059cbb instead of ctc 4byte 0xa9059cbb
    
    these aliases must go in your shell config file
    
        this can be done using one of the following methods:
        1. use ctc aliases --append to append to autodetected config files
        2. use ctc aliases >> CONFIG_PATH to append the aliases to config file
        3. manually paste the aliases into your config file
    
        the path to your terminal file depends on shell:
        - bash: ~/.profile or ~/.bashrc
        - zsh: ~/.zshrc
        - fish: ~/.config/fish/config.fish
    
    to learn more about the underlying commands, run ctc help
    
    depending on preference, can use all aliases or just a subset of them

examples:
    ctc aliases 

    ctc aliases --raw

    ctc aliases --install

arguments:
    --raw        output aliases as raw script file
    --install    install/upgrade aliases in shell config (will ask for confirmation)
chains
usage:
    ctc chains  [options]

description:
    display information about configured chains

examples:
    ctc chains 
    ctc chains --verbose

arguments:
    --verbose, -v    display additional information including RPC urls
config
usage:
    ctc config  [options]

description:
    print current config information

examples:
    ctc config 
    ctc config --reveal
    ctc config --json

arguments:
    --reveal      show sensitive information in config
    --json        output config as json
    --no-color    do not use color
db
usage:
    ctc db  [options]

description:
    display database status

example:
    ctc db 

arguments:
    -v, --verbose    display additional information
log
usage:
    ctc log 

description:
    display logs

example:
    # tail logs
    ctc log 
setup
usage:
    ctc setup  [options]

description:
    run ctc setup wizard
    
    setup wizard sets up ctc config and ctc data directory
    
    each step is optional
    - by default, setup process will leave existing settings unchanged
    - setup can be rerun multiple times idempotently
    
    can run in headless mode (non-interactive mode) using `--headless`:
    - headless mode will use the default values for each unspecified parameter
    - headless mode is useful in scripts when user input is not possible
    - if config file already exists, headless mode must be run with `--overwrite`

examples:
    ctc setup 

    ctc setup --headless

    ctc setup --headless --overwrite

arguments:
    --headless                     run in headless mode
    --ignore-old-config            ignore settings specified in previous config
    --skip-networking              skip network configuration steps
    --rpc-url RPC_URL              url to use for RPC node
    --rpc-chain-id RPC_CHAIN_ID    chain id of RPC node given by `--rpc-url`
    --data-dir DATA_DIR            directory where to store ctc data
    --disable-logs                 disable ctc logs
    --skip-db                      skip creating db until it next time it is needed
    --overwrite                    overwrite old config file
    --skip-aliases                 disable ctc logs

Compute Subcommands

Note

Click on a subcommand to view its documentation page.

usage:
    ctc <subcommand> [options]

description:
    ctc is a tool for historical data analysis of Ethereum and other EVM chains
    
    if using ctc for the first time, run:
        ctc setup
    
    for quick lookups of an address, block, tx, or timestamp, run:
        ctc QUERY
    
        where QUERY is an address, block number, tx hash, or timestamp

    to view help about a specific subcommand run:
        ctc <subcommand> -h

compute subcommands:
    ascii               convert hex to ascii
    checksum            compute checksum of address
    create address      generate address in the style of CREATE or CREATE2
    decode              decode encoded EVM datatypes
    decode call         decode EVM call data
    encode              encode data as EVM datatypes
    hex                 convert text data to hex representation
    int                 convert data to integer
    keccak              compute keccak hash of data
    limits              display limits of various datatypes
    lower               convert string to lower case
    rlp encode          RLP encode data
    selector            compute 4byte function selector using function signature
ascii
usage:
    ctc ascii DATA

description:
    convert hex to ascii

examples:
    ctc ascii 0x766974616c696b
    ctc ascii 0x7475726475636b656e

arguments:
    DATA    hex data to convert
checksum
usage:
    ctc checksum ADDRESS

description:
    compute checksum of address

example:
    ctc checksum 0xd8da6bf26964af9d7eed9e03e53415d37aa96045

arguments:
    ADDRESS    address to get checksum of
create address
usage:
    ctc create address SENDER NONCE_OR_SALT [INIT_CODE]

description:
    generate address in the style of CREATE or CREATE2

examples:
    ctc create address 0xd8da6bf26964af9d7eed9e03e53415d37aa96045 123
    ctc create address 0xd8da6bf26964af9d7eed9e03e53415d37aa96045 0xaabb 0xaabbccdd

arguments:
    SENDER           sender address
    NONCE_OR_SALT    sender nonce (for CREATE) or salt (for CREATE2)
    INIT_CODE        initialization bytecode for CREATE2
decode
usage:
    ctc decode TYPE DATA

description:
    decode encoded EVM datatypes
    
    for simple datatypes, no quotes required
    
    for nested datatypes, enclose in quotes and quote contained addresses

examples:
    ctc decode address 0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f
    ctc decode "(int64,int64,int64)" 0x00000000000000000000000000000000000000000000000000000000000000010000000000000000
0000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003

arguments:
    TYPE    type of data to decode
    DATA    data to decode


usage of subcommands:
    ctc decode can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc decode <subcommand> -h

available subcommands:
    call    decode EVM call data
decode call
usage:
    ctc decode call ARGS [options]

description:
    decode EVM call data
    
    syntax is one of
        1. ctc decode call CALL_DATA
        2. ctc decode call CONTRACT_ADDRESS CALL_DATA
        3. ctc decode call TX_HASH --tx

examples:
    ctc decode call 0xdac17f958d2ee523a2206206994597c13d831ec7 0xa9059cbb00000000000000000000000021dd5c13925407e5bcec3f
27ab11a355a9dafbe3000000000000000000000000000000000000000000000000000000003fd629c0
    ctc decode call 0xeefba1e63905ef1d7acba5a8513c70307c1ce441 0x252dba420000000000000000000000000000000000000000000000
00000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000
0000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000a658
03ad604668e26a81be92c9f1c90354255eae00000000000000000000000000000000000000000000000000000000000000400000000000000000000
000000000000000000000000000000000000000000044bba06f270000000000000000000000000a01960ddf19c59e43cbdf0b5ab9278d7459e76e00
0000000000000000000000e9822f18f2654e606a8dff9d75edd98367e7c0ae000000000000000000000000000000000000000000000000000000000
00000000000000000000000a65803ad604668e26a81be92c9f1c90354255eae00000000000000000000000000000000000000000000000000000000
00000040000000000000000000000000000000000000000000000000000000000000002451cff8d90000000000000000000000000a01960ddf19c59
e43cbdf0b5ab9278d7459e76e00000000000000000000000000000000000000000000000000000000
    ctc decode call 0xcb2931bd1c078f70106017f2e0c378fa9f648aa7d17c1d87240764b65e4626c9

arguments:
    ARGS        `CALL_DATA` or `CONTRACT_ADDRESS CALL_DATA` or `TX_HASH`
    --nested    whether to decode nested calls
encode
usage:
    ctc encode TYPE DATA [options]

description:
    encode data as EVM datatypes
    
    for simple datatypes, no quotes required
    
    for nested datatypes, enclose in quotes and quote contained addresses

examples:
    ctc encode address 0x6b175474e89094c44da98b954eedeac495271d0f
    ctc encode "(int64,int64,int64)" "[1,2,3]"

arguments:
    TYPE        datatype used for encoding
    DATA        data to be encoded
    --packed    encode like solidity's abi.encodePacked()
hex
usage:
    ctc hex TEXT [options]

description:
    convert text data to hex representation

examples:
    ctc hex vitalik
    ctc hex turducken

arguments:
    TEXT     ascii or other text data to convert
    --raw    omit the "0x" prefix
int
usage:
    ctc int DATA

description:
    convert data to integer

examples:
    ctc int 0xa00
    ctc int 0x123456789abdef

arguments:
    DATA    hex data to convert to integer
keccak
usage:
    ctc keccak DATA [options]

description:
    compute keccak hash of data
    
    by default, data treated as hex if it starts with "0x", or treated as text otherwise

examples:
    # take hash of hex data
    ctc keccak 0x678acb67

    # take hash of text
    ctc keccak vitalik

arguments:
    DATA      data to hash
    --text    treat input data as text instead of hex
    --hex     treat data as hex
    --raw     omit "0x" prefix on output
limits
usage:
    ctc limits  [options]

description:
    display limits of various datatypes

examples:
    ctc limits 
    ctc limits --verbose
    ctc limits --bits 256 512 1024

arguments:
    --verbose, -v      display all possible bit values
    --bits, -b BITS    specify number of bits, either single or as list
lower
usage:
    ctc lower TEXT

description:
    convert string to lower case

example:
    ctc lower 0x956F47F50A910163D8BF957Cf5846D573E7f87CA

arguments:
    TEXT    text to convert
rlp encode
usage:
    ctc rlp encode DATA

description:
    RLP encode data

examples:
    ctc rlp encode 1024
    ctc rlp encode cat
    ctc rlp encode 0x956f47f50a910163d8bf957cf5846d573e7f87ca

arguments:
    DATA    data to encode (can enclose with quotes)
selector
usage:
    ctc selector TEXT_SIGNATURE

description:
    compute 4byte function selector using function signature
    
    in most cli shells must enclose parentheses in quotes " "

examples:
    ctc selector "totalSupply()"
    ctc selector "transfer(address,uint256)"

arguments:
    TEXT_SIGNATURE    signature of function

Data Subcommands

Note

Click on a subcommand to view its documentation page.

usage:
    ctc <subcommand> [options]

description:
    ctc is a tool for historical data analysis of Ethereum and other EVM chains
    
    if using ctc for the first time, run:
        ctc setup
    
    for quick lookups of an address, block, tx, or timestamp, run:
        ctc QUERY
    
        where QUERY is an address, block number, tx hash, or timestamp

    to view help about a specific subcommand run:
        ctc <subcommand> -h

data subcommands:
    abi                 display abi of contract
    abi diff            display diff of two contract ABI's
    address             summarize address
    address txs         output all transactions from address
    block               summarize block
    blocks              output information about blocks
    bytecode            get raw bytecode stored at address
    call                output result of a call
    call all            display outputs of all contract's read-only functions
    calls               output the result of multiple contract eth_call's
    chain               display chain_id of provider
    decompile           decompile contract abi
    dex chart           display candlestick chart of DEX pool trades
    dex pool            show information about a pool
    dex pools           list dex pools
    dex trades          get DEX swaps
    erc20               display information about ERC20
    erc20 balance       output an ERC20 balance
    erc20 balances      output ERC20 balances of blocks / addresses / tokens
    erc20 transfers     output information about ERC20 transfers
    eth balance         output ETH balance of address
    eth balances        output ETH balance across blocks or addresses
    events              get contract events
    gas                 output gas summary of block range
    proxy               print proxy information about contract
    proxy register      register custom proxy implementation of a contract
    storage             get value of storage slot
    symbol              convert ERC20 address to symbol, or symbol to address
    timestamp           get block of timestamp
    tx                  display transaction data, receipt, call data, & logs
abi
usage:
    ctc abi ADDRESS NAMES [options]

description:
    display abi of contract

examples:
    ctc abi 0x956f47f50a910163d8bf957cf5846d573e7f87ca
    ctc abi 0x2b79b3c3c7b35463a28a76e0d332aab3e20aa337 Mint Burn Swap Sync
    ctc abi 0x2b79b3c3c7b35463a28a76e0d332aab3e20aa337 -f
    ctc abi 0x2b79b3c3c7b35463a28a76e0d332aab3e20aa337 -e
    ctc abi 0x956f47f50a910163d8bf957cf5846d573e7f87ca --json
    ctc abi 0x956f47f50a910163d8bf957cf5846d573e7f87ca --map-names --python

arguments:
    ADDRESS            address of contract
    NAMES              name of function or event
    --json             json only
    --json-raw         json only, without sorting or indentations
    --map-names        output ABI as map where names are the keys
    --map-selectors    output ABI as map where hash selectors are the keys
    -f, --functions    display function abi's only
    -e, --events       display event abi's only
    --search SEARCH    query of name of function or event abi
    --verbose, -v      include extra abi data
    --python           output data as pep8-formatted python syntax
    --update           re-import ABI from etherscan (e.g. if proxy has changed)


usage of subcommands:
    ctc abi can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc abi <subcommand> -h

available subcommands:
    diff    display diff of two contract ABI's
abi diff
usage:
    ctc abi diff FIRST_ADDRESS SECOND_ADDRESS [options]

description:
    display diff of two contract ABI's

example:
    ctc abi diff 0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419 0xf79d6afbb6da890132f9d7c355e3015f15f3406f

arguments:
    FIRST_ADDRESS     first contract address
    SECOND_ADDRESS    second contract address
    --functions       show functions only
    --events          show events only
address
usage:
    ctc address ADDRESS [options]

description:
    summarize address
    
    for contracts, will display ABI

example:
    ctc address 0x956f47f50a910163d8bf957cf5846d573e7f87ca

arguments:
    ADDRESS                 address to get summary of
    -v, --verbose           emit extra output
    --raw                   emit abi in raw json
    --network NAME_OR_ID    network name or id to scan address of


usage of subcommands:
    ctc address can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc address <subcommand> -h

available subcommands:
    txs    output all transactions from address
address txs
usage:
    ctc address txs ADDRESS [options]

description:
    output all transactions from address

examples:
    ctc address txs 0xd8da6bf26964af9d7eed9e03e53415d37aa96045

    ctc address txs 0xd8da6bf26964af9d7eed9e03e53415d37aa96045 -v

arguments:
    ADDRESS          get transactions from this address
    -v, --verbose    display additional information
block
usage:
    ctc block [BLOCK] [options]

description:
    summarize block

examples:
    ctc block 14000000
    ctc block 14000000 --json
    ctc block --timestamp 1600000000

arguments:
    BLOCK                    block number
    --timestamp TIMESTAMP    specify block by timestamp
    --verbose, -v            emit extra information
    --json                   output block as raw json
blocks
usage:
    ctc blocks BLOCKS [options]

description:
    output information about blocks

examples:
    # get blocks 14000000 through 14000010
    ctc blocks 14000000:14000010

    # get blocks 14000000 through 15000000, every 100000 blocks
    ctc blocks 14000000:15000000:100000

    # get blocks 14000000 through 15000000, every 100000 blocks
    ctc blocks 14000000:15000000 -n 10

    # get blocks 14000000 through 14000100, with specific attributes
    ctc blocks 14000000:14000100 --attributes timestamp,number

arguments:
    BLOCKS                     block range to fetch
    -n N                       number of blocks in block slice
    --attributes ATTRIBUTES    attributes to fetch from each block
    --export EXPORT            file path for output (.json or .csv)
    --overwrite                specify that output path can be overwritten
    --provider PROVIDER        rpc provider to use
bytecode
usage:
    ctc bytecode ADDRESS

description:
    get raw bytecode stored at address

example:
    ctc bytecode 0x6b175474e89094c44da98b954eedeac495271d0f

arguments:
    ADDRESS    address where bytecode is stored
call
usage:
    ctc call ADDRESS FUNCTION ARGS [options]

description:
    output result of a call

examples:
    ctc call 0x956f47f50a910163d8bf957cf5846d573e7f87ca totalSupply
    ctc call 0x956f47f50a910163d8bf957cf5846d573e7f87ca 0x18160ddd
    ctc call 0x956f47f50a910163d8bf957cf5846d573e7f87ca '{"name": "totalSupply", "inputs": [], "outputs": [{"type": 
"uint256"}]}'

arguments:
    ADDRESS          address to point call toward
    FUNCTION         function name, 4byte selector, or ABI
    ARGS             function arguments
    --verbose, -v    show summary
    --from FROM      address where call should come from
    --block BLOCK    block number for call


usage of subcommands:
    ctc call can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc call <subcommand> -h

available subcommands:
    all    display outputs of all contract's read-only functions
call all
usage:
    ctc call all CONTRACT_ADDRESS [options]

description:
    display outputs of all contract's read-only functions
    
    currently only displays output of zero-parameter functions

examples:
    ctc call all 0x6c3f90f043a72fa612cbac8115ee7e52bde6e490
    ctc call all 0x240315db938d44bb124ae619f5fd0269a02d1271 --max-results 5

arguments:
    CONTRACT_ADDRESS             address of contract to call functions of
    --max-results MAX_RESULTS    for functions that output lists, limit display length
    --block BLOCK                block number for call
calls
usage:
    ctc calls ADDRESS_AND_OR_FUNCTION [options]

description:
    output the result of multiple contract eth_call's
    
    This command can be used in two ways:
    
    1) Multi-contract Calls: same call across multiple contracts
        - This is indicated by the --addresses parameter
        - Example: call <function> --addresses <addr1> <addr2> <addr3>
    
    2) Multi-block Calls: same call across multiple blocks
        - This is indicated by either of the --blocks or --time parameters
        - Example: call <addr1> <function> --time 30d
    
    in each case, <function> can be a name, a 4byte selector, or an ABI
    
    ## Multi-contract Calls
    
    Example use case: Get a wallet's balances for many ERC20 tokens
    
    Can use --block to select a specific block for calls
    
    By default will use the first address's function abi for all calls
        (Retrieve separate ABI's for each contract using --unique-abis)
    
    ## Multi-block Calls
    
    Example use case: Get the total supply of an ERC20 over time
    
    Can specify multi-block calls by blocks or by timestamps
    
    Ranges are inclusive of start and end boundaries
    
    ### Specifying multi-block calls using --blocks
    
    Example block specifications:
        --blocks 16000 16010 16020 16030
        --blocks 16010:16030:10
        --blocks 16010:16030 -n 4
        --blocks 16030:-20:10
        --blocks latest:-20:10
        (each of these examples would specify the same set of 4 blocks,
         if the latest block were 16030)
    
    Can also specify a block range sampled over a regular time interval:
        --blocks 15000000:16000000:1d --> samples block range once per day
    
    For block ranges with no interval specified, all blocks are used
    
    ### Specifying multi-block calls using --times
    
    Example time specifications:
        --times 20220701:20220730 -n 30
        --times 20220701:20220730:1d
        --times 20220701:29d -n 30
        --times 29d:20220701 -n 30
        (each of these examples specifies the same set of 30 timestamps)
    
    Can also use the current time as an implicit default:
        --times 100d::1d
        --times 100d -n 101
        --times 100d: -n 101
        --times 100d:: -n 101
        (each of these examples specifies the same set of 100 timestamps)
    
    Can indicate timestamps using a variety of formats:
    
            timestamp formats           meaning               examples  
        ───────────────────────┼──────────────────┼───────────────────────
              number + letter        timelength                   100d  
            (one of {yMdhms})                                      24h  
        ───────────────────────┼──────────────────┼───────────────────────
                         YYYY     start of year                   2018  
                                                                  2022  
        ───────────────────────┼──────────────────┼───────────────────────
                       YYYYMM    start of month                 201802  
                      YYYY-MM                                  2022-06  
        ───────────────────────┼──────────────────┼───────────────────────
                     YYYYMMDD      start of day               20180228  
                   YYYY-MM-DD                               2022-06-01  
        ───────────────────────┼──────────────────┼───────────────────────
              YYYYMMDD_HHMMSS     minute in day               20180228  
             YYYY-MM-DD_HH:MM                         2022-06-01_04:30  
        ───────────────────────┼──────────────────┼───────────────────────
              YYYYMMDD_HHMMSS     second in day               20180228  
          YYYY-MM-DD_HH:MM:SS                      2022-06-01_04:30:40  
        ───────────────────────┼──────────────────┼───────────────────────
                 large number    unix timestamp             1600000000  
                                                            1700000000  
    
    See the tooltime package for more information about time specifications
    
    A default of -n 25 is used if no -n is specified for time range
    
    ## Outputs
    
    A table of outputs is displayed by default, omit with --no-table
    
    Numerical outputs of multi-block calls are charted, omit with --no-chart
    
    Use --export to output data to a json or csv file
    More data is included when exporting to a file
    

examples:
    # 1) multi-contract template: same call across multiple addresses
    ctc calls <function> [<function_parameters>] --addresses <addresses>

    # 2) multi-block template: same call across multiple blocks
    ctc calls <address> <function> [<function_parameters>] --blocks <blocks>

    # Balance of DAI, USDC, and USDT in Curve 3pool
    ctc calls balanceOf 0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7 --addresses 
0x6b175474e89094c44da98b954eedeac495271d0f 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 
0xdac17f958d2ee523a2206206994597c13d831ec7 --normalize

    # Weekly balance of DAI in Curve 3pool throughout year 2021
    ctc calls 0x6b175474e89094c44da98b954eedeac495271d0f balanceOf 0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7 --times 
2021:2022:1w --normalize

    # Balance of DAI in Curve 3pool over the past 1 million blocks
    ctc calls 0x6b175474e89094c44da98b954eedeac495271d0f balanceOf 0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7 --blocks 
latest:-1000000 -n 20 --normalize

arguments:
    ADDRESS_AND_OR_FUNCTION      <see above>
    -b, --blocks BLOCKS          block list or block range (see above)
    -t, --times TIMES            timestamp list or time range (see above)
    -n N                         number of calls to make in given range
    -a, --addresses ADDRESSES    addresses to point calls toward
    --block BLOCK                block number for calls
    --unique-abis UNIQUE_ABIS    retrieve separate ABI for each address
    --export EXPORT              file path for output (.json or .csv)
    --overwrite                  specify that output path can be overwritten
    --no-table                   do not output a table
    --no-chart                   do not output a chart
    --from FROM                  address that calls should come from
    --normalize NORMALIZE        normalize output by value, default is 1) erc20 decimals or 2) "1e18"
    --blocks-gte-times           find the blocks >= timestamps instead of <=
chain
usage:
    ctc chain PROVIDER [options]

description:
    display chain_id of provider

examples:
    ctc chain https://rpc.flashbots.net/
    ctc chain https://arbitrumrpc.com

arguments:
    PROVIDER         url or configured name of RPC node
    --verbose, -v    display additional information about provider chain
    --config         display only chain_id from config, not reported chain_id
    --no-check       do not check reported chain_id against configured chain_id
decompile
usage:
    ctc decompile ADDRESS_OR_BYTECODE [options]

description:
    decompile contract abi

example:
    ctc decompile 0x956f47f50a910163d8bf957cf5846d573e7f87ca

arguments:
    ADDRESS_OR_BYTECODE    contract address or hex bytecode
    -v, --verbose          do not clip long names
dex chart
usage:
    ctc dex chart POOL [options]

description:
    display candlestick chart of DEX pool trades

examples:
    ctc dex chart 0xf4ad61db72f114be877e87d62dc5e7bd52df4d9b
    ctc dex chart 0xf4ad61db72f114be877e87d62dc5e7bd52df4d9b --invert

arguments:
    POOL                     Uniswap pool address
    --timescale TIMESCALE    size of candlesticks, e.g. 1h, 1d, or 1w
    --invert                 use inverse of price
    --no-volume              hide volume data
dex pool
usage:
    ctc dex pool POOL [options]

description:
    show information about a pool

examples:
    ctc dex pool 0xc5be99a02c6857f9eac67bbce58df5572498f40c
    ctc dex pool 0xc5be99a02c6857f9eac67bbce58df5572498f40c --block 14000000

arguments:
    POOL                 address of pool
    --network NETWORK    network to query
    --block BLOCK        block number
dex pools
usage:
    ctc dex pools TOKENS [options]

description:
    list dex pools

examples:
    ctc dex pools CRV
    ctc dex pools DAI --dex balancer
    ctc dex pools DAI --created 14000000:15000000

arguments:
    TOKENS               token symbols or addresses (separate using spaces)
    --update             run update to index all recently created pools
    --created CREATED    specify start and/or end of when pool was created
    --dex DEX            name of dex (e.g. balancer, curve, uniswap-v2)
    --factory FACTORY    address of pool factory
    --all-pools          display all pools instead of just the first 1000
    --compact            use compact view for higher information density
    --verbose, -v        show additional data
    --json               output data as json
    --csv                output data as json
    --export EXPORT      file path to save output to
    --overwrite          specify that output path can be overwritten
    --sort SORT          column to sort pools by
dex trades
usage:
    ctc dex trades POOL [options]

description:
    get DEX swaps

example:
    ctc dex trades 0xc5be99a02c6857f9eac67bbce58df5572498f40c --blocks 14000000:14010000

arguments:
    POOL                           pool to retrieve swaps from
    -b, --blocks BLOCKS            block range to retrieve swaps from
    --no-normalize NO_NORMALIZE    do not normalize by ERC20 decimals
    --export EXPORT                file path to save output to
    --overwrite                    specify that output path can be overwritten
    -v, --verbose                  output extra data
erc20
usage:
    ctc erc20 ERC20

description:
    display information about ERC20

examples:
    ctc erc20 DAI
    ctc erc20 0x6b175474e89094c44da98b954eedeac495271d0f

arguments:
    ERC20    ERC20 address or symbol


usage of subcommands:
    ctc erc20 can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc erc20 <subcommand> -h

available subcommands:
    balance      output an ERC20 balance
    balances     output ERC20 balances of blocks / addresses / tokens
    transfers    output information about ERC20 transfers
erc20 balance
usage:
    ctc erc20 balance ERC20_ADDRESS WALLET_ADDRESS [options]

description:
    output an ERC20 balance

examples:
    ctc erc20 balance 0x956f47f50a910163d8bf957cf5846d573e7f87ca 0x9928e4046d7c6513326ccea028cd3e7a91c7590a
    ctc erc20 balance 0x956f47f50a910163d8bf957cf5846d573e7f87ca 0x9928e4046d7c6513326ccea028cd3e7a91c7590a --raw
    ctc erc20 balance 0x956f47f50a910163d8bf957cf5846d573e7f87ca 0x9928e4046d7c6513326ccea028cd3e7a91c7590a --block 
14000000

arguments:
    ERC20_ADDRESS     address of ERC20 token
    WALLET_ADDRESS    address of wallet
    --block BLOCK     block number
    --raw             whether to normalize balance by ERC20 decimals
erc20 balances
usage:
    ctc erc20 balances ARGS [options]

description:
    output ERC20 balances of blocks / addresses / tokens

examples:
    # version 1: balance of single wallet across multiple tokens
    ctc erc20 balances WALLET --erc20s ERC20S [--block BLOCK]

    # version 2: balances of multiple wallets in single block (default = all wallets)
    ctc erc20 balances ERC20 [--block BLOCK] [--wallets WALLETS]

    # version 3: balance of single wallet across multiple blocks
    ctc erc20 balances ERC20 WALLET --blocks BLOCKS

arguments:
    ARGS                 <see above>
    --block BLOCK        block number
    --wallets WALLETS    wallets to get balances of
    --blocks BLOCKS      block numbers to get balances at
    --erc20s ERC20S      ERC20 addresses to get balances of
    --raw                whether to skip normalizing by ERC20 decimals
    --export EXPORT      file path for output (.json or .csv)
    --overwrite          specify that output path can be overwritten
    -n N                 show n data points
erc20 transfers
usage:
    ctc erc20 transfers ERC20 [options]

description:
    output information about ERC20 transfers

examples:
    ctc erc20 transfers 0x956f47f50a910163d8bf957cf5846d573e7f87ca

    ctc erc20 transfers 0x956f47f50a910163d8bf957cf5846d573e7f87ca --blocks 14000000:14001000

    ctc erc20 transfers 0x956f47f50a910163d8bf957cf5846d573e7f87ca --blocks 14000000:14001000 --include-timestamps

arguments:
    ERC20                   ERC20 address
    --blocks BLOCKS         block range of transfers
    --include-timestamps    include timestamps
    --export EXPORT         file path for output (.json or .csv)
    --overwrite             specify that output path can be overwritten
eth balance
usage:
    ctc eth balance ADDRESS [options]

description:
    output ETH balance of address

examples:
    ctc eth balance 0xd8da6bf26964af9d7eed9e03e53415d37aa96045
    ctc eth balance 0xd8da6bf26964af9d7eed9e03e53415d37aa96045 --raw
    ctc eth balance 0xd8da6bf26964af9d7eed9e03e53415d37aa96045 --block 14000000

arguments:
    ADDRESS          address of wallet
    --block BLOCK    block number
    --raw            skip normalizing balance by 1e18 decimals
eth balances
usage:
    ctc eth balances WALLETS [options]

description:
    output ETH balance across blocks or addresses

examples:
    # multiple wallets
    ctc eth balances 0xd8da6bf26964af9d7eed9e03e53415d37aa96045 0xea674fdde714fd979de3edf0f56aa9716b898ec8 
0xbe0eb53f46cd790cd13851d5eff43d12404d33e8

    # multiple blocks
    ctc eth balances 0xd8da6bf26964af9d7eed9e03e53415d37aa96045 --blocks 14000000:14000100

    # multiple blocks with USD values
    ctc eth balances 0xd8da6bf26964af9d7eed9e03e53415d37aa96045 -v --blocks 14000000:14100000:1000

arguments:
    WALLETS            wallet addresses to get balances of
    --block BLOCK      block number
    --blocks BLOCKS    block numbers to get balances in
    --raw              skip normalizing by 1e18 decimals
    --export EXPORT    file path for output (.json or .csv)
    --overwrite        specify that output path can be overwritten
    -v, --verbose      display additional information
events
usage:
    ctc events CONTRACT EVENT [options]

description:
    get contract events

examples:
    ctc events 0x956f47f50a910163d8bf957cf5846d573e7f87ca Transfer

    ctc events 0x956f47f50a910163d8bf957cf5846d573e7f87ca Transfer --blocks 14000000:14010000

    ctc events 0x956f47f50a910163d8bf957cf5846d573e7f87ca Transfer --blocks 14000000:14010000 --include-timestamps

arguments:
    CONTRACT                contract address of event
    EVENT                   event name or event hash
    --blocks BLOCKS         block range
    --include-timestamps    include timestamps
    --export EXPORT         file path for output (.json or .csv)
    --overwrite             specify that output path can be overwritten
    --verbose, -v           display more event data
gas
usage:
    ctc gas  [options]

description:
    output gas summary of block range

examples:
    ctc gas 
    ctc gas --last 300

arguments:
    --block BLOCK      historical block to use
    --last N           number of blocks to include
    --export EXPORT    file path for output (.json or .csv)
    --overwrite        specify that output path can be overwritten
    -v, --verbose      output additional information
proxy
usage:
    ctc proxy CONTRACT_ADDRESS [options]

description:
    print proxy information about contract

example:
    ctc proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785

arguments:
    CONTRACT_ADDRESS    address to get proxy of
    --verbose, -v       print additional information
    --block BLOCK       block to query


usage of subcommands:
    ctc proxy can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc proxy <subcommand> -h

available subcommands:
    register    register custom proxy implementation of a contract
proxy register
usage:
    ctc proxy register PROXY_CONTRACT IMPLEMENTATION_CONTRACT [options]

description:
    register custom proxy implementation of a contract
    
    Implementation ABI will be downloaded for original contract
    
    Manual registration using this command is normally unnecessary
    
    This command is useful for custom proxy implementations

example:
    ctc proxy register 0xfb558ecd2d24886e8d2956775c619deb22f154ef 0xe16db319d9da7ce40b666dd2e365a4b8b3c18217 --confirm

arguments:
    PROXY_CONTRACT             contract that falls back to other contract
    IMPLEMENTATION_CONTRACT    contract that implements proxy contract
    --confirm                  confirm registration of proxy
storage
usage:
    ctc storage CONTRACT_ADDRESS SLOT [options]

description:
    get value of storage slot

examples:
    ctc storage 0x245cc372c84b3645bf0ffe6538620b04a217988b 0x0
    ctc storage 0x245cc372c84b3645bf0ffe6538620b04a217988b 0x0 --type address
    ctc storage 0x245cc372c84b3645bf0ffe6538620b04a217988b 0x0 --block 14000000

arguments:
    CONTRACT_ADDRESS    address of contract
    SLOT                address of storage slot
    --block BLOCK       block number
    --type TYPE         decode data using this datatype
symbol
usage:
    ctc symbol QUERY

description:
    convert ERC20 address to symbol, or symbol to address

example:
    ctc symbol DAI

arguments:
    QUERY    ERC20 address or symbol
timestamp
usage:
    ctc timestamp [TIMESTAMP]

description:
    get block of timestamp

example:
    ctc timestamp 1642114795

arguments:
    TIMESTAMP    timestamp (default = now)
tx
usage:
    ctc tx TRANSACTION [options]

description:
    display transaction data, receipt, call data, & logs

example:
    ctc tx 0xe981fe5c78d11d935a1dc35c579969e65e2dd6bb05ad321ea9670f8b1e203eaf

arguments:
    TRANSACTION    hash of transaction
    --sort SORT    attribute to sort logs by
    --json         output raw JSON of tx

Protocol Subcommands

Note

Click on a subcommand to view its documentation page.

usage:
    ctc <subcommand> [options]

description:
    ctc is a tool for historical data analysis of Ethereum and other EVM chains
    
    if using ctc for the first time, run:
        ctc setup
    
    for quick lookups of an address, block, tx, or timestamp, run:
        ctc QUERY
    
        where QUERY is an address, block number, tx hash, or timestamp

    to view help about a specific subcommand run:
        ctc <subcommand> -h

protocol subcommands:
    4byte               lookup 4byte signature
    4byte build         build local copy of 4byte database
    aave                output aave usage statistics
    aave addresses      output aave-related addresses
    cg                  output coingecko market data
    chainlink           output Chainlink feed data
    chainlink feeds     list all Chainlink feeds
    curve pools         list curve pools
    ens                 summarize ENS entry
    ens exists          output whether ENS name exists
    ens hash            output hash of ENS name
    ens owner           output owner of ENS name
    ens records         output text records of ENS name
    ens resolve         resolve ENS name
    ens reverse         reverse ENS lookup address
    etherscan           open etherscan query in browser or fetch
    fei analytics       output data payload for app.fei.money/analytics
    fei depth           output FEI liquidity depth information
    fei dex             show information related to FEI on DEX's
    fei pcv             output summary of Fei PCV
    fei pcv assets      output summary of Fei PCV assets
    fei pcv deposits    output summary of Fei PCV deposits
    fei psms            display recent FEI redemptions
    gnosis              print information about a gnosis safe
    llama               output data from Defi Llama api
    llama chain         output data about a chain tracked by Defi Llama
    llama chains        output data about chains tracked by Defi Llama
    llama pool          output data about a pool tracked by Defi Llama
    llama pools         output data about pools tracked by Defi Llama
    llama protocol      output data about a protocol tracked by Defi Llama
    llama protocols     output data about protocols tracked by Defi Llama
    rari                summarize fuse pool, token, or platform
    rari pools          list all Rari fuse pools
    uniswap burns       output information about pool burns
    uniswap chart       chart price action of uniswap pools
    uniswap mints       output information about pool mints
    uniswap pool        summarize pool
    uniswap swaps       output information about pool swaps
    yearn               display summary of Yearn vaults
    yearn addresses     output Yearn addresses
4byte
usage:
    ctc 4byte SIGNATURE [options]

description:
    lookup 4byte signature

examples:
    ctc 4byte 0x18160ddd
    ctc 4byte 0xa9059cbb
    ctc 4byte "totalSupply()"
    ctc 4byte "transfer(address,uint256)"

arguments:
    SIGNATURE    signature to look up
    --local      use local database
    --remote     use remote database


usage of subcommands:
    ctc 4byte can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc 4byte <subcommand> -h

available subcommands:
    build    build local copy of 4byte database
4byte build
usage:
    ctc 4byte build [DATATYPE]

description:
    build local copy of 4byte database
    
    scrapes from 4byte.directory

examples:
    # build function signature db
    ctc 4byte build functions

    # build event signature db
    ctc 4byte build events

arguments:
    DATATYPE    "functions" or "events", omit to build database of both
aave
usage:
    ctc aave [TOKEN] [options]

description:
    output aave usage statistics

examples:
    ctc aave 
    ctc aave --verbose
    ctc aave --block 14000000
    ctc aave DAI
    ctc aave DAI --time 1y -n 10
    ctc aave DAI --time 1y --verbose -n 10

arguments:
    TOKEN            show information related to this token
    --verbose, -v    show additional addresses
    --block BLOCK    block to get addresses of
    --time TIME      timescale to use for token-specific charts
    -n N             number of blocks to sample


usage of subcommands:
    ctc aave can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc aave <subcommand> -h

available subcommands:
    addresses    output aave-related addresses
aave addresses
usage:
    ctc aave addresses  [options]

description:
    output aave-related addresses

examples:
    ctc aave addresses 
    ctc aave addresses --verbose
    ctc aave addresses --block 15000000

arguments:
    --verbose, -v    show additional addresses
    --block BLOCK    block to get addresses of
cg
usage:
    ctc cg TOKENS [options]

description:
    output coingecko market data

examples:
    ctc cg 
    ctc cg CRV -t 100d
    ctc cg ETH / BTC
    ctc cg LINK / ETH -t 24h
    ctc cg --update

arguments:
    TOKENS             token to display information of
    -t, --time TIME    time of chart (e.g. 7d, 1y, max)
    -n N               number of entries to include in output
    --verbose, -v      include extra data
    --height HEIGHT    height, number of rows per asset
    --width WIDTH      width of sparklines
    --update           update stored coingecko token db
curve pools
usage:
    ctc curve pools  [options]

description:
    list curve pools

examples:
    ctc curve pools 
    ctc curve pools --verbose

arguments:
    --verbose, -v    include extra data
ens
usage:
    ctc ens NAME_OR_ADDRESS [options]

description:
    summarize ENS entry

examples:
    ctc ens 0xd8da6bf26964af9d7eed9e03e53415d37aa96045
    ctc ens vitalik.eth
    ctc ens vitalik.eth --verbose

arguments:
    NAME_OR_ADDRESS    ENS name(s) or address(es)
    --block BLOCK      block number
    --verbose, -v      display additional information


usage of subcommands:
    ctc ens can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc ens <subcommand> -h

available subcommands:
    exists     output whether ENS name exists
    hash       output hash of ENS name
    owner      output owner of ENS name
    records    output text records of ENS name
    resolve    resolve ENS name
    reverse    reverse ENS lookup address
ens exists
usage:
    ctc ens exists NAME [options]

description:
    output whether ENS name exists

examples:
    ctc ens exists vitalik.eth
    ctc ens exists vitalik.eth --block 14000000
    ctc ens exists fake-vitalik.eth

arguments:
    NAME             ENS name
    --block BLOCK    block number
ens hash
usage:
    ctc ens hash NAME

description:
    output hash of ENS name

example:
    ctc ens hash vitalik.eth

arguments:
    NAME    ENS name
ens owner
usage:
    ctc ens owner NAME [options]

description:
    output owner of ENS name

examples:
    ctc ens owner vitalik.eth
    ctc ens owner vitalik.eth --block 14000000

arguments:
    NAME             ENS name
    --block BLOCK    block number
ens records
usage:
    ctc ens records NAME

description:
    output text records of ENS name

example:
    ctc ens records vitalik.eth

arguments:
    NAME    ENS name
ens resolve
usage:
    ctc ens resolve NAME [options]

description:
    resolve ENS name

examples:
    ctc ens resolve vitalik.eth
    ctc ens resolve vitalik.eth --block 14000000

arguments:
    NAME             ENS name
    --block BLOCK    block number
ens reverse
usage:
    ctc ens reverse ADDRESS [options]

description:
    reverse ENS lookup address

examples:
    ctc ens reverse 0xd8da6bf26964af9d7eed9e03e53415d37aa96045
    ctc ens reverse 0xd8da6bf26964af9d7eed9e03e53415d37aa96045 --block 14000000

arguments:
    ADDRESS          address of reverse lookup
    --block BLOCK    block number
etherscan
usage:
    ctc etherscan QUERY [options]

description:
    open etherscan query in browser or fetch

examples:
    ctc etherscan 0xd3181ddbb2cea7b4954b8d4a05dbf85d8fc36aef

    ctc etherscan 0x146063226f2bc60ab02fff825393555672ff505afb352ff11b820355422ba31e

    ctc etherscan 14000000

    ctc etherscan vitalik.eth

    ctc etherscan vitalik.eth --holdings

    ctc etherscan vitalik.eth --erc20-transfers

    ctc etherscan DAI

    ctc etherscan DAI --holders

arguments:
    QUERY                address / tx / block / ERC20 symbol / ens
    --holdings           open page viewing holdings of address
    --erc20-transfers    open page viewing ERC20 transfers of address
    --internal           open page viewing internal txs of address
    --holders            open page viewing holders of ERC20 address
    --logs               open page viewing logs of transaction
    --changes            open page viewing state changes of transaction
    --abi                output only the json ABI of an address
fei analytics
usage:
    ctc fei analytics [TIMESCALE] [options]

description:
    output data payload for app.fei.money/analytics

example:
    # create default payload for app.fei.money
    ctc fei analytics 30d,1d

arguments:
    TIMESCALE      time window size and resolution
    --path PATH    path for data output (a .json file)
    --overwrite    allow overwriting an already-existing file
fei depth
usage:
    ctc fei depth  [options]

description:
    output FEI liquidity depth information

examples:
    ctc fei depth 
    ctc fei depth --prices "0.996" "0.997"

arguments:
    --prices PRICES    specify which price levels to output depths of
    --json             output data as json
fei dex
usage:
    ctc fei dex  [options]

description:
    show information related to FEI on DEX's

examples:
    ctc fei dex 
    ctc fei dex --block 14000000

arguments:
    --block BLOCK    block number to query
fei pcv
usage:
    ctc fei pcv  [options]

description:
    output summary of Fei PCV

examples:
    ctc fei pcv 
    ctc fei pcv --block 14000000

arguments:
    --block BLOCK    block number


usage of subcommands:
    ctc fei pcv can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc fei pcv <subcommand> -h

available subcommands:
    assets      output summary of Fei PCV assets
    deposits    output summary of Fei PCV deposits
fei pcv assets
usage:
    ctc fei pcv assets  [options]

description:
    output summary of Fei PCV assets

examples:
    ctc fei pcv assets 
    ctc fei pcv assets --block 14000000

arguments:
    --block BLOCK    block number
fei pcv deposits
usage:
    ctc fei pcv deposits  [options]

description:
    output summary of Fei PCV deposits

examples:
    ctc fei pcv deposits 
    ctc fei pcv deposits --block 14000000

arguments:
    --block BLOCK    block number
fei psms
usage:
    ctc fei psms  [options]

description:
    display recent FEI redemptions

examples:
    ctc fei psms 
    ctc fei psms --verbose

arguments:
    --time TIME      span of time to display
    --token TOKEN    filter by redemptions of a particular token
    --block BLOCK    block
    --limit LIMIT    limit number of mints/redeems shown
    --verbose, -v    display additional information
gnosis
usage:
    ctc gnosis ADDRESS [options]

description:
    print information about a gnosis safe

examples:
    ctc gnosis 0x245cc372c84b3645bf0ffe6538620b04a217988b
    ctc gnosis 0x245cc372c84b3645bf0ffe6538620b04a217988b --verbose

arguments:
    ADDRESS          address of gnosis safe
    --verbose, -v    display additional information
llama
usage:
    ctc llama 

description:
    output data from Defi Llama api

example:
    ctc llama 


usage of subcommands:
    ctc llama can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc llama <subcommand> -h

available subcommands:
    chain        output data about a chain tracked by Defi Llama
    chains       output data about chains tracked by Defi Llama
    protocol     output data about a protocol tracked by Defi Llama
    protocols    output data about protocols tracked by Defi Llama
    pool         output data about a pool tracked by Defi Llama
    pools        output data about pools tracked by Defi Llama
llama chain
usage:
    ctc llama chain CHAIN

description:
    output data about a chain tracked by Defi Llama

example:
    ctc llama chain Tezos

arguments:
    CHAIN    chain to describe
llama chains
usage:
    ctc llama chains  [options]

description:
    output data about chains tracked by Defi Llama

examples:
    ctc llama chains 
    ctc llama chains -n 50

arguments:
    -n N    number of chains to display
llama pool
usage:
    ctc llama pool POOL

description:
    output data about a pool tracked by Defi Llama

example:
    ctc llama pool 747c1d2a-c668-4682-b9f9-296708a3dd90

arguments:
    POOL    id of pool (obtain using --show-id on llama pools cmd)
llama pools
usage:
    ctc llama pools  [options]

description:
    output data about pools tracked by Defi Llama

examples:
    ctc llama pools 
    ctc llama pools --min-tvl 1000000
    ctc llama pools --stablecoin
    ctc llama pools --chain Ethereum
    ctc llama pools --min-tvl 1000000 --min-apy 10 --chain Ethereum

arguments:
    --chain CHAIN        filter pools by chain
    --project PROJECT    filter pools by project
    --stablecoin         filter pools by whether they are stablecoin-based
    --non-stablecoin     filter pools by whether they are not stablecoin-based
    --single             filter pools by whether they use a single asset
    --multi              filter pools by whether they use a multiple assets
    --min-apy MIN_APY    filter pools by minimum yield rate
    --max-apy MAX_APY    filter pools by maximum yield rate
    --min-tvl MIN_TVL    filter pools by miniumum TVL
    --max-tvl MAX_TVL    filter pools by maximum TVL
    -n N                 number of pools to display
    -v, --verbose        display additional information
    --show-id            show id of each pool in table
llama protocol
usage:
    ctc llama protocol PROTOCOL [options]

description:
    output data about a protocol tracked by Defi Llama

examples:
    ctc llama protocol Balancer
    ctc llama protocol Balancer --verbose

arguments:
    PROTOCOL         protocol to display information about
    -v, --verbose    display additional infromation
llama protocols
usage:
    ctc llama protocols  [options]

description:
    output data about protocols tracked by Defi Llama

examples:
    ctc llama protocols 
    ctc llama protocols --category Dexes
    ctc llama protocols --chain Tron

arguments:
    -v, --verbose          show additional information
    --category CATEGORY    filter protocols by category
    --chain CHAIN          filter protocols by chain
    -n N                   number of protocols to display
rari
usage:
    ctc rari [ARG] [options]

description:
    summarize fuse pool, token, or platform

examples:
    # summarize a pool
    ctc rari 8

    # summarize a token across all pools
    ctc rari 0x956f47f50a910163d8bf957cf5846d573e7f87ca

    # summarize all of Rari
    ctc rari 

arguments:
    ARG              pool index or token, omit to summarize platform
    --block BLOCK    block number


usage of subcommands:
    ctc rari can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc rari <subcommand> -h

available subcommands:
    pools    list all Rari fuse pools
rari pools
usage:
    ctc rari pools  [options]

description:
    list all Rari fuse pools

examples:
    ctc rari pools 
    ctc rari pools --verbose

arguments:
    --verbose    emit extra output
uniswap burns
usage:
    ctc uniswap burns POOL [options]

description:
    output information about pool burns

example:
    ctc uniswap burns 0xae461ca67b15dc8dc81ce7615e0320da1a9ab8d5 --blocks 14000000:14001000

arguments:
    POOL               pool address
    --blocks BLOCKS    block number range
    --export EXPORT    file path for export (.json or .csv)
    --overwrite        specify that output path can be overwritten
uniswap chart
usage:
    ctc uniswap chart POOL [options]

description:
    chart price action of uniswap pools

example:
    ctc uniswap chart 0x9928e4046d7c6513326ccea028cd3e7a91c7590a

arguments:
    POOL                     Uniswap pool address
    --timescale TIMESCALE    size of candlesticks, e.g. 1h, 1d, or 1w
    --invert                 use inverse of price
    --no-volume              hide volume data
uniswap mints
usage:
    ctc uniswap mints POOL [options]

description:
    output information about pool mints

example:
    ctc uniswap mints 0xae461ca67b15dc8dc81ce7615e0320da1a9ab8d5 --blocks 14000000:14001000

arguments:
    POOL               pool address
    --blocks BLOCKS    block number range
    --export EXPORT    file path for output (.json or .csv)
    --overwrite        specify that output path can be overwritten
uniswap pool
usage:
    ctc uniswap pool POOL [options]

description:
    summarize pool

example:
    ctc uniswap pool 0xae461ca67b15dc8dc81ce7615e0320da1a9ab8d5 --block 14000000

arguments:
    POOL               pool address
    --block BLOCK      block number range
    --depths DEPTHS    liquidity depths
uniswap swaps
usage:
    ctc uniswap swaps POOL [options]

description:
    output information about pool swaps

example:
    ctc uniswap swaps 0xae461ca67b15dc8dc81ce7615e0320da1a9ab8d5 --blocks 14000000:14001000

arguments:
    POOL               pool address
    --blocks BLOCKS    block number range
    --export EXPORT    file path for output (.json or .csv)
    --overwrite        specify that output path can be overwritten
yearn
usage:
    ctc yearn [QUERY] [options]

description:
    display summary of Yearn vaults

examples:
    ctc yearn 
    ctc yearn --min-tvl 1000000
    ctc yearn --sort TVL
    ctc yearn 0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a
    ctc yearn 0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a -v
    ctc yearn 0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a --harvests

arguments:
    QUERY                address or name of vault to show details of
    --sort SORT          vault field to sort by
    -n N                 number of vaults to display
    --min-apy MIN_APY    filter vaults by minimum APY
    --min-apr MIN_APR    filter vaults by minimum APR
    --min-tvl MIN_TVL    filter vaults by minimum TVL
    -v, --verbose        output additional information
    --harvests           show harvests when viewing individual vault


usage of subcommands:
    ctc yearn can also be used to invoke subcommands

    to view help about a specific subcommand, run:
        ctc yearn <subcommand> -h

available subcommands:
    addresses    output Yearn addresses
yearn addresses
usage:
    ctc yearn addresses  [options]

description:
    output Yearn addresses

examples:
    ctc yearn addresses 
    ctc yearn addresses -v

arguments:
    -v, --verbose    output additional addresses

Other Subcommands

Note

Click on a subcommand to view its documentation page.

usage:
    ctc <subcommand> [options]

description:
    ctc is a tool for historical data analysis of Ethereum and other EVM chains
    
    if using ctc for the first time, run:
        ctc setup
    
    for quick lookups of an address, block, tx, or timestamp, run:
        ctc QUERY
    
        where QUERY is an address, block number, tx hash, or timestamp

    to view help about a specific subcommand run:
        ctc <subcommand> -h

other subcommands:
    cd                  change working directory to ctc-related location
    help                output help
    version             print cli version
cd
usage:
    ctc cd DIRNAME

description:
    change working directory to ctc-related location

    directories:
    - code: directory where ctc code is stored
    - data: directory where ctc stores data
    - config: directory where ctc stores config

arguments:
    DIRNAME    name of directory
help
usage:
    ctc help SUBCOMMAND [options]

description:
    output help

arguments:
    SUBCOMMAND       
    -h, --help       
    --hidden         
    --reset-cache    reset help message cache
version
usage:
    ctc version  [options]

description:
    print cli version

arguments:
    -V, --version    

Useful Aliases

ctc makes it simple to perform many tasks from the command line. However, ctc can be made even more simple by using shell aliases that reduce the number of required keystrokes that must be typed. The ctc codebase includes an optional set of cli aliases for this purpose.

Such aliases make it so you do not need to type the “ctc” before a subcommand name. For example, instead of typing ctc keccak <address>, you just type keccak <address>. Instead of typing ctc 4byte <query>, you just type 4byte <query>. And so on, for many different ctc subcommands.

The ctc setup wizard can add these aliases to your shell configuation.

The Aliases

These aliases are chosen so as not to conflict with any common CLI tools.

# compute commands
alias ascii="ctc ascii"
alias hex="ctc hex"
alias keccak="ctc keccak"
alias lower="ctc lower"

# data commands
alias abi="ctc abi"
alias address="ctc address"
alias block="ctc block"
alias blocks="ctc blocks"
alias bytecode="ctc bytecode"
alias call="ctc call"
alias calls="ctc calls"
alias dex="ctc dex"
alias erc20="ctc erc20"
alias eth="ctc eth"
alias gas="ctc gas"
alias int="ctc int"
alias rlp="ctc rlp"
alias tx="ctc tx"

# protocol commands
alias 4byte="ctc 4byte"
alias aave="ctc aave"
alias cg="ctc cg"
alias chainlink="ctc chainlink"
alias curve="ctc curve"
alias es="ctc etherscan"
alias ens="ctc ens"
alias fei="ctc fei"
alias gnosis="ctc gnosis"
alias llama="ctc llama"
alias rari="ctc rari"
alias uniswap="ctc uniswap"
alias yearn="ctc yearn"

Similar CLI tools

ethereum-etl

ethereum-etl is a tool for collecting raw historical data from EVM chains, including blocks, transactions, erc20 transfers, and internal traces. Along with the rest of the blockchain-etl stack, it powers the popular BigQuery blockchain datasets. The primary use case of ethereum-etl and its associated stack is to index a significant portion of a chain’s history in preparation for large scale data analysis.

Prior to creating ctc, ethereum-etl was the primary data collection tool used by ctc’s authors. It was extensive use of ethereum-etl that inspired much of ctc’s design. Compared to ethereum-etl, ctc falls closer to the porcelain end of the plumbing-vs-porcelain spectrum, with goals such as:

  • create more diverse datasets, such as datasets that rely on eth_call

  • create more targeted datasets, such as datasets focused on specific protocols like Chainlink or Uniswap

  • create tighter integration with the python ecosystem

  • go beyond data collection by creating a data analysis toolkit that serves each stage of the data analysis lifecycle

  • implement quality-of-life improvements for the lazy

    • store and manage metadata such as addresses of tokens, oracles, and pools

    • automate tasks such as data encoding/decoding

TrueBlocks

TrueBlocks is a tool for managing optimized local indices of EVM chain data. TrueBlocks then makes these local data copies accessible through an enhanced RPC interface. TrueBlocks delivers some of the highest performance ways to query chain data and it excels at tracing and querying all appearances of a given address throughout a chain’s history. Since TrueBlocks can provide its data over RPC, it could be used as an ultra high performance RPC provider for ctc.

There’s a decent amount of overlap between ethereum-etl, TrueBlocks, and ctc. Relatively speaking, ethereum-etl is plumbing, TrueBlocks is mostly plumbing with some porcelain, and ctc is mostly porcelain with some plumbing.

ethereal, seth, and cast

ethereal (go), seth (dapptools, bash+javascript), and cast (foundry, rust) are powerful command line utilities that each perform a wide range of EVM-related tasks.

ctc has lots of overlapping functionality with each. Where they differ is their focus. These other tools are more aimed at smart contract development, whereas ctc is more aimed at data collection and analysis. Compared to these tools, ctc’s biggest disadvantage is that it is limited to read-only operations. On the other hand ctc’s biggest advantage is its treatment of historical data as a first class feature.

Basic Usage

The top-level ctc module contains functions for generic EVM operations:

Example: Generic EVM Operations

import ctc

some_hash = ctc.keccak_text('hello')

encoded_data = ctc.abi_encode_packed((400, 6000), '(int128,int128)')

eth_balance = await ctc.async_get_eth_balance('0x6b175474e89094c44da98b954eedeac495271d0f')

erc20_balance = await ctc.async_get_erc20_balance(
    token='0x6b175474e89094c44da98b954eedeac495271d0f',
    wallet='0x6b175474e89094c44da98b954eedeac495271d0f'],
    block=15000000,
)

events = await ctc.async_get_events(
    '0xcbcdf9626bc03e24f779434178a73a0b4bad62ed',
    event_name='Swap',
)

Some points to keep in mind while using ctc:

  • ctc uses functional programming. Instead of custom types or OOP, ctc uses simple standard datatypes including python builtins and numpy arrays. There is no need to initialize any objects. Simply import ctc and then call functions in the ctc.* namespace.

  • ctc is asynchronous-first, which allows it to efficiently orchestrate large numbers of interdependent queries. Special consideration is needed to run code in an asynchronous context.

  • ctc is designed with historical data analysis in mind. For any query of EVM state, ctc aims to support historical versions of that query. Most ctc query functions take parameters that can specify a block or block range relevant to the query.

The top-level ctc package covers generic EVM operations, which are described in more detail here. There are also a few other ctc subpackages that are relevant to specific use-cases described below.

RPC Client Subpackage ctc.rpc

ctc.rpc implements ctc’s custom RPC client. This client can be used for fine-grained control over RPC calls. Unless explcitly told not to do so.ctc will automatically encode requests to binary and decode requests from binary.

Example: get bytecode for contract, at specific block, using specific provider

import ctc.rpc

contract_bytecode = await ctc.rpc.async_eth_get_code(
    '0x6b175474e89094c44da98b954eedeac495271d0f',
    block_number=15000000,
    provider='https://some_rpc_node/',
)

Protocol-specific Subpackages ctc.protocols

ctc.protocols contains functions specific to many different protocols such as Chainlink or Uniswap. See a full list here.

Example: gather complete historical data for Chainlink’s RAI-USD feed

from ctc.protocols import chainlink_utils

feed_data = await chainlink_utils.async_get_feed_data('RAI_USD')

Other Subpackages

End users of ctc probably won’t need to use any of these directly.

  • ctc.cli: command line interface

  • ctc.config: configuration utilities

  • ctc.db: local cache database

  • ctc.spec: ctc specifications, mainly types for type annotations

  • ctc.toolbox: miscellaneous python utilities

RPC Client

ctc.rpc is a low-level asynchronous RPC client that implements the EVM JSON-RPC standard. This standard consists of many methods such as eth_call and eth_getCode that query current and historical states of an EVM chain.

Implementation of Methods

For every method specified by the EVM JSON-RPC standard, ctc.rpc implements five python functions:

  1. constructor function: create method requests

  2. digestor function: process method responses

  3. executor function: perform construction, dispatching, and digestion all in one step

  4. batch construct: create method requests in bulk

  5. batch execute: execute method requests in bulk

(there are no batch digestor functions because they compose naturally from the scalar digestor functions)

RPC Providers

Unless otherwise specified, requests will be sent to the default RPC provider in ctc’s config. Functions in ctc.rpc that send RPC requests also take an optional provider argument that can be used to specify other RPC providers.

For more details, see the RPC Provider section on the Data Sources page.

Typical RPC Request Lifecycle in ctc

  1. a constructor function encodes request metadata and parameters into a RpcRequest python dict

  2. the request is dispatched to an rpc provider using rpc.async_send_http()

  3. the client awaits until the rpc provider returns a response

  4. a digestor function decodes the response

For requests that execute contract code (like eth_call) or retrieve events (like eth_getLogs), ctc will encode/decode inputs/outputs using the relevant function abi’s and event abi’s.

Asynchronous Code

ctc uses async functions for network calls and database calls. This allows for high levels of concurrency and makes it easy to dispatch large numbers of complex interdependent queries.

async is an intermediate-level python topic with a bit of a learning curve. If you’ve never used async before, you should probably read a tutorial or two before trying to use it in ctc. To use async functions, they must be run from an event loop. These functions can be called from synchronous code as follows:

import asyncio

result = asyncio.run(some_async_function(input1, input2))

Inside of IPython or Jupyter notebooks, await can be used directly, without asyncio.run(). Many of the code examples in these docs assume this is the context and omit asyncio.run().

# no asyncio.run() necessary inside of IPython / Jupyter
result = await some_async_function(input1, input2)

If your code opens up network connections, you should also close those connections at the end of your script. For example:

from ctc import rpc

await rpc.async_close_http_session()

Datatypes

ctc has functions for collecting and analyzing many different EVM datatypes

Datatype

Examples

Reference

ABIs

Examples

Reference

Addresses

Examples

Reference

Binary

Examples

Reference

Blocks

Examples

Reference

ERC20s

Examples

Reference

ETH

Examples

Reference

Events

Examples

Reference

Transactions

Examples

Reference

ABIs

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

abis
Reference
async ctc.evm.async_decompile_function_abis(bytecode, sort=None)

decompile solidity-style function ABI’s from contract bytecode

Return type

Sequence[Mapping[str, Any]]

async ctc.evm.async_get_contract_abi(contract_address, *, network=None, provider=None, use_db=True, db_query=None, db_intake=None, block=None, proxy_implementation=None, verbose=True)

retrieve abi of contract either from local database or block explorer

for addresses that change ABI’s over time, use db_query=False to skip cache

async ctc.evm.async_get_event_abi(*, contract_abi=None, contract_address=None, event_name=None, event_hash=None, event_abi=None, network=None)

get event ABI from local database or block explorer

async ctc.evm.async_get_function_abi(*, function_name=None, contract_abi=None, contract_address=None, n_parameters=None, parameter_types=None, function_selector=None, network=None)

get function ABI from local database or block explorer

ctc.binary.get_event_hash ctc.binary.get_event_indexed_names ctc.binary.get_event_indexed_types ctc.binary.get_event_signature ctc.binary.get_event_unindexed_names ctc.binary.get_event_unindexed_types ctc.binary.get_function_output_names ctc.binary.get_function_output_types ctc.binary.get_function_parameter_names ctc.binary.get_function_parameter_types ctc.binary.get_function_selector ctc.binary.get_function_signature

Contracts

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

addresses
Reference
async ctc.evm.async_get_contract_creation_block(contract_address, *, provider=None, use_db=True, **search_kwargs)

get block number of when contract was created

  • behavior is undefined for functions that have undergone SELF-DESTRUCT(S)

  • caches result in local database

Binary Data

Note

By default ctc will perform end-to-end encoding/decoding of many operations. The low-level functions listed here are only needed if you need to work directly with raw binary data.

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

binary_data
Reference

[none]

.. autofunction:: ctc.binary.convert .. autofunction:: ctc.binary.decode_call_data .. autofunction:: ctc.binary.decode_function_output .. autofunction:: ctc.binary.decode_types .. autofunction:: ctc.binary.encode_call_data .. autofunction:: ctc.binary.encode_types .. autofunction:: ctc.binary.keccak .. autofunction:: ctc.binary.keccak_text


Blocks

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

blocks
Reference
async ctc.evm.async_get_block(block, *, include_full_transactions=False, provider=None, use_db=True)

get block from local database or from RPC node

async ctc.evm.async_get_block_of_timestamp(timestamp, *, nary=None, cache=None, block_timestamps=None, block_timestamp_array=None, block_number_array=None, verbose=False, provider=None, use_db=True, use_db_assist=True, mode='>=')

search for the block that corresponds to a given timestamp

async ctc.evm.async_get_blocks(blocks, *, include_full_transactions=False, chunk_size=500, provider=None, use_db=True, latest_block_number=None)

get blocks from local database or from RPC node

async ctc.evm.async_get_blocks_of_timestamps(timestamps, *, block_timestamps=None, block_number_array=None, block_timestamp_array=None, nary=None, cache=None, provider=None, use_db=True, mode='>=')

search for blocks corresponding to list of timestamps

ERC20s

Note

functions that require multiple RPC calls will attempt to do so concurrently for maximum efficiency

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

erc20s
Reference
async ctc.evm.async_get_erc20_balance(wallet, token, *, block=None, normalize=True, provider=None, **rpc_kwargs)

get ERC20 balance

async ctc.evm.async_get_erc20_balances_of_addresses(wallets, token, *, block=None, normalize=True, provider=None, **rpc_kwargs)

get ERC20 balance of multiple addresses

async ctc.evm.async_get_erc20_balance_by_block(wallet, token, *, blocks, normalize=True, provider=None, empty_token=0, **rpc_kwargs)

get historical ERC20 balance over multiple blocks

async ctc.evm.async_get_erc20_decimals(token, *, block=None, use_db=True, provider=None, **rpc_kwargs)

get decimals of an erc20

async ctc.evm.async_get_erc20_balances_from_transfers(transfers, *, block=None, dtype=None, normalize=False)

compute ERC20 balance of each wallet using Transfer events

async ctc.evm.async_get_erc20_name(token, *, block=None, use_db=True, provider=None, **rpc_kwargs)

get name of an erc20

async ctc.evm.async_get_erc20_symbol(token, *, block=None, use_db=True, provider=None, **rpc_kwargs)

get symbol of an erc20

async ctc.evm.async_get_erc20_total_supply(token, *, block=None, normalize=True, provider=None, **rpc_kwargs)

get total supply of ERC20

async ctc.evm.async_get_erc20_total_supply_by_block(token, blocks, *, normalize=True, provider=None, **rpc_kwargs)

get historical total supply of ERC20 across multiple blocks

async ctc.evm.async_get_erc20_transfers(token, *, start_block=None, end_block=None, start_time=None, end_time=None, include_timestamps=False, normalize=True, convert_from_str=True, verbose=False, provider=None, **event_kwargs)

get transfer events of ERC20 token

async ctc.evm.async_get_erc20s_balances(wallet, tokens, *, block=None, normalize=True, provider=None, **rpc_kwargs)

get ERC20 balance of wallet for multiple tokens

async ctc.evm.async_get_erc20s_decimals(tokens, *, block=None, **rpc_kwargs)

get decimals of multiple erc20s

async ctc.evm.async_get_erc20s_names(tokens, block=None, **rpc_kwargs)

get name of multiple erc20s

async ctc.evm.async_get_erc20s_symbols(tokens, *, block=None, **rpc_kwargs)

get symbol of multiple erc20s

async ctc.evm.async_get_erc20s_total_supplies(tokens, *, block=None, normalize=True, provider=None, **rpc_kwargs)

get total supplies of ERC20s

async ctc.evm.async_normalize_erc20_quantities(quantities, token=None, *, provider=None, decimals=None, block=None)

normalize ERC20 quantites by adjusting radix by (10 ** decimals)

async ctc.evm.async_normalize_erc20_quantity(quantity, token=None, *, provider=None, decimals=None, block=None)

convert raw erc20 quantity by adjusting radix by (10 ** decimals)

ETH Balances

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

eth_balances
Reference

Events

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

events
Reference
async ctc.evm.async_get_events(contract_address, *, start_block=None, end_block=None, start_time=None, end_time=None, include_timestamps=False, backend_order=None, keep_multiindex=True, verbose=True, provider=None, **query)

get events matching given inputs

Transactions

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

transactions
Reference
async ctc.evm.async_get_transaction(transaction_hash)

get transaction

async ctc.evm.async_get_transaction_count(address)

get transaction count of address

Specific Protocols

ctc has functions for collecting and analyzing data from many on-chain and off-chain sources

4byte

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

4byte
Reference
async ctc.protocols.fourbyte_utils.async_build_event_signatures_dataset(signature_data=None)
Return type

None

async ctc.protocols.fourbyte_utils.async_build_function_signatures_dataset(signature_data=None)
Return type

None

async ctc.protocols.fourbyte_utils.async_query_event_signatures(hex_signature=None, *, id=None, bytes_signature=None, text_signature=None, use_local=True, use_remote=True)
Return type

Sequence[Entry]

async ctc.protocols.fourbyte_utils.async_query_function_signatures(hex_signature=None, *, id=None, bytes_signature=None, text_signature=None, use_local=True, use_remote=True)
Return type

Sequence[Entry]

Aave V2

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

aave_v2
Reference
async ctc.protocols.aave_v2_utils.async_get_deposits(*, start_block=None, end_block=None, start_time=None, end_time=None, include_timestamps=False, provider=None)
async ctc.protocols.aave_v2_utils.async_get_interest_rates(*, token=None, block=None, reserve_data=None)
async ctc.protocols.aave_v2_utils.async_get_interest_rates_by_block(token, blocks, *, reserve_data_by_block=None)
async ctc.protocols.aave_v2_utils.async_get_reserve_data(asset, block=None, *, provider=None)
async ctc.protocols.aave_v2_utils.async_get_reserve_data_by_block(asset, blocks, *, provider=None)
async ctc.protocols.aave_v2_utils.async_get_underlying_asset(pool_token, provider=None)
async ctc.protocols.aave_v2_utils.async_get_withdrawals(*, start_block=None, end_block=None, start_time=None, end_time=None, include_timestamps=False, provider=None)

Balancer

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

balancer
Reference
async ctc.protocols.balancer_utils.async_get_pool_address(pool_id, block=None)
async ctc.protocols.balancer_utils.async_get_pool_balances(*, pool_address=None, pool_id=None, block=None, vault=None, normalize=True, provider=None)
async ctc.protocols.balancer_utils.async_get_pool_fees(pool_address, *, block='latest', normalize=True)
async ctc.protocols.balancer_utils.async_get_pool_id(pool_address, block=None, *, provider=None)
async ctc.protocols.balancer_utils.async_get_pool_swaps(pool_address=None, *, start_block=None, end_block=None, start_time=None, end_time=None, include_timestamps=False)
async ctc.protocols.balancer_utils.async_get_pool_tokens(*, pool_address=None, pool_id=None, block=None)
async ctc.protocols.balancer_utils.async_get_pool_weights(pool_address, block='latest', *, normalize=True)
async ctc.protocols.balancer_utils.async_get_pool_weights_by_block(pool_address, blocks, *, normalize=True)
async ctc.protocols.balancer_utils.async_summarize_pool_state(pool_address, block='latest')

Compound

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

compound
Reference
async ctc.protocols.compound_utils.async_get_borrow_apy(ctoken, block=None)
async ctc.protocols.compound_utils.async_get_borrow_apy_by_block(ctoken, blocks)
async ctc.protocols.compound_utils.async_get_supply_apy(ctoken, block=None)
async ctc.protocols.compound_utils.async_get_supply_apy_by_block(ctoken, blocks)

Gnosis Safe

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

coingecko

Curve

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

curve
Reference
async ctc.protocols.curve_utils.async_get_base_pools(*, start_block=None, end_block=None, start_time=None, end_time=None, factory=None, provider=None, verbose=False)
async ctc.protocols.curve_utils.async_get_meta_pools(*, start_block=None, end_block=None, start_time=None, end_time=None, factory=None, provider=None, verbose=False)
async ctc.protocols.curve_utils.async_get_plain_pools(*, factory=None, start_block=None, end_block=None, start_time=None, end_time=None, provider=None, verbose=False)
async ctc.protocols.curve_utils.async_get_pool_metadata(pool, *, n_tokens=None, provider=None)
async ctc.protocols.curve_utils.async_get_pool_state(pool, *, n_tokens=None, block=None, provider=None, normalize=True)
async ctc.protocols.curve_utils.async_get_virtual_price(pool, *, provider=None, block=None)

Gnosis Safe

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

etherscan

ENS

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

ens
Reference
async ctc.protocols.ens_utils.async_get_expiration(name)
Return type

int

async ctc.protocols.ens_utils.async_get_owner(name, *, provider=None, block=None)
async ctc.protocols.ens_utils.async_get_registration_block(name)
Return type

int

async ctc.protocols.ens_utils.async_get_registrations()
async ctc.protocols.ens_utils.async_get_text_records(*, name=None, node=None, keys=None)

https://docs.ens.domains/ens-improvement-proposals/ensip-5-text-records

Return type

dict[str, str]

async ctc.protocols.ens_utils.async_record_exists(name, *, provider=None, block=None)
async ctc.protocols.ens_utils.async_reverse_lookup(address, *, provider=None, block=None)
ctc.protocols.ens_utils.hash_name(name)

Fei

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

fei
Reference
async ctc.protocols.fei_utils.async_create_payload(*, blocks=None, timestamps=None, timescale=None, end_time=None, window_size=None, interval_size=None, provider=None)

create data payload from scratch

async ctc.protocols.fei_utils.async_get_pcv_stats(block=None, *, wrapper=False, provider=None)
async ctc.protocols.fei_utils.async_get_pcv_stats_by_block(blocks, *, wrapper=False, provider=None, nullify_invalid=True)
async ctc.protocols.fei_utils.async_print_pcv_assets(block=None)
async ctc.protocols.fei_utils.async_print_pcv_deposits(block=None)

Gnosis Safe

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

gnosis_safe

Defi Llama

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

llama

Multicall

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

multicall

Rari

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

rari
Reference
async ctc.protocols.rari_utils.async_get_all_pools(block=None, provider=None)
async ctc.protocols.rari_utils.async_get_ctoken_state(ctoken, *, block='latest', metrics=None, eth_price=None, in_usd=True)
async ctc.protocols.rari_utils.async_get_ctoken_state_by_block(ctoken, blocks, *, metrics=None, eth_price=None, in_usd=True)
async ctc.protocols.rari_utils.async_get_pool_ctokens(comptroller, *, block='latest')
async ctc.protocols.rari_utils.async_get_pool_prices(*, oracle=None, ctokens=None, comptroller=None, block='latest', to_usd=True)
async ctc.protocols.rari_utils.async_get_pool_tvl_and_tvb(*, comptroller=None, ctokens=None, oracle=None, block='latest')
async ctc.protocols.rari_utils.async_get_pool_underlying_tokens(*, ctokens=None, comptroller=None, block='latest')
async ctc.protocols.rari_utils.async_get_token_multipool_stats(token, block='latest', *, in_usd=True)
async ctc.protocols.rari_utils.async_print_all_pool_summary(block='latest', n_display=15)
async ctc.protocols.rari_utils.async_print_fuse_token_summary(token, *, block='latest', in_usd=True)

Uniswap V2

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

uniswap_v2
Reference
async ctc.protocols.uniswap_v2_utils.async_get_pool_burns(pool_address, *, start_block=None, end_block=None, start_time=None, end_time=None, include_timestamps=False, replace_symbols=False, normalize=True, provider=None, verbose=False)
async ctc.protocols.uniswap_v2_utils.async_get_pool_decimals(pool=None, *, x_address=None, y_address=None, provider=None)
async ctc.protocols.uniswap_v2_utils.async_get_pool_mints(pool_address, *, start_block=None, end_block=None, start_time=None, end_time=None, include_timestamps=False, replace_symbols=False, normalize=True, provider=None, verbose=False)
async ctc.protocols.uniswap_v2_utils.async_get_pool_state(pool, *, block=None, provider=None, normalize=True, fill_empty=True)
async ctc.protocols.uniswap_v2_utils.async_get_pool_state_by_block(pool, *, blocks, provider=None, normalize=True)
async ctc.protocols.uniswap_v2_utils.async_get_pool_swaps(pool, *, start_block=None, end_block=None, start_time=None, end_time=None, include_timestamps=False, include_prices=False, include_volumes=False, label='index', normalize=True, provider=None, verbose=False)
async ctc.protocols.uniswap_v2_utils.async_get_pool_symbols(pool=None, *, x_address=None, y_address=None, provider=None)
async ctc.protocols.uniswap_v2_utils.async_get_pool_tokens(pool, provider=None)

Uniswap V3

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

uniswap_v3
Reference
async ctc.protocols.uniswap_v3_utils.async_get_pool_metadata(pool_address, **rpc_kwargs)
async ctc.protocols.uniswap_v3_utils.async_get_pool_swaps(pool_address, *, start_block=None, end_block=None, start_time=None, end_time=None, include_timestamps=False, replace_symbols=False, normalize=True)
async ctc.protocols.uniswap_v3_utils.async_quote_exact_input_single(token_in, token_out, *, fee, amount_in, sqrt_price_limit_x96=0, provider=None, block=None)
async ctc.protocols.uniswap_v3_utils.async_quote_exact_output_single(token_in, token_out, *, fee, amount_out, sqrt_price_limit_x96=0, provider=None, block=None)

Yearn

Examples

Note

These examples are crafted as a Jupyter notebook. You can download the original notebook file here.

Also note that inside Jupyter notebooks, await can be used freely outside of asyncio.run().

yearn

On-chain Protocols

Protocol

Examples

Reference

Source

Aave V2

Examples

Reference

Source

Balancer

Examples

Reference

Source

Chainlink

Examples

Reference

Source

Compound

Examples

Reference

Source

Curve

Examples

Reference

Source

ENS

Examples

Reference

Source

Fei

Examples

Reference

Source

Gnosis Safe

Examples

Reference

Source

Multicall

Examples

Reference

Source

Rari

Examples

Reference

Source

Uniswap V2

Examples

Reference

Source

Uniswap V3

Examples

Reference

Source

Yearn

Examples

Reference

Source

External Data Sources

Protocol

Examples

Reference

Source

4byte

Examples

Reference

Source

Coingecko

Examples

Reference

Source

Defi Llama

Examples

Reference

Source

Etherscan

Examples

Reference

Source

Similar Python Tools

web3.py

web3.py is a general purpose EVM library that is created and maintained by the Ethereum Foundation. Although web3.py and ctc have some overlapping functionality, they focus on different things. Web3.py supports full wallet functionality, whereas ctc is currently limited to read-only operations. Web3.py also supports a greater variety of communication protocols including websockets.

On the other hand, ctc is primarily aimed at historical data analysis. It contains more functions for aggregating historical datasets from various on-chain protocols. Additionally, web3.py is primarily synchronous, whereas ctc is primarily asynchronous.

ape

ape is another general purpose EVM library that aims to improve upon web3.py in a variety of areas. Ape features direct integrations with many tools for both the development and deployment of smart contracts. Ape has plugins for many popular languages and tools including vyper, solidity, foundry, and hardhat.

ethtx

ethtx is a library for decoding and summarizing individual transactions. You can see it in action at https://ethtx.info/. Although ctc has its own transaction summarizing capabilities, it is currently much more limited than ethtx when it comes to tracing internal transactions and revealing the resultant state changes. These types of features may come to ctc in a future release.