Follow transfers of a Fan Token
Track Fan Token transfer history on Chiliz Chain using subgraphs with The Graph or Goldsky: event indexing, GraphQL queries, and building a token dashboard.
Tracking Fan Token movements on Chiliz Chain is a great way to monitor the activity of your favourite tokens. By using it as a building block for a potential dashboard, you can streamline data to provide insights into what's popular and what's not.
When tracking Fan Token™movements, you quickly run into a challenge: reading data directly from the blockchain is efficient for current status ("What is the balance of wallet X?"), but inefficient for historical data ("Show me every transfer involving wallet X over the last year").
To solve this, we can use subgraphs.
About subgraphs
A Subgraph is a custom API that extracts data from a blockchain, processes it, and stores it so it can be easily queried. Instead of asking the blockchain to scan millions of blocks every time you need data, a subgraph indexes specific events as they happen and stores them in a database.
Chiliz Chain supports industry-standard indexing protocols. You can choose the provider that best fits your project's needs:
The Graph: The industry standard for decentralized indexing. It allows you to deploy your subgraph to a decentralized network of indexers.
Goldsky: A high-performance, hosted indexing service. It is fully compatible with The Graph's code (you can often use the exact same code) but offers faster indexing speeds and real-time data streaming features.
Both tools use the same development framework, so most of the steps on this page can apply to both.
Let's see for instance how we could follow transfers of the PSG Fan Token...
0. Choose a tool
You can deploy a subgraph on Chiliz Chain using The Graph (decentralized network) or Goldsky (hosted indexer). The code structure is identical; only the deployment commands differ.
Of course, you can rely on their own docs:
1. Initialize a subgraph project
Both The Graph and Goldsky offer CLI-based methods to create your graph.
Install the Graph CLI
On your local machine, run the following:
Initialize your subgraph
You can copy this directly from your subgraph page to include your specific subgraph slug:
The --studio tag is optional.
In our PSG Fan Token example, we can use:
You’ll be prompted to provide some info on your subgraph, like this:

You need to have your contract verified on the block explorer, and the CLI will automatically obtain the ABI and set up your subgraph. The default settings will generate an entity for each event.
Open subgraph.yaml and make sur your manifest file points to the correct network:
Compile your subgraph
Finally, compile your subgraph to ensure that there are no errors:
2. Deploy & Publish
Once your subgraph is built, choose your provider to deploy it.
The Graph
Connect to Subgraph Studio, create a subgraph, and copy your deploy key.
Authenticate through the CLI:
graph auth --studio <DEPLOY_KEY>Deploy your subgraph to Subgraph Studio:
graph deploy --studio <SUBGRAPH_SLUG>Go to Studio, open your subgraph and click "Publish" to mint your subgraph to the decentralized network. It'll trigger a transaction through your wallet to publish your subgraph as an NFT on the Arbitrum One network.
Goldsky
Go to Goldsky, create an API key in "Project Settings", and log in via CLI.
Install the
goldskycommand:curl https://goldsky.com | shThen authenticate through the CLI:goldsky loginUpload your subgraph to Goldsky:
goldsky subgraph deploy / --path
Goldsky subgraphs are live immediately after deployment. No extra publishing step is required.
3. Query your Subgraph
Congratulations! You can now start querying it by passing a GraphQL query into the subgraph’s query URL which can be found in the dashboard of your chosen service.
Example:
The Graph
https://gateway-arbitrum.network.thegraph.com/api/[APIKEY]/subgraphs/id/[ID]
Goldsky
https://api.goldsky.com/api/public/project_[KEY]/subgraphs/[SLUG]/1.0.0/gn
Now, you simply need to fill in your details to start sending GraphQL queries to this endpoint.
Appendices
Sample Query
This query shows all transactions of the PSG Fan Token.
Sample code
Passing this into the query URL returns this result:
Additional resources
For more information about querying data from your subgraph with GraphQL:
Last updated
Was this helpful?