Please view the third-party content disclaimer here.
- Polygon Chain mainnet
- Amoy testnet
Prerequisites
- A smart contract deployed and verified on a supported Polygon network.
- Node.js installed.
- A Subgraph Studio account with a connected wallet.
Step 1: Initialize your subgraph project
Create a subgraph in Subgraph Studio
Go to Subgraph Studio and connect your wallet. Click Create a Subgraph. Use Title Case for the name, for example: “My Contract Polygon Chain”. The subgraph page displays the CLI commands you need on the right side:Install the Graph CLI
Initialize your subgraph
Copy the command from your subgraph page to include your specific subgraph slug:Step 2: Deploy and publish
Deploy to Subgraph Studio
Build the subgraph:v0.0.1.
Test your subgraph
Use the playground in Subgraph Studio to run a sample query. The Details tab shows your API endpoint for testing from your dApp.Publish to the decentralized network
When your subgraph is ready for production, click Publish on the subgraph page in Subgraph Studio: After publishing, indexers must begin serving queries. To speed this up, curate your subgraph with GRT. As of May 2024, curating with at least 3,000 GRT is recommended to ensure the subgraph is indexed and queryable promptly.Note: The Graph’s smart contracts are on Arbitrum One, even when your subgraph indexes data from Polygon or other supported chains.
Step 3: Query your subgraph
Once published, query your subgraph by sending a GraphQL query to the subgraph’s query URL. Find the URL at the top of the subgraph’s Explorer page. Example from the CryptoPunks Ethereum subgraph: The query URL format is:https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/HdVdERFUe8h61vm2fDyycgxjsde5PbB832NHgJfZNqK