diff --git a/smart-contracts/advanced/fevm-indexers.md b/smart-contracts/advanced/fevm-indexers.md index 91ad7ba86..a613e845a 100644 --- a/smart-contracts/advanced/fevm-indexers.md +++ b/smart-contracts/advanced/fevm-indexers.md @@ -19,6 +19,83 @@ Blockchain indexers are used for accessing blockchain data efficiently. They pro Additionally, blockchain indexers provide a better developer experience by leveraging well-known API standards and query languages like GraphQL. +## Goldsky +[Goldsky](https://goldsky.com/) offers high-performance subgraph hosting and real-time data indexing for blockchain data. These are GraphQL-based APIs built on top of smart contracts. With Goldsky, developers can access structured blockchain data quickly and efficiently without needing to run their own nodes or build custom indexing backends. + +Goldsky officially supports the Filecoin, allowing developers to create subgraphs that index smart contract data from the Filecoin mainnet & testnet. + +**Ways to Deploy a Subgraph with Goldsky** + +**1. Goldsky Web App (No-Code)** +A visual interface that guides you step-by-step to configure and deploy a subgraph. Ideal for quick prototyping or less technical users. + +**2. Goldsky CLI (Developer Tooling)** +A command-line interface for creating, editing, and deploying subgraphs programmatically. +- From Subgraph source code +- Migrating from The Graph or any other subgraph host +- Via instant, no-code subgraphs + +In this tutorial, we will use no-code Goldsky’s deploy wizard to create a subgraph for the wFIl ERC-20 token on the Filecoin testnet. + +### Prerequisites +Make sure you have the following tools and setup ready: +- Node.js +- Create a Goldsky account and generate a Goldsky API key +- Goldsky CLI installed + ``` + curl https://goldsky.com | sh + ``` +- Authenticate Goldsky CLI with your API key + ``` + goldsky login + ``` +- wFIl Contract information + - contract address: `0xaC26a4Ab9cF2A8c5DBaB6fb4351ec0F4b07356c4` + - [contract ABI](https://beryx.io/fil/calibration/address/0xaC26a4Ab9cF2A8c5DBaB6fb4351ec0F4b07356c4?tab=contract): saved it as `wfil_abi.json` locally. + +### Deploy a subgraph +Goldsky’s Deploy Wizard simplifies the creation of subgraphs using a CLI-guided flow. + +Run: +``` +goldsky subgraph init +``` +Follow the prompts from the Goldsky subgraph configuration wizard: +- *Subgraph name*: wfil-subgraph +- *Subgraph version*: 1.0.0 +- *Subgraph target path*: Choose default or specify your own +- *Contract ABI source*: path/to/wfil_abi.json +- *Contract Address*: `0xaC26a4Ab9cF2A8c5DBaB6fb4351ec0F4b07356c4` +- *Contract network*: filecoin-testnet +- *Start block*: Which block is the wfil created, can be 0. +- *Contract name*: wfil +- *Enable subgraph call handlers?*: no + +Once you complete the above information following the prompt, the Goldsky wizard will guide you through building and deploying your subgraph. Once the subgraph is successfully deployed, Goldsky will output a deployment URL (GraphQL endpoint). + +Indexing all the data for your smart contract will take time after the subgraph is deployed. You can also check the indexing status of your subgraph from the [Goldsky dashboard](https://app.goldsky.com/). + +### Query the Subgraph +You can use the provided GraphQL endpoint to query the subgraph. + +For example: +``` +{ + transfers( + where: {from: "0xf49d33f54ce41354dcd7e698aa54256781a6dd30"} + orderBy: timestamp_ + orderDirection: desc + first: 10 + ) { + id + from + to + amount + timestamp_ + } +} +``` +Use the Goldsky Playground or integrate it into your app to consume indexed data. ## The Graph [The Graph](https://thegraph.com) is a decentralized protocol for indexing blockchain data. It enables developers to build and publish custom open APIs, known as subgraphs, that applications can query to retrieve blockchain data using GraphQL in a time-efficient manner.