ctc is a tool for collecting and processing historical EVM data
Project description
⛓🔍 Check the Chain (ctc) 🔎⛓
ctc is a tool for collecting and analyzing data from Ethereum and other EVM chains
It can be used as either 1) a python package or 2) a cli tool
ctc is in beta, please report bugs to the issue tracker
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
- protocol specificity: includes functionality for protocols like Chainlink, Uniswap, ERC20, and more
- command line interface: performs many block explorer tasks in the terminal
For detailed information check out the documentation
Contents
📜 Legal Disclaimer 📜 ctc is available under either the MIT license or the Apache license at your option. As stated in both licenses, ctc comes with no warranty of any kind. The authors of ctc accept no responsibility for any damages or negative outcomes that result from using ctc or ctc-derived data. ctc is not audited and using it as a basis for making financial decisions is not recommended.
|
Example Usage
for more examples see examples in the docs
Get all token transfers of an ERC20
# python
from ctc import evm
# get token transfers
transfers = await evm.async_get_erc20_transfers(
token='0x956f47f50a910163d8bf957cf5846d573e7f87ca',
event_name='Transfer',
)
# get holdings of each address for a given block
holdings = await evm.async_get_erc20_balances_from_transfers(transfers=transfers, block=12345789)
# bash
ctc erc20 transfers 0x956f47f50a910163d8bf957cf5846d573e7f87ca \
--export transfers.csv
ctc erc20 balances 0x956f47f50a910163d8bf957cf5846d573e7f87ca \
--export balances.csv \
--block 12345789
Get DAO proposals and votes
# python
from ctc import evm
dao_address = '0x0bef27feb58e857046d630b2c03dfb7bae567494'
proposals = await evm.async_get_events(
contract_address=dao_address,
event_name='ProposalCreated',
)
votes = await evm.async_get_events(
contract_address=dao_address,
event_name='VoteCast',
include_timestamps=True,
)
# bash
DAO="0x0bef27feb58e857046d630b2c03dfb7bae567494"
ctc events $DAO ProposalCreated --export proposals.csv
ctc events $DAO VoteCast --export votes.csv
Get historical data for a Chainlink feed
# python
from ctc.protocols import chainlink_utils
feed = '0x31e0a88fecb6ec0a411dbe0e9e76391498296ee9'
data = await chainlink_utils.async_get_feed_data(feed)
# bash
ctc chainlink 0x31e0a88fecb6ec0a411dbe0e9e76391498296ee9 --export data.csv
Get swaps, mints, and burns of a Uniswap pool
# python
from ctc.protocols import uniswap_v2_utils
pool = '0x94b0a3d511b6ecdb17ebf877278ab030acb0a878'
swaps = await uniswap_v2_utils.async_get_pool_swaps(pool)
mints = await uniswap_v2_utils.async_get_pool_mints(pool)
burns = await uniswap_v2_utils.async_get_pool_burns(pool)
# bash
POOL="0x94b0a3d511b6ecdb17ebf877278ab030acb0a878"
ctc uniswap swaps $POOL --export swaps.csv
ctc uniswap mints $POOL --export mints.csv
ctc uniswap burns $POOL --export burns.csv
Installation
Two steps:
pip install checkthechain- run
ctc setupin terminal to specify data provider and data storage path
If your shell's PATH does not include python scripts you may need to do something like python3 -m pip ... and python3 -m ctc ...
Detailed instructions can be found in the installation documentation.
ctc requires python >= 3.7 (supports 3.7, 3.8, 3.9, 3.10, and 3.11).
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
ctcmost 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.
ctcaims to lower the barrier to entry on all fronts.
- Why use
async?asyncis a natural fit for efficiently querying large amounts of data from an archive node. Allctcfunctions that fetch external data useasync. For tips on usingasyncsee this section in the docs. Future versions ofctcwill 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
ctcto query current (non-historical) data using a non-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
- Is
ctcuseful for recent, non-historical data?- Yes,
ctchas lots of functionality for querying the current state of the chain.
- Yes,
Similar Projects
ethereum-etlETL tools for bulk data gathering in pythonTrueblocksoptimized EVM local indexing enginecastcli EVM swiss army knife (rust)sethcli EVM swiss army knife (bash / js)etherealcli EVM swiss army knife (go)web3.pyofficial Ethereum python clientapegeneral python framework for many tasks including smart contract devethtx.infoEVM transaction trace visualizer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file checkthechain-0.3.9.tar.gz.
File metadata
- Download URL: checkthechain-0.3.9.tar.gz
- Upload date:
- Size: 573.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.30.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cff46dcf8a42b51c9624c526b1bca31246780b3693169cc2497eff7e170a83f7
|
|
| MD5 |
fe7c2282b6255d555cc1ace68623bcad
|
|
| BLAKE2b-256 |
6979951a61322020978df9a2ec6d894657d11892785a02854b98094db859d0cc
|
File details
Details for the file checkthechain-0.3.9-py3-none-any.whl.
File metadata
- Download URL: checkthechain-0.3.9-py3-none-any.whl
- Upload date:
- Size: 687.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.30.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40d1c8fabdf41afc6804d8d26af6eba7708c6eacf69a6b90ee32e6ab7609cdb0
|
|
| MD5 |
accf8b8e52494cb051cae386ca82acab
|
|
| BLAKE2b-256 |
0270e9cf93eea6dde689acdc99c9bb0bb5a1e0219ef8c3943e67627b7e95c8dc
|