A Graph Of Possibilities
If you have never heard of The Graph Network before, it is easy to understand what it does and how it benefits a blockchain ecosystem. Beyond the digital coins themselves, blockchains are rich with data coming from transactions and smart contract events. The permanent ledgers they secure are a growing record of every confirmed transaction in its history. The problem is that these ledgers can become complex and large, which makes the historical data difficult to store and query quickly. The Graph Network solves this problem with a decentralized protocol that creates indexes of blockchain data, called subgraphs. This makes it fast and easy for developers to query data with a GraphQL API. If you are building a dApp then there are plenty of reasons to need robust access to blockchain data, I will go over some of them in this article.
DeFi
The most obvious category of data for the graph to be indexing would be decentralized finance (DeFi). dApps like Uniswap and Compound need to provide dynamic price and interest rate information 24/7 their users around the world. Real-time data like Chainlink Price Feeds can be indexed and used in a multitude of ways.
For example, The Graph’s integration with Chainlink oracles can help to calculate and compare slippage of potential trades made on Uniswap. I would love to see a subgraph that can chart and compare off-chain price data with other on-chain metrics. The Graph could index all large wallet activity for a particular token, giving users more real-time tools for trading indicators. This could become a decentralized Glassnode for any blockchain it indexes.
Compared to the many kinds of off-chain data that oracles offer, price feeds are low-hanging fruit. Let's think of how to use The Graph’s indexing to integrate real-world location data from projects like Foam.Space; a cartography project that uses blockchain technology to signal places on a world map. This use case is intriguing because until now we have only relied on centralized GPS systems to index places, like with google maps. Using The Graph with Foam Map or Foam Location, developers can do really neat things with secure location information.
For example, Foam Map can be leveraged by The Graph to keep a well-cataloged record of every Point Of Interest (POI). The metadata of each POI is currently not well documented on the blockchain but rather stored on FOAM’s centralized hosted server. Subgraphs can be used to index the metadata attached to each POI allowing developers to create front-end applications that leverage this data for other use cases. A community driven Yelp could be a good example to picture.
What if we want to index other subgraphs!? At first, this might seems counterintuitive but we can use The Graph Oracle to index other subgraphs through a smart contract, and use it as an oracle. This integration allows any smart contract to interact with the Graph Network’s entire set of subgraphs through the theGraphOracle.sol solidity contract. Normally an off-chain agent would perform the queries and display the information on an HTML page, but in this case, The Graph data can become more of a composable primitive offering relational data to smart contracts. Useful as triggers for retroactive rewards also good for closed-loop data analytics and automation.
As I write, more and more possibilities come to mind but this goes to show the incredible usefulness of the graph! Not only as an indexing tool but also as an oracle for smart contracts! There are plenty of ways blockchain data can be leveraged with subgraphs. As a Graph Network Curator, I am excited to study all the new ideas for subgraphs that have never been thought of. Particularly in the area where 1 subgraph can index multiple protocols in one graph, this should get very interesting!
Space Commander Theo Beams Signing Off, until next time…
See you on Mars!