Skip to content

Instantly share code, notes, and snippets.

@nenadjaja
Created October 25, 2021 18:44
Show Gist options
  • Save nenadjaja/04a456761416200ca9752a223a950e5e to your computer and use it in GitHub Desktop.
Save nenadjaja/04a456761416200ca9752a223a950e5e to your computer and use it in GitHub Desktop.
<!doctype html>
<html class="docs-version-current" lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Docusaurus v2.0.0-beta.8">
<title data-react-helmet="true">Migrating an Existing Subgraph to The Graph Network | Graph Docs</title><meta data-react-helmet="true" name="twitter:card" content="summary_large_image"><meta data-react-helmet="true" property="og:url" content="https://thegraph.com/docs/hostedservice/migrating-subgraph"><meta data-react-helmet="true" name="docusaurus_locale" content="en"><meta data-react-helmet="true" name="docusaurus_version" content="current"><meta data-react-helmet="true" name="docusaurus_tag" content="docs-default-current"><meta data-react-helmet="true" property="og:title" content="Migrating an Existing Subgraph to The Graph Network | Graph Docs"><meta data-react-helmet="true" name="description" content="Introduction"><meta data-react-helmet="true" property="og:description" content="Introduction"><script src="/cdn-cgi/apps/head/a-7iaLT0SRdb_kvxGKIYLrjkGzU.js"></script><link data-react-helmet="true" rel="shortcut icon" href="/docs/img/favicon.ico"><link data-react-helmet="true" rel="canonical" href="https://thegraph.com/docs/hostedservice/migrating-subgraph"><link data-react-helmet="true" rel="alternate" href="https://thegraph.com/docs/hostedservice/migrating-subgraph" hreflang="en"><link data-react-helmet="true" rel="alternate" href="https://thegraph.com/docs/hostedservice/migrating-subgraph" hreflang="x-default"><link rel="stylesheet" href="/docs/assets/css/styles.a0924070.css">
<link rel="preload" href="/docs/assets/js/runtime~main.0449330f.js" as="script">
<link rel="preload" href="/docs/assets/js/main.dd7ef3b1.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"dark")}()</script><div id="__docusaurus">
<div style="position:absolute;left:0;right:0;top:0;bottom:0;background-image:url(&#x27;/docs/img/page-background.png&#x27;);background-size:cover;background-position:center top;background-repeat:no-repeat"></div><div style="position:relative;margin:0 auto;width:1340px;max-width:100%;padding:0 30px"><div><a href="#" class="skipToContent_1oUP">Skip to main content</a></div><div class="navbar"><style data-emotion="css 6z7wob">.css-6z7wob{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;z-index:10;padding-left:0;padding-right:0;padding-top:32px;padding-bottom:32px;height:100px;}</style><header class="header css-6z7wob"><style data-emotion="css 1biwuey">.css-1biwuey{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;width:100%;height:100%;padding-left:4px;padding-right:4px;}</style><style data-emotion="css 1cy6b33">.css-1cy6b33{box-sizing:border-box;margin:0;min-width:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;width:100%;height:100%;padding-left:4px;padding-right:4px;}</style><div class="left-area css-1cy6b33"><style data-emotion="css 1iff5yk">.css-1iff5yk{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;width:100%;}</style><style data-emotion="css 1q0t0ec">.css-1q0t0ec{box-sizing:border-box;margin:0;min-width:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;width:100%;}</style><div class="brand css-1q0t0ec"><style data-emotion="css 13xhtad">.css-13xhtad{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}</style><style data-emotion="css ykwscm">.css-ykwscm{box-sizing:border-box;margin:0;min-width:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}</style><div class="css-ykwscm"><a href="/" class="logo"><style data-emotion="css kup8ry">.css-kup8ry{margin-right:32px;height:25px;display:block;}</style><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjJweCIgaGVpZ2h0PSIyOHB4IiB2aWV3Qm94PSIwIDAgMjIgMjgiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDUyLjQgKDY3Mzc4KSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5GaWxsIDE5PC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGcgaWQ9IlN5bWJvbHMiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIGlkPSJNZW51LS8tbm90LXNpZ25lZC1pbiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTg4LjAwMDAwMCwgLTUyLjAwMDAwMCkiIGZpbGw9IiNGRkZGRkYiPgogICAgICAgICAgICA8cGF0aCBkPSJNOTcuMzMzMzAxOSw2Ny41NTU1MDMyIEM5My44OTY5NDk4LDY3LjU1NTUwMzIgOTEuMTExMTAwNiw2NC43Njk4NDI1IDkxLjExMTEwMDYsNjEuMzMzMzAxOSBDOTEuMTExMTAwNiw1Ny44OTY3NjEzIDkzLjg5Njk0OTgsNTUuMTExMTAwNiA5Ny4zMzMzMDE5LDU1LjExMTEwMDYgQzEwMC43Njk4NDMsNTUuMTExMTAwNiAxMDMuNTU1NTAzLDU3Ljg5Njc2MTMgMTAzLjU1NTUwMyw2MS4zMzMzMDE5IEMxMDMuNTU1NTAzLDY0Ljc2OTg0MjUgMTAwLjc2OTg0Myw2Ny41NTU1MDMyIDk3LjMzMzMwMTksNjcuNTU1NTAzMiBNOTcuMzMzMzAxOSw1MiBDMTAyLjQ4NzkyNCw1MiAxMDYuNjY2NjA0LDU2LjE3ODY3OTUgMTA2LjY2NjYwNCw2MS4zMzMzMDE5IEMxMDYuNjY2NjA0LDY2LjQ4NzkyNDMgMTAyLjQ4NzkyNCw3MC42NjY2MDM4IDk3LjMzMzMwMTksNzAuNjY2NjAzOCBDOTIuMTc4Njc5NSw3MC42NjY2MDM4IDg4LDY2LjQ4NzkyNDMgODgsNjEuMzMzMzAxOSBDODgsNTYuMTc4Njc5NSA5Mi4xNzg2Nzk1LDUyIDk3LjMzMzMwMTksNTIgWiBNMTA2LjIxMTA2Myw3MS4xMjIxNDQ0IEMxMDYuODE4NTc2LDcxLjcyOTY1NzUgMTA2LjgxODU3Niw3Mi43MTQ0NjIyIDEwNi4yMTEwNjMsNzMuMzIxOTc1MyBMOTkuOTg4NjczNCw3OS41NDQzNjUyIEM5OS4zODExNjAzLDgwLjE1MTg3ODMgOTguMzk2MzU1Niw4MC4xNTE4NzgzIDk3Ljc4ODg0MjUsNzkuNTQ0MzY1MiBDOTcuMTgxMzI5NCw3OC45MzY4NTIxIDk3LjE4MTMyOTQsNzcuOTUyMDQ3MyA5Ny43ODg4NDI1LDc3LjM0NDUzNDIgTDEwNC4wMTEyMzIsNzEuMTIyMTQ0NCBDMTA0LjYxODc0NSw3MC41MTQ2MzEzIDEwNS42MDM1NSw3MC41MTQ2MzEzIDEwNi4yMTEwNjMsNzEuMTIyMTQ0NCBaIE0xMDkuNzc3NzA0LDUzLjU1NTU1MDMgQzEwOS43Nzc3MDQsNTQuNDE0Nzc5NyAxMDkuMDgxMzg0LDU1LjExMTEwMDYgMTA4LjIyMjM0Myw1NS4xMTExMDA2IEMxMDcuMzYzMTEzLDU1LjExMTEwMDYgMTA2LjY2Njc5Miw1NC40MTQ3Nzk3IDEwNi42NjY3OTIsNTMuNTU1NTUwMyBDMTA2LjY2Njc5Miw1Mi42OTYzMjA5IDEwNy4zNjMxMTMsNTIgMTA4LjIyMjM0Myw1MiBDMTA5LjA4MTM4NCw1MiAxMDkuNzc3NzA0LDUyLjY5NjMyMDkgMTA5Ljc3NzcwNCw1My41NTU1NTAzIFoiIGlkPSJGaWxsLTE5Ij48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=" alt="logo" class="css-kup8ry"></a><style data-emotion="css asd1im">.css-asd1im{right:0;cursor:pointer;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;background-color:transparent;border:none;box-shadow:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;font-weight:600;font-size:16px;gap:4px;padding-right:28px;margin-right:32px;color:white;font-family:EuclidCircular,Roboto Mono;min-width:100px;}@media (max-width: 767px){.css-asd1im{border-right:none;}}@media (min-width: 767px){.css-asd1im{border-right:1px solid rgba(255, 255, 255, 0.14);}}</style><button class="css-asd1im"><span>The Graph</span><style data-emotion="css 1xd2oy0">.css-1xd2oy0{color:white;width:1rem;height:1rem;}</style><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="css-1xd2oy0"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></button><style data-emotion="css gae4m9">.css-gae4m9{margin-top:1px;display:block;}@media (max-width: 767px){.css-gae4m9{display:none;}}</style><nav class="css-gae4m9"><style data-emotion="css xw6ru3">.css-xw6ru3{box-sizing:border-box;margin:0;min-width:0;display:grid;grid-gap:32px;grid-template-columns:repeat(2, max-content);}</style><div class="css-xw6ru3"><style data-emotion="css t18qkk">.css-t18qkk{box-sizing:border-box;margin:0;min-width:0;display:grid;grid-gap:32px;grid-template-columns:repeat(5, max-content);}</style><div class="css-t18qkk"><style data-emotion="css r00ly7">.css-r00ly7{color:rgba(255,255,255,0.88);border-bottom:1px solid;cursor:pointer;-webkit-text-decoration:none;text-decoration:none;border-color:transparent;opacity:0.7;-webkit-transition:font-weight,text-shadow,opacity .3s ease;transition:font-weight,text-shadow,opacity .3s ease;font-size:16px;}.css-r00ly7:hover{border-color:transparent;opacity:0.85;}</style><a href="/" class="css-r00ly7"><style data-emotion="css 1o9ge91">.css-1o9ge91{font-size:14px;font-weight:600;letter-spacing:0.4px;line-height:20px;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:4px;}</style><style data-emotion="css o999io">.css-o999io{box-sizing:border-box;margin:0;min-width:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;font-size:14px;font-weight:600;letter-spacing:0.4px;line-height:20px;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:4px;}</style><div class="css-o999io">Home</div></a><a class="css-r00ly7"><div class="css-o999io">Docs<style data-emotion="css 1nhsdn7">.css-1nhsdn7{color:inherit;width:1rem;height:1rem;}</style><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="css-1nhsdn7"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></div></a><a href="/blog" class="css-r00ly7"><div class="css-o999io">Blog</div></a><a href="/security" class="css-r00ly7"><div class="css-o999io">Security</div></a><a href="/jobs" class="css-r00ly7"><div class="css-o999io">Jobs</div></a></div></div></nav></div><style data-emotion="css h4in5l">.css-h4in5l{gap:128px;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:end;-ms-flex-pack:end;-webkit-justify-content:flex-end;justify-content:flex-end;display:none;}@media screen and (min-width: 40em){.css-h4in5l{display:none;}}@media screen and (min-width: 52em){.css-h4in5l{display:none;}}@media screen and (min-width: 64em){.css-h4in5l{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}</style><div class="css-h4in5l"><div style="display:flex;gap:12px"><a href="/explorer" style="display:flex;padding:8px 20px;font-weight:500;color:rgba(255, 255, 255, 0.88);background:rgba(111, 76, 255, 0.08);border:1px solid rgba(111, 76, 255, 0.16);transition:all 0.3s ease;align-items:center;gap:4px;border-radius:3rem;text-decoration:none;line-height:1.25">Graph Explorer<img src="/docs/img/arrow-right.svg" style="margin-left:2px;margin-right:-4px"></a><a href="/studio" style="display:flex;padding:8px 20px;font-weight:500;color:rgba(255, 255, 255, 0.88);background:rgba(111, 76, 255, 0.08);border:1px solid rgba(111, 76, 255, 0.16);transition:all 0.3s ease;align-items:center;gap:4px;border-radius:3rem;text-decoration:none;line-height:1.25">Subgraph Studio<img src="/docs/img/arrow-right.svg" style="margin-left:2px;margin-right:-4px"></a></div></div><style data-emotion="css g8efda">.css-g8efda{box-shadow:none;border:none;background:transparent;color:white;cursor:pointer;display:none;}@media (max-width: 767px){.css-g8efda{display:block;}}</style><button class="css-g8efda"><img src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgb3BhY2l0eT0iMC44OCI+CjxwYXRoIGQ9Ik05IDEwSDIzIiBzdHJva2U9IndoaXRlIiBzdHJva2UtbWl0ZXJsaW1pdD0iMS41NTU3MiIvPgo8cGF0aCBkPSJNMTIgMTZMMjAgMTYiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS1taXRlcmxpbWl0PSIxLjU1NTcyIi8+CjxwYXRoIGQ9Ik05IDIySDIzIiBzdHJva2U9IndoaXRlIiBzdHJva2UtbWl0ZXJsaW1pdD0iMS41NTU3MiIvPgo8L2c+Cjwvc3ZnPgo="></button></div></div></header></div><div class="main-wrapper docs-wrapper docs-doc-page"><div class="docPage_31aa"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_35hR" type="button"></button><aside class="docSidebarContainer_3Kbt"><div class="sidebar_15mo"><nav class="menu thin-scrollbar menu_Bmed"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/">Get Started</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed separator-after"><a class="menu__link menu__link--sublist" href="#">About The Graph</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#">Developer</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/indexing">Indexer</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/delegating">Delegator</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item separator-after"><a class="menu__link" href="/docs/curating">Curator</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#">Subgraph Studio</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/explorer">The Graph Explorer</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><a class="menu__link menu__link--sublist menu__link--active" href="#">Hosted Service</a><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/hostedservice/what-is-hosted-service">The Hosted Service</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/hostedservice/deploy-subgraph-hosted">Deploy a Subgraph to the Hosted Service</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/hostedservice/query-hosted-service">Query the Hosted Service</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/docs/hostedservice/migrating-subgraph">Migrating an Existing Subgraph to The Graph Network</a></li></ul></li></ul></nav></div></aside><main class="docMainContainer_3ufF"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_3FnS"><div class="docItemContainer_33ec"><article><div class="tocCollapsible_1PrD theme-doc-toc-mobile tocMobile_3Hoh"><button type="button" class="clean-btn tocCollapsibleButton_2O1e">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>Migrating an Existing Subgraph to The Graph Network</h1></header><h2 class="anchor anchorWithStickyNavbar_31ik" id="introduction">Introduction<a aria-hidden="true" class="hash-link" href="#introduction" title="Direct link to heading">​</a></h2><p>This is a guide for the migration of subgraphs from the Hosted Service (also known as 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.</p><p>This will tell you everything you need to know about how to migrate to the decentralized network and manage your subgraphs moving forward. The process is quick and your subgraphs will forever benefit from the reliability and performance that you can only get on The Graph Network.</p><h3 class="anchor anchorWithStickyNavbar_31ik" id="migrating-an-existing-subgraph-to-the-graph-network-1">Migrating An Existing Subgraph to The Graph Network<a aria-hidden="true" class="hash-link" href="#migrating-an-existing-subgraph-to-the-graph-network-1" title="Direct link to heading">​</a></h3><ol><li>Get the latest version of the graph-cli installed:</li></ol><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly sh"><pre tabindex="0" class="prism-code language-sh codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">npm install -g @graphprotocol/graph-cli</span><br></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly sh"><pre tabindex="0" class="prism-code language-sh codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">yarn global add @graphprotocol/graph-cli</span><br></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><ol start="2"><li>Create a subgraph on the <a href="https://thegraph.com/studio/" target="_blank" rel="noopener noreferrer">Subgraph Studio</a>. Guides on how to do that can be found in the <a href="https://thegraph.com/docs/studio/subgraph-studio" target="_blank" rel="noopener noreferrer">Subgraph Studio docs</a> and in <a href="https://www.youtube.com/watch?v=HfDgC2oNnwo" target="_blank" rel="noopener noreferrer">this video tutorial</a>.</li><li>Inside the main project subgraph repository, authenticate the subgraph to deploy and build on the studio:</li></ol><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly sh"><pre tabindex="0" class="prism-code language-sh codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">graph auth --studio &lt;DEPLOY_KEY&gt;</span><br></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><ol start="4"><li>Generate files and build the subgraph:</li></ol><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly sh"><pre tabindex="0" class="prism-code language-sh codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">graph codegen &amp;&amp; graph build</span><br></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><ol start="5"><li>Deploy the subgraph to the Studio. You can find your &lt;SUBGRAPH_SLUG&gt; in the Studio UI, which is based on the name of your subgraph.</li></ol><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly sh"><pre tabindex="0" class="prism-code language-sh codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain"> graph deploy --studio &lt;SUBGRAPH_SLUG&gt;</span><br></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><ol start="6"><li>Test queries on the Studio&#x27;s playground. Here are some examples for the <a href="https://thegraph.com/explorer/subgraph?id=0x4bb4c1b0745ef7b4642feeccd0740dec417ca0a0-0&amp;view=Playground" target="_blank" rel="noopener noreferrer">Sushi - Mainnet Exchange Subgraph</a>:</li></ol><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly sh"><pre tabindex="0" class="prism-code language-sh codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">{</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> users(first: 5) {</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> id</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> liquidityPositions {</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> id</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> }</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> }</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> bundles(first: 5) {</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> id</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> ethPrice</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> }</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">}</span><br></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><ol start="7"><li>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&#x27;d like as well.</li><li>Publish the subgraph on The Graph&#x27;s Network by hitting the &quot;Publish&quot; button.</li></ol><ul><li>Remember that publishing is an on-chain action and will require gas to be paid for in Ethereum - see an example transaction <a href="https://etherscan.io/tx/0xd0c3fa0bc035703c9ba1ce40c1862559b9c5b6ea1198b3320871d535aa0de87b" target="_blank" rel="noopener noreferrer">here</a>. Prices are roughly around 0.0425 ETH at 100 gwei.</li><li>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.</li></ul><p>And that&#x27;s it! After you are done publishing, you&#x27;ll be able to view your subgraphs live on the network via <a href="https://thegraph.com/explorer" target="_blank" rel="noopener noreferrer">The Graph Explorer</a>.</p><h3 class="anchor anchorWithStickyNavbar_31ik" id="upgrading-a-subgraph-on-the-network">Upgrading a Subgraph on the Network<a aria-hidden="true" class="hash-link" href="#upgrading-a-subgraph-on-the-network" title="Direct link to heading">​</a></h3><p>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.</p><ol><li>Make changes to your current subgraph. A good idea is to test small fixes on the Subgraph Studio by publishing to Rinkeby.</li><li>Deploy the following and specify the new version in the command (eg. v0.0.1, v0.0.2, etc):</li></ol><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly sh"><pre tabindex="0" class="prism-code language-sh codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">graph deploy --studio &lt;SUBGRAPH_SLUG&gt;</span><br></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><ol start="3"><li>Test the new version in the Subgraph Studio by querying in the playground</li><li>Publish the new version on The Graph Network. Remember that this requires gas (as described in the section above).</li></ol><h3 class="anchor anchorWithStickyNavbar_31ik" id="owner-upgrade-fee-deep-dive">Owner Upgrade Fee: Deep Dive<a aria-hidden="true" class="hash-link" href="#owner-upgrade-fee-deep-dive" title="Direct link to heading">​</a></h3><p>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 <a href="https://thegraph.com/docs/curating#bonding-curve-101" target="_blank" rel="noopener noreferrer">here</a>).</p><p>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&#x27;s funds with recursive upgrade calls. The example below is only the case if your subgraph is being actively curated on. If there is no curation activity, you will have to pay a minimum of 100 GRT in order to signal yourself on your own subgraph.</p><ul><li>100,000 GRT is signaled using auto-migrate on v1 of a subgraph</li><li>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</li><li>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.</li></ul><p><em>While this mechanism is currently live on the network, the community is currently discussing ways to reduce the cost of upgrades for subgraph developers.</em></p><h3 class="anchor anchorWithStickyNavbar_31ik" id="maintaining-a-stable-version-of-a-subgraph">Maintaining a Stable Version of a Subgraph<a aria-hidden="true" class="hash-link" href="#maintaining-a-stable-version-of-a-subgraph" title="Direct link to heading">​</a></h3><p>If you&#x27;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 <a href="https://discord.gg/8tgJ7rKW" target="_blank" rel="noopener noreferrer">#Indexers channel</a> on Discord to let Indexers know when you&#x27;re versioning your subgraphs.</p><p>Subgraphs are open API that external developers are leveraging. Open APIs need to follow strict standards so that they do not break external developers&#x27; applications. In The Graph Network, a subgraph developer must consider Indexers and how long it takes them to sync a new subgraph <strong>as well as</strong> other developers who are using their subgraphs.</p><h3 class="anchor anchorWithStickyNavbar_31ik" id="updating-the-metadata-of-a-subgraph">Updating the Metadata of a Subgraph<a aria-hidden="true" class="hash-link" href="#updating-the-metadata-of-a-subgraph" title="Direct link to heading">​</a></h3><p>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.</p><p>Make sure <strong>Update Subgraph Details in Explorer</strong> is checked and click on <strong>Save</strong>. If this is checked, an 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.</p><h2 class="anchor anchorWithStickyNavbar_31ik" id="best-practices-for-deploying-a-subgraph-to-the-graph-network">Best Practices for Deploying a Subgraph to The Graph Network<a aria-hidden="true" class="hash-link" href="#best-practices-for-deploying-a-subgraph-to-the-graph-network" title="Direct link to heading">​</a></h2><ol><li>Leveraging an ENS name for Subgraph Development</li></ol><ul><li>Set up your ENS: <a href="https://app.ens.domains/" target="_blank" rel="noopener noreferrer">https://app.ens.domains/</a></li><li>Add your ENS name to your settings <a href="https://thegraph.com/explorer/settings?view=display-name" target="_blank" rel="noopener noreferrer">here</a>.</li></ul><p>The more filled out your profiles are, the better the chances for your subgraphs to be indexed and curated.</p><h2 class="anchor anchorWithStickyNavbar_31ik" id="deprecating-a-subgraph-on-the-graph-network">Deprecating a Subgraph on The Graph Network<a aria-hidden="true" class="hash-link" href="#deprecating-a-subgraph-on-the-graph-network" title="Direct link to heading">​</a></h2><p>Follow the steps <a href="https://thegraph.com/docs/developer/deprecating-a-subgraph" target="_blank" rel="noopener noreferrer">here</a> to deprecate your subgraph and remove it from The Graph Network.</p><h2 class="anchor anchorWithStickyNavbar_31ik" id="querying-a-subgraph--billing-on-the-graph-network">Querying a Subgraph + Billing on The Graph Network<a aria-hidden="true" class="hash-link" href="#querying-a-subgraph--billing-on-the-graph-network" title="Direct link to heading">​</a></h2><p>The Hosted Service was set up to allow developers to deploy their subgraphs without any restrictions.</p><p>In order for The Graph Network to truly be decentralized, query fees have to be paid as a core part of the protocol&#x27;s incentives. For more information on subscribing to APIs and paying the query fees, check out billing documentation <a href="https://thegraph.com/docs/studio/billing" target="_blank" rel="noopener noreferrer">here</a>.</p><h3 class="anchor anchorWithStickyNavbar_31ik" id="estimate-query-fees-on-the-network">Estimate Query Fees on the Network<a aria-hidden="true" class="hash-link" href="#estimate-query-fees-on-the-network" title="Direct link to heading">​</a></h3><p>While this is not a live feature in the product UI, you can set your maximum budget per query by taking the amount you&#x27;re willing to pay per month and divide it by your expected query volume.</p><p>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 <strong>and</strong> their price. As a consequence of that, a lower query price reduces the pool of Indexers available to you, which may affect the quality of service you receive. It&#x27;s beneficial to have high query fees, as that may attract curation and big name Indexers to your subgraph.</p><p>Remember that it&#x27;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 in 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, <a href="https://www.pickle.finance/" target="_blank" rel="noopener noreferrer">Pickle Finance</a> has 8 requests per second and paid 2.4 GRT for one week.</p><p><img alt="QueryFee" src="/docs/assets/images/QueryFee-bc028d47d1920bc37b23d22c703d823b.png"></p><h2 class="anchor anchorWithStickyNavbar_31ik" id="additional-resources">Additional Resources<a aria-hidden="true" class="hash-link" href="#additional-resources" title="Direct link to heading">​</a></h2><p>If you&#x27;re still confused, fear not! Check out the following resources or watch our video guide on migrating subgraphs to the decentralized network below:</p><iframe class="video-iframe" src="https://www.youtube.com/embed/CzdQ3dFFrjo" title="YouTube video player" frameborder="0" allowfullscreen="true"></iframe><ul><li><a href="https://github.com/graphprotocol/contracts" target="_blank" rel="noopener noreferrer">The Graph Network Contracts</a></li><li><a href="https://github.com/graphprotocol/contracts/blob/dev/contracts/curation/Curation.sol" target="_blank" rel="noopener noreferrer">Curation Contract</a> - the underlying contract that the GNS wraps around<ul><li>Address - <code>0x8fe00a685bcb3b2cc296ff6ffeab10aca4ce1538</code></li></ul></li><li><a href="https://thegraph.com/docs/studio/subgraph-studio" target="_blank" rel="noopener noreferrer">Subgraph Studio documentation</a></li></ul></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/hostedservice/query-hosted-service"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">« <!-- -->Query the Hosted Service</div></a></div><div class="pagination-nav__item pagination-nav__item--next"></div></nav></div></div><div class="col col--3"><div class="tableOfContents_35-E thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#introduction" class="table-of-contents__link toc-highlight">Introduction</a><ul><li><a href="#migrating-an-existing-subgraph-to-the-graph-network-1" class="table-of-contents__link toc-highlight">Migrating An Existing Subgraph to The Graph Network</a></li><li><a href="#upgrading-a-subgraph-on-the-network" class="table-of-contents__link toc-highlight">Upgrading a Subgraph on the Network</a></li><li><a href="#owner-upgrade-fee-deep-dive" class="table-of-contents__link toc-highlight">Owner Upgrade Fee: Deep Dive</a></li><li><a href="#maintaining-a-stable-version-of-a-subgraph" class="table-of-contents__link toc-highlight">Maintaining a Stable Version of a Subgraph</a></li><li><a href="#updating-the-metadata-of-a-subgraph" class="table-of-contents__link toc-highlight">Updating the Metadata of a Subgraph</a></li></ul></li><li><a href="#best-practices-for-deploying-a-subgraph-to-the-graph-network" class="table-of-contents__link toc-highlight">Best Practices for Deploying a Subgraph to The Graph Network</a></li><li><a href="#deprecating-a-subgraph-on-the-graph-network" class="table-of-contents__link toc-highlight">Deprecating a Subgraph on The Graph Network</a></li><li><a href="#querying-a-subgraph--billing-on-the-graph-network" class="table-of-contents__link toc-highlight">Querying a Subgraph + Billing on The Graph Network</a><ul><li><a href="#estimate-query-fees-on-the-network" class="table-of-contents__link toc-highlight">Estimate Query Fees on the Network</a></li></ul></li><li><a href="#additional-resources" class="table-of-contents__link toc-highlight">Additional Resources</a></li></ul></div></div></div></div></main></div></div><footer><div class="footer-subscribe-container_23sc"><img alt="thegraph" src="/docs/img/graph-logo.svg" width="28" height="35"></div><div class="footer-links_K5Ln"><a href="https://thegraph.com/">The Graph</a><a href="https://thegraph.com/blog">Blog</a><a href="/docs/">Docs</a><a href="https://thegraph.com/security/">Security</a><a href="https://thegraph.com/jobs/">Jobs</a></div><div class="footer-links_K5Ln footer-links__bottom_1hkt"><a href="https://thegraph.foundation/">Graph Foundation</a><a href="https://thegraph.com/hosted-service/">Hosted Service</a><a href="https://forum.thegraph.com/">Forum</a><a href="https://testnet.thegraph.com/">Testnet</a><a href="https://thegraph.com/privacy/">Privacy Policy</a><a href="https://thegraph.com/termsofuse/">Terms of Use</a></div><div class="footer-social_1c0K"><a href="https://github.com/graphprotocol" target="_blank" rel="noreferrer" class="footer-social__icon__R-X"><img alt="github" src="/docs/img/social/github-icon.svg" width="16" height="16"></a><a href="https://twitter.com/graphprotocol" target="_blank" rel="noreferrer" class="footer-social__icon__R-X"><img alt="twitter" src="/docs/img/social/twitter-icon.svg" width="16" height="16"></a><a href="https://discord.gg/vtvv7FP" target="_blank" rel="noreferrer" class="footer-social__icon__R-X"><img alt="discord" src="/docs/img/social/discord-icon.svg" width="16" height="16"></a><a href="http://t.me/graphprotocol" target="_blank" rel="noreferrer" class="footer-social__icon__R-X"><img alt="telegram" src="/docs/img/social/telegram-icon.svg" width="16" height="16"></a><a href="https://reddit.com/r/thegraph" target="_blank" rel="noreferrer" class="footer-social__icon__R-X"><img alt="reddit" src="/docs/img/social/reddit-icon.svg" width="16" height="16"></a><a href="/cdn-cgi/l/email-protection#f79e999198b7839f92908596879fd994989a" target="_blank" rel="noreferrer" class="footer-social__icon__R-X"><img alt="email" src="/docs/img/social/email-icon.svg" width="16" height="16"></a></div></footer></div></div>
<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script src="/docs/assets/js/runtime~main.0449330f.js"></script>
<script src="/docs/assets/js/main.dd7ef3b1.js"></script>
<script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"rayId":"6a3d97f7a5cc214b","token":"8aff362e136740cd82eeeb1ea39b8b0e","version":"2021.10.0","si":100}'></script>
<script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"rayId":"6a3d97f78ffb214b","token":"8aff362e136740cd82eeeb1ea39b8b0e","version":"2021.10.0","si":100}'></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment