Quick Start
It takes just a few minutes to start indexing subgraphs on Celo. To get started, follow these three steps:- Initialize your subgraph project
- Deploy & Publish
- Query from your dapp
1. Initialize your subgraph project
Create a subgraph on Subgraph Studio
Go to the Subgraph Studio and connect your wallet. Once your wallet is connected, you can begin by clicking “Create a Subgraph”. Please choose a good name for the subgraph because this name can’t be edited later. It is recommended to use Title Case: “Subgraph Name Chain Name.”Install the Graph CLI
On your local machine run the following:Initialize your Subgraph
You can copy this directly from your subgraph page to include your specific subgraph slug:2. Deploy & Publish
Deploy to Subgraph Studio
First run these commands:Test your subgraph
You can test your subgraph by making a sample query in the playground section. The Details tab will show you an API endpoint. You can use that endpoint to test from your dapp.Publish Your Subgraph to The Graph’s Decentralized Network
Once your subgraph is ready to be put into production, you can publish it to the decentralized network. On your subgraph’s page in Subgraph Studio, click on the Publish button:
Note: The Graph’s smart contracts are all on Arbitrum One, even though your subgraph is indexing data from Ethereum, BSC or any other supported chain.
3. Query your Subgraph
Congratulations! You can now query your subgraph on the decentralized network! For any subgraph on the decentralized network, you can start querying it by passing a GraphQL query into the subgraph’s query URL which can be found at the top of its Explorer page. Here’s an example from the CryptoPunks Ethereum subgraph by Messari:Getting your own API Key
Appendix
Sample Query
This query shows the most expensive CryptoPunks sold.Sample code
Additional resources:
- To explore all the ways you can optimize & customize your subgraph for a better performance, read more about creating a subgraph here.
- For more information about querying data from your subgraph, read more here.