The Queryloop
This page will explain what The Queryloop is and how you can get started.
Last updated
This page will explain what The Queryloop is and how you can get started.
Last updated
A decentralized technology called The Queryloop is used to index and search blockchain data. Data that is challenging to query directly can be queried via the Queryloop.
It is extremely challenging to read anything other than the most basic data directly from the blockchain due to projects with complicated smart contracts like Pancakeswap, Uniswap, and NFTs efforts like Bored Ape Yacht Club that keep data on the Binance smart chain and Ethereum blockchain.
Basic read operations, such as obtaining the owner of a specific Ape, the content URI of an Ape based on their ID, or the total supply, are possible in the case of Bored Ape Yacht Club because they are directly programmed into the smart contract. However, more complex real-world queries and operations, such as aggregation, search, relationships, and non-trivial filtering, are not possible. By engaging with the contract directly, we would not be able to obtain information, for instance, if we wanted to search for apes that are owned by a specific address and filter by one of their attributes.
You would have to process every transfer event ever produced to obtain this data, read the IPFS metadata using the Token ID and IPFS hash, and then aggregate it. Even for such straightforward inquiries, getting a response from a decentralized application (dapp) running in a browser might take hours or even days.
The transactions may alternatively be processed on your server, saved to a database, and then accessed via an API endpoint that you built on top of the server. This method, however, destroys crucial security features needed for decentralization and is resource-intensive, maintenance-intensive, exposes a single point of failure, and requires maintenance.
Retrieving accurate query results from blockchain data is theoretically challenging and made more time-consuming by blockchain qualities like finality, chain reorganizations, or uncled blocks.
This problem is resolved by The Queryloop, a decentralized system that indexes blockchain data and makes it possible to query it quickly and effectively. Thereafter, a typical QL API may be used to query these APIs (indexed "subquery"). Today, the same functionalities are available in both a hosted service and a decentralized protocol. Both are supported by the Queryloop Node open-source implementation.
Based on subquery manifests, also known as subquery descriptions, the Queryloop learns what and how to index Ethereum and Binance Smart Chain data. The subquery description identifies the smart contracts that are relevant to the subquery, the events inside those contracts that should be monitored, and the mapping between event data and the information that The Queryloop will store in its database.
After creating a subquery manifest, you instruct the indexer to begin indexing data for that subquery and save the definition in IPFS using the Queryloop CLI.
This graphic, which deals with transactions, provides further information about the data flow once a subquery manifest has been deployed:
Through a transaction on a smart contract, a dapp contributes data to the Binance Smart Chain.
During the course of executing the transaction, the smart contract emits one or more events.
The Queryloop Node constantly searches the Binance Smart Chain for fresh blocks and any data your subquery might want.
These blocks are where Queryloop Node identifies Binance Smart Chain events for your subquery and executes the mapping handlers you specified. In reaction to Binance Smart Chain events, the mapping is a WASM module that produces or modifies the data entities that Queryloop Node stores.
Using the Queryloop Node's QL endpoint, the dapp asks for information that has been indexed from the blockchain. In order to get this data, the Queryloop Node in turn converts the QL inquiries into queries for its underlying data store by utilising the indexing capabilities of the store. The dapp provides end users with a sophisticated user interface that allows them to issue new transactions on the Binance Smart Chain using this data. The cycle continues.
The definition of subqueries, their deployment, and how to access data from the indexes that Queryloop Node creates will all be covered in further detail in the sections that follow.
You might want to have a peek at the Queryloop Explorer and study some of the subqueries that have already been deployed before you start building your own subquery. You may use QL to query the data from each subquery using the playground on the page for that subgraph.