The role of the blockchain index protocol

The blockchain is a decentralized ledger. The ledger records data, but what you see in the browser is that after the transaction is packaged into blocks, the transaction data becomes a hash. Under the effect of Ethereum’s erc20 protocol, we can see these basic data such as transfer transactions.

But for users, if they query the data of the blockchain, if the browser does not have a special display, they can only see the hash. In the possible demand, there will be many types of data on the blockchain. These data need Indexes and queries.

These indexes and queries can collect statistics and aggregate the data to help users use them.

In this part, The Graph is an example, a protocol dedicated to indexing and querying. In theory, all blockchain networks need to deploy such tools.

For example, The Graph is on Ethereum, making it possible to query data that is difficult to query directly.

After projects with complex smart contracts such as Uniswap and NFTs such as Bored Ape Yacht Club store data on the Ethereum blockchain, it is difficult to read anything other than basic data from the blockchain.

For example, Bored Ape Yacht Club NFT performs read operations on the contract to obtain owner information, total supply, content URI, etc. These are the basic information in the contract. If you want to implement advanced queries and operations like a search engine, such as Aggregation, search, and filtering are all impossible.

Because if you want to get this data, you must process all the events that the trader has ever sent, read the metadata from the IPFS storage location with the token ID and IPFS hash, and then aggregate it. Time-consuming.

The Graph solves this problem through a decentralized protocol that can index blockchain data and achieve high-performance and efficient queries. These APIs (index “subgraphs”) can then be queried using the standard GraphQL API.

The specific implementation process is as follows:

1.Decentralized applications add data to Ethereum through transactions on smart contracts, and smart contracts emit one or more events when processing transactions.

2. The Graph node continuously scans Ethereum for new blocks and the subgraph data they may contain. The Graph node finds Ethereum events for the subgraph in these blocks and runs the mapping handler. Mapping is a WASM module that creates or updates data entities stored by Graph Node in response to Ethereum events.

3. The decentralized application uses the GraphQL endpoint of the node to query the Graph Node to obtain data indexed from the blockchain. Graph Node in turn converts GraphQL queries into queries on its underlying data storage to obtain these data using the stored index function. Decentralized applications display this data in a rich user interface for end users, who use these user interfaces to post new transactions on Ethereum.

Ps: The page of each subgraph contains a Playground, and GraphQL can be used to query the data of the subgraph.

Posted by:CoinYuppie,Reprinted with attribution to:
Coinyuppie is an open information publishing platform, all information provided is not related to the views and positions of coinyuppie, and does not constitute any investment and financial advice. Users are expected to carefully screen and prevent risks.

Like (0)
Donate Buy me a coffee Buy me a coffee
Previous 2021-12-10 09:52
Next 2021-12-10 09:55

Related articles