5 minutos
Como Implantar com o Subgraph Studio
Learn how to deploy your Subgraph to Subgraph Studio.
Note: When you deploy a Subgraph, you push it to Subgraph Studio, where you’ll be able to test it. It’s important to remember that deploying is not the same as publishing. When you publish a Subgraph, you’re publishing it onchain.
Visão Geral do Subgraph Studio
No Subgraph Studio, você pode fazer o seguinte:
- View a list of Subgraphs you’ve created
- Manage, view details, and visualize the status of a specific Subgraph
- Create and manage your API keys for specific Subgraphs
- Restringir as suas chaves de API a domínios específicos e permitir que apenas certos indexadores façam queries com eles
- Create your Subgraph
- Deploy your Subgraph using The Graph CLI
- Test your Subgraph in the playground environment
- Integrate your Subgraph in staging using the development query URL
- Publish your Subgraph to The Graph Network
- Gerir o seu faturamento
Instalar a CLI do The Graph
Antes de implantar, você deve instalar a Graph CLI (CLI do The Graph).
É necessário ter Node.js e um gerenciador de pacotes da sua escolha (npm
, yarn
ou pnpm
) instalados, para utilizar a Graph CLI. Verifique a versão mais recente da CLI.
Instalação com o yarn
1yarn global add @graphprotocol/graph-cli
Instalação com o npm
1npm install -g @graphprotocol/graph-cli
Como Começar
- Abra o Subgraph Studio.
- Conecte a sua carteira para fazer login.
- É possível fazer isso via MetaMask, Carteira da Coinbase, WalletConnect, ou Safe.
- After you sign in, your unique deploy key will be displayed on your Subgraph details page.
- The deploy key allows you to publish your Subgraphs or manage your API keys and billing. It is unique but can be regenerated if you think it has been compromised.
Important: You need an API key to query Subgraphs
Como Criar um Subgraph no Subgraph Studio
Para mais detalhes, consulte o Guia de Início Rápido.
Compatibilidade de Subgraph com a Graph Network
To be supported by Indexers on The Graph Network, Subgraphs must index a supported network. For a full list of supported and unsupported features, check out the Feature Support Matrix repo.
Como inicializar o seu Subgraph
Once your Subgraph has been created in Subgraph Studio, you can initialize its code through the CLI using this command:
1graph init <SUBGRAPH_SLUG>
You can find the <SUBGRAPH_SLUG>
value on your Subgraph details page in Subgraph Studio, see image below:

After running graph init
, you will be asked to input the contract address, network, and an ABI that you want to query. This will generate a new folder on your local machine with some basic code to start working on your Subgraph. You can then finalize your Subgraph to make sure it works as expected.
Autenticação
Before you can deploy your Subgraph to Subgraph Studio, you need to log into your account within the CLI. To do this, you will need your deploy key, which you can find under your Subgraph details page.
Em seguida, use o seguinte comando para autenticar a partir da CLI:
1graph auth <DEPLOY KEY>
Como Implantar um Subgraph
Once you are ready, you can deploy your Subgraph to Subgraph Studio.
Deploying a Subgraph with the CLI pushes it to the Studio, where you can test it and update the metadata. This action won’t publish your Subgraph to the decentralized network.
Use the following CLI command to deploy your Subgraph:
1graph deploy <SUBGRAPH_SLUG>
Após executar este comando, a CLI solicitará um número de versão.
- É altamente recomendado usar o semver para números de versão, como
0.0.1
. Dito isto, dá para escolher qualquer string como versão, por exemplo:v1
,version1
,asdf
. - Os nomes de versão criados serão visíveis no Graph Explorer, e podem ser usados pelos curadores para decidir se querem ou não sinalizar numa versão específica, então escolha com sabedoria.
Como Testar o Seu Subgraph
After deploying, you can test your Subgraph (either in Subgraph Studio or in your own app, with the deployment query URL), deploy another version, update the metadata, and publish to Graph Explorer when you are ready.
Use Subgraph Studio to check the logs on the dashboard and look for any errors with your Subgraph.
Edite o Seu Subgraph
In order to publish your Subgraph successfully, review publishing a Subgraph.
Como Fazer Versões do Seu Subgraph com a CLI
If you want to update your Subgraph, you can do the following:
- Você pode implantar uma nova versão para o Studio com a CLI (no momento, só será privada).
- Quando o resultado estiver satisfatório, você poderá editar a sua nova implantação para o Graph Explorer.
- This action will create a new version of your Subgraph that Curators can start signaling on and Indexers can index.
You can also update your Subgraph’s metadata without publishing a new version. You can update your Subgraph details in Studio (under the profile picture, name, description, etc.) by checking an option called Update Details in Graph Explorer. If this is checked, an onchain transaction will be generated that updates Subgraph details in Explorer without having to publish a new version with a new deployment.
Note: There are costs associated with publishing a new version of a Subgraph to the network. In addition to the transaction fees, you must also fund a part of the curation tax on the auto-migrating signal. You cannot publish a new version of your Subgraph if Curators have not signaled on it. For more information, please read more here.
Arquivamento Automático de Versões de Subgraphs
Whenever you deploy a new Subgraph version in Subgraph Studio, the previous version will be archived. Archived versions won’t be indexed/synced and therefore cannot be queried. You can unarchive an archived version of your Subgraph in Subgraph Studio.
Note: Previous versions of non-published Subgraphs deployed to Studio will be automatically archived.
