Skip to content

Add Goldsky tutorial of creating subgraph for Filecoin #2392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions smart-contracts/advanced/fevm-indexers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down