📃
Graph Codex
  • Welcome to The Graph Codex
  • Getting Started
    • Websites
    • Resources
  • Meetings and Events
    • Core Developers Calls
    • Community Talks
    • Indexer Office Hours
    • NFT Community Calls
  • Workshops
    • Subgraph Development
      • Resources
        • Hackathon Workshops
          • Blockchain Development - Querying with Open APIs Course
          • Building a Custom NFT API with Filtering, Sorting, Full Text Search, and Relationships
          • Building a custom NFT API with The Graph
          • Building a Subgraph on Celo @ The Cross Chain Salon
          • Building a Subgraph with Subgraph Studio
          • Building an NFT API and Subgraph on NEAR with The Graph
          • Building an NFT API with the Graph - Nader Dabit
          • Building an NFT Subgraph - Kuneco April 2021
          • Building and Deploying Subgraphs on TheGraphProtocol
          • Building API's on Ethereum, with Nader Dabit
          • Building Apps on the Decentralized Web with Nader Dabit
          • Building Decentralised GraphQL APIs with The Graph
          • Building on Ethereum with GraphQL, The Graph, and Next.js
          • Building Rich APIs on top of Ethereum with The Graph
          • Building Subgraphs on The Graph - MarketMake
          • Building Subgraphs on The Graph
          • Building Subgraphs with The Graph
          • Defining the Web3 Stack - Nader Dabit - (Next.js Conf 2021)
          • How to build a dApp – Nader Dabit
          • How to Build a Full Stack NFT Marketplace on Ethereum with Polygon and Next.js
          • How to Build an NFT API with The Graph
          • Indexing Smart Contracts with OpenZeppelin Subgraphs & The Graph
          • NFT Dev Talk, GenerativeMasks, and Building NFT APIs with OpenZeppelin, GraphQL, and The Graph
          • Query Ethereum with GraphQL with The Graph
          • The Complete Guide to Full Stack Web3 Development
          • Web3 with Nader Dabit
          • Workshop on How to Build Subgraphs
        • Repositories
      • Developer Highlights
      • Developer Guides
      • Subgraph Testing (Matchstick)
    • Protocol Workshops
  • Ecosystem Updates
    • This Month in Indexing
    • This Month in Curation
    • Council Meeting Notes
    • Governance
      • Governance Resources
      • Graph Improvement Proposals (GIPs)
        • 0000-template
        • 0001-gip-process
        • 0002-gip-withdraw-indexer-rewards
        • 0003-gip-rewards-no-signal
        • 0004-gip-withdraw-indexer-rewards-thawing
        • 0005-gas-costing
        • 0006-gip-withdraw-helper
        • 0007-separate-slashing-percentages
        • 0008-subgraph-api-versioning-and-feature-support
        • 0009-arbitration-charter
        • 0010-rewards-snapshot-empty-poi-fix
        • 0011-stake-to-init-fix
        • 0012-cache-contract-addresses
        • 0013-reduce-curation-tax
        • 0014-batch-gns-transactions
        • 0015-allow-unstake-passing-larger-amount-available
        • 0016-revert-precision-assign-delegation-share
        • 0017-allow-batching-calls-staking-contract
        • 0018-subgraph-ownership-transfer
        • 0019-save-gas-initializing-subgraph-deployment
        • 0020-unattestable-indexer-responses
        • 0023-subgraph-ownership-transfer-nft
        • 0024-query-versioning
        • 0025-principal-protected-bonding-curves
        • 0026-decaying-curation-tax
      • Graph Request for Comments (GRCs)
        • 0001-data-edge
  • Repositories and Documentation
    • Official Repositories
    • Official Documentation
      • About
        • Introduction
        • Network Overview
      • Developer
        • Quick Start
        • Define a Subgraph
        • Create a Subgraph
        • Publish a Subgraph to the Decentralized Network
        • Query The Graph
        • Querying from an Application
        • Querying Best Practices
        • Distributed Systems
        • AssemblyScript API
        • AssemblyScript Migration Guide
        • GraphQL API
        • Unit Testing Framework
        • Deprecating a Subgraph
        • Developer FAQs
      • Indexer
      • Delegator
      • Curator
      • The Graph Explorer
      • Subgraph Studio
        • How to use the Subgraph Studio
        • Deploy a Subgraph to the Subgraph Studio
        • Billing on the Subgraph Studio
        • Managing your API Keys
        • Subgraph Studio FAQs
        • Multisig Users
      • Hosted Service
        • What is Hosted Service?
        • Deploy a Subgraph to the Hosted Service
        • Migrating an Existing Subgraph to The Graph Network
      • Supported Networks
        • NEAR
Powered by GitBook
On this page
  • Introduction
  • Best Practices for Deploying a Subgraph to The Graph Network
  • Deprecating a Subgraph on The Graph Network
  • Querying a Subgraph + Billing on The Graph Network
  • Additional Resources

Was this helpful?

Edit on GitHub
  1. Repositories and Documentation
  2. Official Documentation
  3. Hosted Service

Migrating an Existing Subgraph to The Graph Network

PreviousDeploy a Subgraph to the Hosted ServiceNextSupported Networks

Last updated 3 years ago

Was this helpful?

Introduction

This is a guide on how to migrate your subgraph from the Hosted Service to The Graph Network. The migration to The Graph Network has been successful for projects like Opyn, UMA, mStable, Audius, PoolTogether, Livepeer, RAI, Enzyme, DODO, Opyn, Pickle, and BadgerDAO all of which are relying on data served by Indexers on the network. There are now over 200 subgraphs live on The Graph Network, generating query fees and actively indexing web3 data.

