Blocktime Service: Use Calendar Dates to Get Block Numbers

Substreams By Oct 02, 2023 No Comments

Stop wasting time looking for block numbers on block explorers. Instead, use Pinax’s new Blocktime service.

Follow along with Étienne, an analytics developer at Pinax, as he showcases Blocktime, a revolutionary service that allows you to retrieve data using specific dates rather than block numbers.

Thanks to Substreams technology, you can get the information you need from the blockchain using dates and timestamps.

What is Blocktime?

To use a Substream or any Substream-related technology, you have to input a block range. For example, start at this block and end at this block. The challenge is that you can’t query historical data more intuitively using dates.

This is where Pinax’s Blocktime can help. It translates a block number into a timestamp (and vice versa).

How does it work?

The Blocktime service allows you to get a block number from a timestamp or partial date. So if you query a start date and (an optional) end date, you will get the block numbers associated with that date range.

The service uses a key-value (kv) store, and to populate that store with the data you want, you use Substreams sink kv, developed by the StreamingFast team. 

You can use any compatible database for your kv store. This demo uses BadgerDB, but you could also use Zigbee or Redis, for example.

Watch the video above to see the full process.

How can you use it?

Use Blocktime instead of hunting through a block explorer to find where a date starts in the chain.

You can also use Blocktime as a template to build your own services with Substreams.

Explore the GitHub repository to use it as a starting point for customizing your own service and building your own kv service with Substreams.

Author

We're a web3 service provider specializing in blockchain indexing operations. Our mission is to enable creators to achieve their true potential with web3 technology. We want to help developers reliably access blockchain data in a consistent format so you can create amazing experiences for your applications.

No Comments

Leave a comment

Your email address will not be published. Required fields are marked *