Package: checkthechain
⛓🔍 Check the Chain (ctc) 🔎⛓ctcis a tool for collecting and analyzing data from Ethereum and other EVM chainsIt can be used as either 1) a python package or 2) a cli toolctcis in beta, please report bugs to the issue trackerFeaturesdata collection: collects data from archive nodes robustly and efficientlydata storage: stores collected data on disk so that it only needs to be collected oncedata coding: handles data encoding and decoding automatically by defaultdata analysis: computes derived metrics and other quantitative data summariesdata visualization: plots data to maximize data interpretabilityprotocol specificity: includes functionality for protocols like Chainlink, Uniswap, ERC20, and morecommand line interface: performs many block explorer tasks in the terminalFor detailed information check outthe documentationContentsExample UsageERC20: get all token transfers and balances of an ERC20Uniswap: get swaps, mints, and burns of a Uniswap pairChainlink: get historical data for a Chainlink feedDAO: get DAO proposals and votesInstallationFAQSimilar Projects📜 Legal Disclaimer 📜ctcis available under either the MIT license or the Apache license at your option. As stated in both licenses,ctccomes with no warranty of any kind. The authors ofctcaccept no responsibility for any damages or negative outcomes that result from usingctcorctc-derived data.ctcis not audited and using it as a basis for making financial decisions is not recommended.Example Usagefor more examples see examples inthe docsGet all token transfers of an ERC20# pythonfromctcimportevm# get token transferstransfers=awaitevm.async_get_erc20_transfers(token='0x956f47f50a910163d8bf957cf5846d573e7f87ca',event_name='Transfer',)# get holdings of each address for a given blockholdings=awaitevm.async_get_erc20_balances_from_transfers(transfers=transfers,block=12345789)# bashctcerc20transfers0x956f47f50a910163d8bf957cf5846d573e7f87ca\--exporttransfers.csv

ctcerc20balances0x956f47f50a910163d8bf957cf5846d573e7f87ca\--exportbalances.csv\--block12345789Get DAO proposals and votes# pythonfromctcimportevmdao_address='0x0bef27feb58e857046d630b2c03dfb7bae567494'proposals=awaitevm.async_get_events(contract_address=dao_address,event_name='ProposalCreated',)votes=awaitevm.async_get_events(contract_address=dao_address,event_name='VoteCast',include_timestamps=True,)# bashDAO="0x0bef27feb58e857046d630b2c03dfb7bae567494"ctcevents$DAOProposalCreated--exportproposals.csv
ctcevents$DAOVoteCast--exportvotes.csvGet historical data for a Chainlink feed# pythonfromctc.protocolsimportchainlink_utilsfeed='0x31e0a88fecb6ec0a411dbe0e9e76391498296ee9'data=awaitchainlink_utils.async_get_feed_data(feed)# bashctcchainlink0x31e0a88fecb6ec0a411dbe0e9e76391498296ee9--exportdata.csvGet swaps, mints, and burns of a Uniswap pool# pythonfromctc.protocolsimportuniswap_v2_utilspool='0x94b0a3d511b6ecdb17ebf877278ab030acb0a878'swaps=awaituniswap_v2_utils.async_get_pool_swaps(pool)mints=awaituniswap_v2_utils.async_get_pool_mints(pool)burns=awaituniswap_v2_utils.async_get_pool_burns(pool)# bashPOOL="0x94b0a3d511b6ecdb17ebf877278ab030acb0a878"ctcuniswapswaps$POOL--exportswaps.csv
ctcuniswapmints$POOL--exportmints.csv
ctcuniswapburns$POOL--exportburns.csvInstallationTwo steps:pip install checkthechainrunctc setupin terminal to specify data provider and data storage pathIf your shell'sPATHdoes not include python scripts you may need to do something likepython3 -m pip ...andpython3 -m ctc ...Detailed instructions can be found in theinstallation documentation.ctcrequires python >= 3.7 (supports3.7,3.8,3.9,3.10, and3.11).FAQWhat are the goals ofctc?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: Withctcmost 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 useasync?asyncis a natural fit for efficiently querying large amounts of data from an archive node. Allctcfunctions that fetch external data useasync. For tips on usingasyncseethis sectionin 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 eitherrun one yourselfor use a third-party provider such asAlchemy,Quicknode, orMoralis. You can also usectcto query current (non-historical) data using a non-archive node.Isctcuseful for recent, non-historical data?Yes,ctchas lots of functionality for querying the current state of the chain.Similar Projectsethereum-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