The Graph
The Graph

The Graph

What is the Graph Protocol?

The Graph is a decentralized protocol designed to index and query data from blockchains, enabling efficient access to complex blockchain data that is otherwise difficult to retrieve directly.

More about The Graph Protocol

Blockchain projects like Uniswap and NFT initiatives such as Bored Ape Yacht Club store vast amounts of data on the Ethereum blockchain. While basic data, such as the owner of a specific NFT or its metadata, can be accessed directly via smart contract read operations, more complex queries are challenging. For instance, finding all NFTs owned by a particular address and filtering them based on certain characteristics involves processing numerous transactions and metadata, which is not feasible directly on-chain.
Without The Graph, developers would need to build their own servers to process blockchain transactions, maintain a database, and create an API for querying this data. This approach is resource-intensive, prone to single points of failure, and compromises the decentralization principle.

The Graph's Solution

The Graph overcomes these challenges by providing a decentralized protocol that indexes blockchain data and allows efficient querying through standard GraphQL APIs. Both a hosted service and a decentralized protocol version are available, backed by the open-source implementation of Graph Node.
By using The Graph, developers can build robust, decentralized applications that efficiently handle complex data queries without compromising on performance or decentralization.

How The Graph Works

  • Subgraph Manifest Creation: Developers define what data to index by creating a subgraph manifest. This manifest specifies the relevant smart contracts, the events to monitor, and how to map event data to entities The Graph will store.
  • Indexing Process:
    • The subgraph manifest is stored in IPFS using the Graph CLI.
    • The indexer starts indexing the specified data.
  • Data Flow:
    • A decentralized application (dapp) executes a transaction on Ethereum, emitting events.
    • Graph Node, constantly scanning Ethereum for new blocks, detects these events.
    • It runs predefined mapping handlers, which are WebAssembly (WASM) modules, to process the events and update the stored data entities accordingly.
  • Querying Data:
    • Dapps query the indexed data via Graph Node's GraphQL endpoint.
    • Graph Node translates GraphQL queries into efficient data store queries, leveraging its indexing capabilities.
    • The retrieved data is then used to enhance the dapp's user interface, allowing users to interact with complex data seamlessly.

Key services & use cases powered by The Graph Protocol as a Web3 infrastructure provider

  • Subgraph Studio: A platform to create, manage, and publish subgraphs along with API keys. Developers use Subgraph Studio to define and deploy subgraphs, specifying which blockchain data to index and how to structure it. This facilitates the efficient querying of complex data for dapps.
  • Graph Explorer: A tool to explore subgraphs and interact with The Graph protocol. Users and developers can browse through existing subgraphs, test queries, and understand the data structures indexed by The Graph. This helps in verifying data availability and accuracy for building or improving dapps.
  • Hosted Service: An environment to create and explore subgraphs without the need to run a Graph Node. Provides a scalable, managed service for developers to quickly deploy and test subgraphs. This is ideal for projects that want to leverage The Graph’s capabilities without managing the infrastructure, ensuring rapid development and iteration.
By leveraging these services, developers can efficiently index and query blockchain data, build powerful and data-rich decentralized applications, and interact seamlessly with complex data sets across various blockchain networks.

The Graph Protocol Resources


Β