The process of migration is quick and your subgraphs will forever benefit from the reliability and performance that you can only get on The Graph Network.

When not to Migrate?

If your subgraph is:

  • Indexing .

  • Using .

  • Indexing chains other than Ethereum mainnet.

Migrating an Existing Subgraph to The Graph Network

  1. Get the latest version of the graph-cli installed:

npm install -g @graphprotocol/graph-cli
yarn global add @graphprotocol/graph-cli
  1. Create a subgraph on the . Guides on how to do that can be found in the and in .

  2. Inside the main project subgraph repository, authenticate the subgraph to deploy and build on the studio:

graph auth --studio <DEPLOY_KEY>
  1. Generate files and build the subgraph:

graph codegen && graph build
  1. Deploy the subgraph to the Studio. You can find your <SUBGRAPH_SLUG> in the Studio UI, which is based on the name of your subgraph.

 graph deploy --studio <SUBGRAPH_SLUG>
{
  users(first: 5) {
    id
    liquidityPositions {
      id
    }
  }
  bundles(first: 5) {
    id
    ethPrice
  }
}
  1. Fill in the description and the details of your subgraph and choose up to 3 categories. Upload a project image in the Studio if you'd like as well.

  2. Publish the subgraph on The Graph's Network by hitting the "Publish" button.

  • Any time you need to upgrade your subgraph, you will be charged an upgrade fee. Remember, upgrading is just publishing another version of your existing subgraph on-chain. Because this incurs a cost, it is highly recommended to deploy and test your subgraph on Rinkeby before deploying to mainnet. It can, in some cases, also require some GRT if there is no signal on that subgraph. In the case there is signal/curation on that subgraph version (using auto-migrate), the taxes will be split.

Upgrading a Subgraph on the Network

If you would like to upgrade an existing subgraph on the network, you can do this by deploying a new version of your subgraph to the Subgraph Studio using the Graph CLI.

  1. Make changes to your current subgraph. A good idea is to test small fixes on the Subgraph Studio by publishing to Rinkeby.

  2. Deploy the following and specify the new version in the command (eg. v0.0.1, v0.0.2, etc):

graph deploy --studio <SUBGRAPH_SLUG>
  1. Test the new version in the Subgraph Studio by querying in the playground

  2. Publish the new version on The Graph Network. Remember that this requires gas (as described in the section above).

Owner Upgrade Fee: Deep Dive

The new bonding curve charges the 2.5% 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 upgrade 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 upgrades 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 upgrade, otherwise, the upgrade will not succeed. This happens in the same transaction as the upgrade.

While this mechanism is currently live on the network, the community is currently discussing ways to reduce the cost of upgrades for subgraph developers.

Maintaining a Stable Version of a Subgraph

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.

Updating the Metadata of a Subgraph

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 the 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.

Best Practices for Deploying a Subgraph to The Graph Network

  1. Leveraging an ENS name for Subgraph Development:

  1. The more filled out your profiles are, the better the chances for your subgraphs to be indexed and curated.

Deprecating a Subgraph on The Graph Network

Querying a Subgraph + Billing on The Graph Network

The Hosted Service was set up to allow developers to deploy their subgraphs without any restrictions.

Estimate Query Fees on the Network

While this is not a live feature in the product UI, you can set your maximum budget per query by taking the amount you're willing to pay per month and dividing it by your expected query volume.

While you get to decide on your query budget, there is no guarantee that an Indexer will be willing to serve queries at that price. If a Gateway can match you to an Indexer willing to serve a query at, or lower than, the price you are willing to pay, you will pay the delta/difference of your budget and their price. As a consequence, a lower query price reduces the pool of Indexers available to you, which may affect the quality of service you receive. It's beneficial to have high query fees, as that may attract curation and big-name Indexers to your subgraph.

Additional Resources

If you're still confused, fear not! Check out the following resources or watch our video guide on migrating subgraphs to the decentralized network below:

    • Address - 0x8fe00a685bcb3b2cc296ff6ffeab10aca4ce1538

Test queries on the Studio's playground. Here are some examples for the :

Remember that publishing is an on-chain action and will require gas to be paid for in Ethereum - see an example transaction . Prices are roughly around 0.0425 ETH at 100 gwei.

And that's it! After you are done publishing, you'll be able to view your subgraphs live on the network via .

Feel free to leverage the on Discord to let Curators know that your subgraph is ready to be signaled. It would also be helpful if you share your expected query volume with them. Therefore, they can estimate how much GRT they should signal on your subgraph.

An upgrade requires GRT to be migrated from the old version of the subgraph to the new version. This means that for every upgrade, a new bonding curve will be created (more on bonding curves ).

If you're making a lot of changes to your subgraph, it is not a good idea to continually upgrade it and front the upgrade 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 upgrade 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.

Set up your ENS:

Add your ENS name to your settings .

Follow the steps to deprecate your subgraph and remove it from The Graph Network.

In order for The Graph Network to truly be decentralized, 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 .

Remember that it's a dynamic and growing market, but how you interact with it is in your control. There is no maximum or minimum price specified in the protocol or the Gateways. For example, you can look at the price paid by a few of the dapps on the network (on a per-week basis), below. See the last column, which shows query fees in GRT. For example, has 8 requests per second and paid 2.4 GRT for one week.

- the underlying contract that the GNS wraps around

IPFS
full-text search fields
Subgraph Studio
Subgraph Studio docs
this video tutorial
Sushi - Mainnet Exchange Subgraph
here
The Graph Explorer
#Curators channel
here
#Indexers channel
https://app.ens.domains/
here
here
here
Pickle Finance
The Graph Network Contracts
Curation Contract
Subgraph Studio documentation
QueryFee