cryo
is about to become your new best friend. This guide is designed to walk you through what cryo
is, how it works, and how to harness its power to fetch blockchain data quickly.
At its core, cryo
is a command-line interface (CLI) tool, but don’t let the simplicity of its interface fool you. This tool packs a powerful punch, making an easy and flexible way to extract blockchain data into various user-friendly formats. Whether you need your data in Parquet, CSV, JSON, or piped directly into a Python data frame, cryo
has got you covered.
So, whether you’re planning to build complex applications, conduct in-depth research, or satisfy your curiosity about blockchain operations, cryo
will make the process simple and fast. Today, let’s learn how to use cryo
coupled with a high-performance Chainstack Global Node.
cryo
workscryo
, explaining its data extraction process, how it handles data schemas and formatting, and the range of blockchain networks it supports.
cryo
’s primary tool is the JSON-RPC protocol, a widely used standard that allows for communication with a blockchain node.
When you run a cryo
command, it sends out JSON-RPC requests to a blockchain node. These requests ask for specific pieces of data like blocks, transactions, or logs. The node responds with raw data, which cryo
then meticulously processes. It’s not just about fetching data; cryo
transforms this data into structured and readable formats like CSV, JSON, or Parquet files. This transformation makes it incredibly straightforward to use this data in various applications or analyses.
cryo
are standout features, largely attributed to its development in Rust. Renowned for its performance and memory safety, Rust enables cryo
to handle blockchain data with exceptional speed and efficiency. This results in rapid data processing, even when dealing with the large datasets typical in blockchain networks. Rust’s prowess in concurrency further amplifies cryo's
ability to manage multiple data extraction tasks simultaneously, ensuring swift and smooth operation. In short, cryo
leverages Rust’s strengths to offer a fast, reliable, and efficient data extraction experience.
cryo
is built to navigate this diversity. It’s compatible with various blockchain networks, making it a versatile tool for users interested in different ecosystems.
Primarily, cryo
is compatible with Ethereum and supports EVM-based networks. This wide range of compatibility is possible because cryo
utilizes ethers.rs for JSON-RPC requests, allowing it to interact with any chain compatible with ethers-rs. This versatility makes cryo
a valuable asset, whether you’re getting into the bustling world of Ethereum or exploring the unique landscapes of its various Layer 2 solutions and sidechains.
cryo
up and running involves a few straightforward steps. This section will guide you through the prerequisites, the installation process, and setting up essential environment variables. We’ll also set up a Chainstack global endpoint.
cryo
ensure that your system meets the following requirements:
cryo
is built in Rust, so you must install Rust on your machine. If you haven’t installed Rust, you can do so via rustup, the recommended way to install the Rust programming language.cryo
can be installed either directly from the source or via crates.io
. Here’s how you can do it:
Method 1: Install from source
cryo
repository:
cryo
directory:
cryo
using Cargo:
cryo
cryo
begins with understanding its basic and help commands and the variety of data types it can extract. This section will cover the foundational aspects of using cryo
, including the essential commands and options that make it a versatile tool for blockchain data extraction.
cryo
offers several commands to help you navigate its functionalities:
cryo help
: This is your go-to command for any assistance. It provides an overview of all available commands and options in cryo
. Whenever in doubt, just type cryo help
in your terminal.cryo help syntax
: Blockchain data queries can sometimes get complex. The cryo help syntax
command is designed to help you understand how to effectively specify block ranges, transaction hashes, and other query parameters.cryo help datasets
: This command displays all the available datasets that cryo
can extract. Datasets include blocks
, transactions
, logs
, and many others, each serving a specific type of data extraction.cryo help DATASET(S)
: Use this command for detailed information about a specific dataset. It helps you understand the nuances of each dataset, what data it includes, and how it can be used. For instance, if you want to know more about the logs
dataset, you should use cryo help logs
.cryo
can extract various types of blockchain data, each with its own set of applicable options:
cryo
provides a range of options:
-include-columns
: Specify which columns to include in your output. For instance, if you’re only interested in certain aspects of a transaction, like gas prices and transaction hashes, this option allows you to focus on just those columns.-exclude-columns
: Conversely, if there are columns you want to omit from your output, this option lets you exclude them, streamlining your dataset.-blocks
: A crucial option for specifying the range of blocks you are interested in. You can define a single block, a range, or multiple ranges.-contract
: This option lets you specify a particular contract address when dealing with log-related data.cryo
also includes various other options for output format (--csv
, --json
), sorting (--sort
), and filtering based on transaction parameters. Combining these data types and options gives you a powerful toolkit to customize your data extraction precisely to your needs.
cryo
with a custom RPCcryo
you’ll need a custom RPC (Remote Procedure Call) endpoint. This section will explain what a custom RPC endpoint is and how to use it with cryo
.
cryo
cryo
, you can use the --rpc
flag followed by the URL of your RPC endpoint or add it as an environment variable. Here’s how to do it:
cryo
command, add the -rpc
flag followed by your custom RPC URL. For example:
ETH_RPC_URL
by running this in the console:
--rpc
flag when running a command.cryo
and you can fine-tune the requests.
cryo
commands to work with blocks.
--dry
flag in cryo
is useful for previewing the structure and content of the data you plan to extract without actually executing the data extraction.
Using the --dry
command with cryo provides a snapshot of the parameters, source details, output configuration, and the data schema for the requested dataset. This feature is highly beneficial for confirming the data fields and format before running a full data extraction process. It helps in understanding the range of data (like block numbers and types of data points), source information (like network and RPC URL), and how the data will be output (such as the file format and chunk size). This preemptive insight allows users to adjust their query parameters and output settings as needed, ensuring they get the data they need in the desired format. This is especially valuable for large-scale data operations where efficiency and precision are critical.
Run it with:
schema for blocks
displays what kind of data will be extracted.--dry
flag to actually send the requests, you’ll get an output similar to this:
cryo
cryo
simplifies the extraction of these logs, offering two primary approaches:
cryo
comes with built-in capabilities to extract standard event logs like ERC-20 and ERC-721 Transfer
events. This functionality is accessible without needing intricate parameters, significantly streamlining the process.
For example, extracting ERC-20 Transfer
events can be achieved with a straightforward command:
Transfer
events from the latest block in JSON format.Transfer
events of the APE token over a range of 500 blocks, the command would be:
Transfers
.
cryo
also allows users to extract custom event logs. This feature is useful for analyzing non-standard events or those specific to a particular smart contract.
For example, to fetch custom events, you can use the logs
dataset command with specific topics or event signatures. To extract the same Transfer
events as above using a custom approach, the command would be:
cryo
documentation.cryo
extends beyond event logs, encompassing various data types inherent to blockchain technology. Each dataset can be customized and extracted based on user-specific requirements, enabling various analysis and research possibilities. Post extraction, the data can be seamlessly integrated into different frameworks or tools for further processing and analysis, offering a comprehensive solution for blockchain data retrieval.
cryo
, a tool that stands out in blockchain data extraction. Cryo offers a seamless and efficient way to access blockchain data, from its intuitive command-line interface to its powerful Rust-based engine.
Whether you’re getting into complex application development, embarking on in-depth research, or simply exploring the blockchain landscape, cryo
proves to be an indispensable ally. Its ability to interact with various blockchain networks and its flexibility in data formatting and extraction ensures that your blockchain data needs are met with precision and ease.
Integrating cryo
with high-performance RPC endpoints like Chainstack global nodes further elevates its efficiency, providing lightning-fast data retrieval and enhanced reliability. This synergy enables you to harness the full potential of blockchain data, unlocking insights and opportunities that were previously challenging to access.