Getting historical data on a smart contract can be frustrating when you’re building a dapp. The Graph provides an easy & decentralized option to query smart contract data through APIs known as subgraphs. Its infrastructure relies on a decentralized network of indexers, enabling your dapp to achieve true decentralization.
These subgraphs only take a few minutes to set up. To get started, follow these three steps:
Pricing: All developers receive 100K free queries per month on the decentralized network. After these free queries, you only pay based on usage at $4 for every 100K queries.
Here’s a step by step walk through:
Go to the Subgraph Studio and connect your wallet. Once your wallet is connected, you can begin by clicking “Create a Subgraph”. When choosing a name for your subgraph, it is recommended to use Title Case: “Subgraph Name Chain Name.”
You will then land on your subgraph’s page. All the CLI commands you need will be visible on the right side of the page:
On your local machine run the following:
npm install -g @graphprotocol/graph-cli
You can copy this directly from your subgraph page to include your specific subgraph slug:
graph init --studio <SUBGRAPH_SLUG>