This section contains several subgraph examples to help you get started with The Graph. Each example demonstrates specific configurations and assumes basic familiarity with subgraph components.
-
Aggregations This example demonstrates how to aggregate data using block numbers as predictable values. The comments in the schema, subgraph manifest, and mappings provide guidance for implementing custom aggregations.
-
Arweave Blocks and Transactions This example indexes blocks, transactions, tags, and POAs on the Arweave blockchain. Please note that it requires
graph-cli
version 0.30.2 or above to build. -
Cosmos Block Filtering This example stores
Block
objects that represent blocks appended to a Cosmos chain, saving only the block number and timestamp to the store. -
Cosmos Osmosis Token Swaps This example stores
TokenSwap
objects that represent token swaps made using the Generalized Automated Market Maker (GAMM) in the Osmosis chain. -
Cosmos Validator Delegations This example stores
Delegation
objects representing validator delegations on a Cosmos chain. -
Cosmos Validator Rewards This example stores
Reward
objects representing rewards received by validators on a Cosmos chain. -
Ethereum Basic Event Handlers This example shows how to handle basic events on the Ethereum blockchain using The Graph. It provides a practical implementation of event handlers, showcasing how to index and query blockchain data.
-
Ethereum Gravatar This example indexes data from the Ethereum Gravatar smart contract. Gravatar is a service where users can create and manage globally unique avatars.
-
Example Subgraph This example shows the structure of a minimal, basic subgraph. It provides a generic setup with a simple contract and schema designed to teach the fundamentals of defining, mapping, and querying subgraph data.
-
Matic Lens Protocol Posts Subgraph This example demonstrates how to index data from the Lens Protocol deployed on the Polygon (Matic) network.
-
NEAR Blocks This example indexes blockchain data from the NEAR Protocol. It listens to block-related events and stores key data such as block number, timestamp, and hash in a queryable format.
-
NEAR Receipts This example indexes transaction receipts from the NEAR Protocol. It tracks and stores receipt data such as transaction hash, status, and execution details.
-
Substreams Powered Subgraph This example is a basic Substreams-powered subgraph, which includes the Substreams definition. It tracks new contract deployments on Ethereum and demonstrates integration with Graph Node using
substreams_entity_change
types and helpers.
To learn more about subgraphs, review subgraphs on The Graph docs.