Configuring YAML

The studio.yaml is the entry point to your project. It defines the smart contracts you index, which events/functions from these contracts to pay attention to, and how to map their data to entities that are stored and allowed to query.

name: cli-demo
description: a project to showcase cli working
startBlock: latest
userId: XXXXXXXX-XXXX-XXXX-XXXXXXXX-XXXXXXXX
projectId: XXXXXXXX-XXXX-XXXX-XXXXXXXX-XXXXXXXX
network: Ethereum
user: Jane-doe
schema:
  file: ./studio.schema.ts
execution: parallel
Resources:
  - Name: usdt
    Abi: src/abis/usdt.json
    Type: contract/event
    Address: "0xdAC17F958D2ee523a2206206994597C13D831ec7"
    Triggers:
      - Event: Transfer(address indexed,address indexed,uint256)
        Handler: src/handlers/usdt/Transfer.TransferHandler
        

FieldDescription

name

This is the name of your project.

description

A brief description of what your project does.

startBlock

The block number from which you want to start indexing. You can specify a specific block number or use “latest” to start from the most recent block.

userId

Unique identifiers for your Blockflow user account.

projectId

Unique identifiers for your Blockflow project.

network

The blockchain network you’re working with.

user

The Blockflow username associated with your account.

schema

It contains a file path to your database schemas.

execution

It tells our system how to run the indexing process over the specified block range. You can choose between “parallel” or “sequential” execution.

resources

This section defines the smart contracts you want to index.


Supported Network

The command-line interface (CLI) supports multiple networks for deployment and interaction. When using the CLI, you can specify the target network environment for your operations.

export const SUPPORTED_NETWORK = [
  "Ethereum",
  "Linea",
  "Optimism",
  "Polygon",
  "Avalanche",
  "Base",
  "Arbitrum",
  "Manta",
  "Zkevm",
  "Scroll",
  "Bsc",
];

You can use Blockflow CLI to run instance tests on any network with an available RPC endpoint. Choose a network with an accessible RPC endpoint and use Blockflow CLI to run your instance tests on that network.

Note: Currently, we only support deployments to above networks. However, we are actively expanding our supported chain list.


Resources

Within the resources section, you can define one or more data sources, each representing a specific blockchain network or smart contract. For each data source, you can provide the following details:

FieldDescription

Name

The name of the source data.

Abi

The path to the smart contract's ABI file. The ABI defines the contract’s interface and is used to interact with it.

Type

The type of resource.

Address

The address of the source data.

Triggers

It contains an array of configurations linking smart contract events/functions to their corresponding handler functions.


Type

Blockflow allows you to define the type of resource you want to index based on the triggers you need. The platform supports a wide range of trigger types, enabling you to customize your subgraph instances according to your specific requirements.

  1. contract/event: This resource type allows you to set up a trigger that executes an action when a specific event is emitted by a smart contract. For example, you can index the data associated with a token transfer event or track updates to a particular state variable in a contract.

  2. contract/function:With this resource type, you can execute an action when a particular function in a smart contract is called. This can be useful for indexing the input and output data of a function call, tracking state changes, or monitoring specific smart contract interactions.

  3. transaction/event: This resource type enables you to set up a trigger based on transactions occurring on the blockchain. This can be helpful for tracking and indexing data related to specific types of transactions, such as token transfers, contract deployments, or any other relevant transaction events.

  4. api/rest: Allows you to create a RESTful API interface for accessing and manipulating data in your existing databases.

  5. api/graphql: Enables the creation of a custom GraphQL API endpoint to interact with your project's databases.


Triggers

The triggers section contains an array of configurations linking smart contract events/functions to their corresponding handler functions. Each configuration maps an event/function to the handler executed when triggered.

It vary according to Type of resource.

  • contract/event

Triggers:
      - Event: Transfer(address indexed,address indexed,uint256)
        Handler: src/handlers/usdt/Transfer.TransferHandler
  • contract/function

Triggers:
      - Function: approve(address,uint256)
        Handler: src/handlers/usdt/approve.approveHandler
  • transaction/event

Triggers:
      - Event: Transfer(address indexed,address indexed,uint256)
        Handler: src/handlers/usdt/Transfer.TransferHandler

You don't need to define address in Resources for transaction/event type.

Once you define the name, address, type, and ABI path for your smart contracts in the resources section, you can use the blockflow generate command to automatically populate the trigger configurations.


Points to Consider While Writing subgraph.yaml

  1. Handler File Paths: Ensure handler file paths in the Triggers section match the actual file locations. Incorrect paths will cause webpack errors.

  2. Handler Definition: Define all handler functions at their respective file paths specified in the subgraph.yaml. Missing handlers will result in errors.

  3. Event Parameter Formatting: Write event parameter types without spaces, e.g., MessageReceived(address indexed,uint32,uint64 indexed,bytes32,bytes). Improper formatting can lead to indexing errors. Same for functions.

Last updated