Upgrading an Existing Subgraph to The Graph Network
Reading time: 7 min
This is a guide on how to upgrade your subgraph from the hosted service to The Graph's decentralized network. Over 1,000 subgraphs have successfully upgraded to The Graph Network including projects like Snapshot, Loopring, Audius, Premia, Livepeer, Uma, Curve, Lido, and many more!
The process of upgrading is quick and your subgraphs will forever benefit from the reliability and performance that you can only get on The Graph Network.
- You have a subgraph deployed on the hosted service.
If you are logged in to the hosted service, you can access a simple flow to upgrade your subgraphs from , or from an individual subgraph page.
This process typically takes less than five minutes.
- Select the subgraph(s) you want to upgrade.
- Connect or enter the receiving wallet (the wallet that will become the owner of the subgraph).
- Click the "Upgrade" button.
That's it! Your subgraphs will be deployed to Subgraph Studio, and published on The Graph Network. You can access the to manage your subgraphs, logging in with the wallet specified during the upgrade process.
You'll be able to view your subgraphs live on the decentralized network via .
When your subgraph is upgraded, it will automatically be indexed by the upgrade indexer. If the indexed chain is , you can add some GRT as "signal", to attract more indexers. It is recommended to curate your subgraph with at least 3,000 GRT to attract 2-3 Indexers for higher quality of service.
You can start to query your subgraph right away on The Graph Network, once you have generated an API key.
You can generate an API key in Subgraph Studio .
You can use this API key to query subgraphs on The Graph Network. All users start on the Free Plan, which includes 100,000 free queries per month. Developers can sign up for the Growth Plan by connecting a credit or debit card, or by depositing GRT to Subgraph Studio billing system.
It is recommended that you secure the API by limiting its usage in two ways:
- Authorized Subgraphs
- Authorized Domain
Now you can check the indexing status of the Indexers on the network in Graph Explorer (example ). The green line at the top indicates that at the time of posting 7 Indexers successfully indexed that subgraph. Also in the Indexer tab you can see which Indexers picked up your subgraph.
As soon as the first Indexer has fully indexed your subgraph you can start to query the subgraph on the decentralized network. In order to retrieve the query URL for your subgraph, you can copy/paste it by clicking on the symbol next to the query URL. You will see something like this:
https://gateway.thegraph.com/api/[api-key]/subgraphs/id/S9ihna8D733WTEShJ1KctSTCvY1VJ7gdVwhUujq4Ejo
Important: Make sure to replace [api-key]
with an actual API key generated in the section above.
You can now use that Query URL in your dapp to send your GraphQL requests to.
Congratulations! You are now a pioneer of decentralization!
Note: Due to the distributed nature of the network it might be the case that different Indexers have indexed up to different blocks. In order to only receive fresh data you can specify the minimum block an Indexer has to have indexed in order to serve your query with the block: { number_gte: $minBlock }
field argument as shown in the example below:
{stakers(block: { number_gte: 14486109 }) {id}}
More information about the nature of the network and how to handle re-orgs are described in the documentation article .
If you would like to update an existing subgraph on the network, you can do this by deploying a new version of your subgraph to Subgraph Studio using the Graph CLI.
- Make changes to your current subgraph.
- Deploy the following and specify the new version in the command (eg. v0.0.1, v0.0.2, etc):
graph deploy --studio --version <version> <SUBGRAPH_SLUG>
- Test the new version in Subgraph Studio by querying in the playground
- Publish the new version on The Graph Network. Remember that this requires gas (as described in the section above).
An update requires GRT to be migrated from the old version of the subgraph to the new version. This means that for every update, a new bonding curve will be created (more on bonding curves ).
The new bonding curve charges the 1% curation tax on all GRT being migrated to the new version. The owner must pay 50% of this or 1.25%. The other 1.25% is absorbed by all the curators as a fee. This incentive design is in place to prevent an owner of a subgraph from being able to drain all their curator's funds with recursive update calls. If there is no curation activity, you will have to pay a minimum of 100 GRT in order to signal your own subgraph.
Let's make an example, this is only the case if your subgraph is being actively curated on:
- 100,000 GRT is signaled using auto-migrate on v1 of a subgraph
- Owner updates to v2. 100,000 GRT is migrated to a new bonding curve, where 97,500 GRT get put into the new curve and 2,500 GRT is burned
- The owner then has 1250 GRT burned to pay for half the fee. The owner must have this in their wallet before the update, otherwise, the update will not succeed. This happens in the same transaction as the update.
While this mechanism is currently live on the network, the community is currently discussing ways to reduce the cost of updates for subgraph developers.
If you're making a lot of changes to your subgraph, it is not a good idea to continually update it and front the update costs. Maintaining a stable and consistent version of your subgraph is critical, not only from the cost perspective but also so that Indexers can feel confident in their syncing times. Indexers should be flagged when you plan for an update so that Indexer syncing times do not get impacted. Feel free to leverage the on Discord to let Indexers know when you're versioning your subgraphs.
Subgraphs are open APIs that external developers are leveraging. Open APIs need to follow strict standards so that they do not break external developers' applications. In The Graph Network, a subgraph developer must consider Indexers and how long it takes them to sync a new subgraph as well as other developers who are using their subgraphs.
You can update the metadata of your subgraphs without having to publish a new version. The metadata includes the subgraph name, image, description, website URL, source code URL, and categories. Developers can do this by updating their subgraph details in Subgraph Studio where you can edit all applicable fields.
Make sure Update Subgraph Details in Explorer is checked and click on Save. If this is checked, an on-chain transaction will be generated that updates subgraph details in the Explorer without having to publish a new version with a new deployment.
- Leveraging an ENS name for Subgraph Development:
- The more filled out your profiles are, the better the chances for your subgraphs to be indexed and curated.
Follow the steps to deprecate your subgraph and remove it from The Graph Network.
The hosted service was set up to allow developers to deploy their subgraphs without any restrictions.
On The Graph Network, query fees have to be paid as a core part of the protocol's incentives. For more information on subscribing to APIs and paying the query fees, check out billing documentation .
If you're still confused, fear not! Check out the following resources or watch our video guide on upgrading subgraphs to the decentralized network below: