Step 2 - Getting Data

We’re finally able to get some data from the chain. But are we? Let’s find out.

Run this command:

chifra

TrueBlocks is a collection of command line tools. Notice the two groups: Chain Data and Chain State. Similar to the RPC, these tools pull data directly from the node. With a few improvements…

Getting data

Try any of these commands:

chifra blocks 2001007
chifra transactions --fmt json 0xc9c5f47ed17445070a68fab0c5336f39e6a70a74c67c8fce2a586b5f6596b3fb
chifra receipts --fmt json 4001009.32
chifra logs --fmt json 0xc9c5f47ed17445070a68fab0c5336f39e6a70a74c67c8fce2a586b5f6596b3fb
chifra traces --fmt json 0xc9c5f47ed17445070a68fab0c5336f39e6a70a74c67c8fce2a586b5f6596b3fb

They bring straight, raw PRC data from the node. Try adding --cache to each of the above commands? What happens? Did it get faster? Why?


[Talk about the RPC endpoint]


Let’s try something a bit more complicated:

chifra receipts 2010732.\* --fmt csv

This is every receipt (or log, or transaction, or trace if you have a tracing node) in the given block.

Getting rate limited

How about a block with a lot of transacitons? Try this:

chifra blocks 4100000 --uniq --cache --cache_txs --cache_traces

[Talk about the Unchained Index] The Unchained Index


Important: If you get rate limited, don’t run the command again. They may cut you off permenantly.

Did you get rate limited? We didn’t.

Lesson

Decentralizing your data source brings a number of massive upsides to you.

  1. There is no arbitrary rate limit to the data. You’re not sharing.
  2. The API provider cannot be spying on you. There is no API provider.
  3. With greater speed, comes greater insight into what’s going on.

No matter what Web 2.0 API providers do, they MUST rate limit you. If they didn’t, they would be swamped with requests. Plus – price. Plus – privacy. Why wait?

Yeah. But I really want an API

Every chifra command is available through a local API server. Try this:

In one window:

chifra serve

In another window:

curl "http://localhost:8080/blocks?blocks=2001007"

Getting names / abis / dates

Chifra provides a lot other very useful tools. Check them out.

chifra names
chifra names vitalik.eth
chifra names unchainedindex.eth
chifra when 2001001                                                       # by block
<!-- chifra when 1664656944                                                    # by timestmap
chifra when 2022-10-01T20:42:24                                           # by date -->
chifra when 2000000-4000000:weekly                                        # time period ranges
chifra abis --chain mainnet 0x6b175474e89094c44da98b954eedeac495271d0f    # requires an Etherscan key

What’s next?

In the next step, Step 3 - Getting Details we’re going to look a bit deeper.


« Prev | Next » | Home

Edit this page on GitHub