Explore the Substreams-Based Atomic API

Substreams By Jan 30, 2024 1 Comment
TL;DR: Learn how the Substreams-based Atomic API revolutionizes blockchain data management by using Substreams and database integration for efficient data processing and analysis.

Hey there, let’s dive into the world of the Substreams-based Atomic API, which is crafted on two foundational contracts: AtomicAssets and AtomicMarket. AtomicAssets is a robust standard for creating and managing NFTs on Antelope blockchains, while AtomicMarket is an integrated market smart contract for trading these NFTs.

Together, they form the backbone of this API, originally developed to replicate market volume charts similar to those on AtomicHub. Imagine having access to every collection’s daily sales numbers and amounts, all neatly laid out for you in USD or the native chain token.

Keep reading to learn how this tool helps aggregate and analyze NFT data, offering detailed insights into trading patterns and asset values within the WAX and EOS NFT marketplaces.

Unpacking the technology behind NFT analytics

First up, we’ve got Substreams, a nifty tech from StreamingFast that transforms raw on-chain data into something we can easily use. We’re working with two Substreams here because we’re dealing with two contracts.

Next is the webhook sink. This process runs the Substreams and sends the data over HTTP POST requests. Keep in mind that you’ll need a separate webhook sink for each Substream and each chain. So if you’re dealing with two chains—that’s four webhook sinks in total for both the AtomicAssets Substreams and AtomicMarket Substreams.

Overview of how Substreams-based Atomic API works

The database of choice? ClickHouse using the ClickHouse sink. Check out our blog post where we introduce ClickHouse sink and how it can simplify blockchain data analytics with efficient data extraction and processing. The ClickHouse sink does the heavy lifting of inserting the data into your ClickHouse database.

The role of Substreams

Substreams is the backbone of the Atomic API, responsible for extracting and refining data from the blockchain. Its primary function is to transform raw data into a format that is more accessible and usable. A notable feature of Substreams is adaptability as it allows you to modify data fields. This lets you break down complex information into more manageable and insightful parts.

Graph Node compatible

The Substreams uses the [graph_out] module to stream Atomic events to the ClickHouse database. This [graph_out] map module is also compatible with Graph Node to create subgraphs.

Database integration: the core of API functionality

For the Substreams-based Atomic API to operate effectively, it requires the integration of specific tables in the database. These tables store critical information from the AtomicMarket and AtomicAssets contracts. The inclusion of these tables enables users to perform comprehensive queries, including sales data, and offers the flexibility to filter results based on parameters like template IDs, which are not originally present in the AtomicMarket smart contract.

Exploring the API: a journey through endpoints and queries

The Substreams-based Atomic API is equipped with various endpoints, each serving a unique purpose. The demonstration in the video is completed on Swagger.

  1. Health endpoint ensures seamless communication between the API and the ClickHouse database.
  2. Chains endpoint provides a selection of available chains in the database.
  3. Sales endpoint allows you to query sales data with an extensive list of filters to pinpoint specific transactions.

Our practical demonstration of these endpoints shows their effectiveness in retrieving and analyzing data. For instance, filtering sales for a particular collection on the EOS chain yields precise and comprehensive results, showcasing the API’s robustness.

Aggregation and metrics: enhancing data analysis

The aggregation feature of the Substreams-based Atomic API enables you to count and analyze sales volume for each collection. This tool is instrumental in replicating market volume charts, offering a granular view of transactional data.

The metrics endpoint provides valuable insights into API usage, such as the number of queries made, errors encountered, and rows read, which helps with effective API monitoring.

Final thoughts

Substreams are revolutionizing blockchain data management. This technology is key to simplifying complex blockchain data, making it more accessible. While the Substreams-based Atomic API is a remarkable example of what can be achieved with Substreams, it is important to understand that Substreams is the core innovation and the driving force behind the integration of blockchain data into user-friendly applications.

We encourage you to explore the capabilities of Substreams further by watching the video above and check out our GitHub repo, Awesome Substreams.

Author

I am a dedicated member of the Graph Advocates DAO and proud to be a part of the Graphtronauts community. As a passionate crypto investor and enthusiast, I have delved into the world of decentralized technologies, with a strong focus on The Graph protocol. My journey includes writing insightful blogs for Graphtronauts and contributing to the development of subgraph documentation for various projects within The Graph ecosystem. Most recently, I have taken on the role of a Pinax technical writer, further expanding my commitment to advancing the adoption and understanding of blockchain and Graph-based technologies. /n https://twitter.com/PaulBarba12 https://github.com/PaulieB14 https://hey.xyz/u/paulieb https://medium.com/@paulieb.eth/about

1 Comment

  1. Andrew says:

    Very detailed, great demonstration and explanation. Gonna delve into some of those awesome substreams!

Leave a comment

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