The Graph is a decentralized protocol for indexing and querying data from blockchains, starting with Ethereum. Fantom Opera now supports this API of making subgraphs and query data with graphql thru this hosted service. It makes it possible to query data that is difficult to query directly. More information can be found here.
Fantom Opera chain now also supports Call Handlers, so they can be used in any subgraph deployed to hosted service. You can experience longer times during intitial indexation of the subgraph, so we recomend to limit indexing interval with start block in subgraph manifest file.
dataSources:- kind: ethereum/contractname: ExampleSourcenetwork: fantomsource:address: '0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95'abi: ExampleContractstartBlock: 3037823mapping:
Once history indexing is done, performace is not affected.
Purpose of this tutorial is not to describe, how to create mappings between smart contracts and final graphql requests, but how to use hosted service to deploy created subgraph and make it accessible to the world. If you want to start from scratch, please use this documentation to define a new subgraph.
Go to The Graph Explorer page. In the top right corner, there is a button to Sign In with Github. After successful login, you will see your Github account profile picture. Click it and selecet Dashboard.
In your Dashboard, click Add Subgraph button on the right side. Fill in the specified mandatory fields, which are subgraph name and subtitle. Select your github account. When you will be filling subgraph name, you can see the URL which will be used for it in future, something like thegraph.com/explorer/<github_name>/<subgraph_name>. Click Create subgraph button. Then you will see it in your Dashboard.
In your subgraph project, there is a manifest file in the root folder, called subgraph.yaml or similar name according to configuration. Inside you have to specify network name as a target. For Fantom Opera chain is the name fantom.
# ...dataSources:- kind: ethereum/contractname: Gravitynetwork: fantomsource:address: '0x50DD37ac4fC2D7FbaafC07131D9Fe9788dc9df90'abi: Gravitymapping:kind: ethereum/events
Use Yarn or NPM to install graph command line interface
yarn global add @graphprotocol/graph-cli
Then you need your access token, to be able to authorize. You can find it in your Dashboard on the explorer page. Then for deploy it self use this command.
graph deploy --access-token '<access_token>' --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ <github_name/subgraph_name> subgraph.yaml
And that's all. If everything was successful, then you can try your graphql requests from GUI in your subgraph details page accessible from Dashboard. There is also a tab called Logs, so you can see output of the service.