Hosted Graph Nodes
How to create and use subgraphs on the Fantom Sonic builders testnet
What is this API for
Current solution uses Graph Node to allow developers to deploy and query their subgraphs so they can use this service for indexing data about deployed contracts, logs, and calls. Unfortunately, The Graph hosted service and Subgraph Studio don't contain the Sonic builders testnet network yet, so you have to use the CLI interface to interact with Graph Node.
Using already created subgraphs
If you already have your subgraphs created and have contracts deployed on the same addresses on the Sonic network, you can change only the network.
Creating subgraph
For creating and using subgraphs on the Sonic network, you can use this article as a guideline with more details. However, Sonic is not supported with the Graph CLI yet. There are a few things that are different.
Install the Graph CLI
The Graph CLI is written in JavaScript, and you will need to install either yarn
or npm
to use it; it is assumed that you have yarn in what follows.
Install with yarn:
Install with npm:
Init subgraph
At the moment, it is not possible to select the Sonic network, so use fantom as a network and we will replace it manually later. Fill in your GitHub user name (case sensitive) as it will be used later for authentication.
Go into the directory where your subgraph was created, open file networks.json, and rename fantom to sonic so it will look like this:
Then open file subgraph.yaml and also replace fantom with sonic:
Build your subgraph
You can change anything in your subgraph to obtain needed indexing. More details on how to do that can be found on The Graph documentation.
After you have made all the changes, you can build your subgraph:
Authorization
For deploying your subgraph to the Sonic network, you have to obtain a security token, which you will use for creating, deploying, and removing.
Obtaining this token is similar to how it's done on The Graph Hosted Service. Go to this login page and log in with your GitHub account. After you log in, you will obtain an access token, which will be used for registering, deploying, and removing actions. https://graph.public-sonic.fantom.network/service/login
Then you can store your token to the Graph CLI:
Register your subgraph
Before you can deploy your subgraph, you have to register its name:
Deploying
Finally, you can deploy your subgraph with this command:
There is information about endpoints to query your subgraph at the end of the log of the deploy proccess, but they're wrong, so please use the next section to find out how to query it.
Browsing
If everything goes well, your subgraph will be ready and you can view it in the GraphQL playground on this address:
The endpoint for your application is:
Still a work in progress
We are preparing a website similar to Hosted Service, so you will be able to see synchronization status and subgraph errors, so please check this page regularly.
Last updated