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.
Key Sections:
Version: This is a mandatory field for CLI version 2.0.0 or higher. It specifies the template version used to define the project template.
Type: Indicates whether the project template contains
api
orinstance
resources, which dictates how testing and deployment processes will be handled.Metadata: Contains project metadata such as the project name and description. This information is useful for identifying and documenting your project.
Auth: Stores your Blockflow credentials, including the access key, secret key, user ID, and project ID. These are required for authentication and authorisation within the project.
Path: Specifies the file paths for important project files, such as the schema (
studio.schema.ts
) and Docker Compose configuration (docker-compose.yml
).Environment: Defines the environment settings for testing and deployment. This includes the blockchain network, execution mode (e.g., parallel), the RPC endpoint, and block range.
Resources: Specifies the smart contracts you want to index or the APIs you intend to build, depending on the template type. For example, it includes contract addresses, ABI files, and event handlers associated with the contract.
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.
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. 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 resources types, enabling you to customize your instances according to your specific requirements.
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.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.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.api/rest
: Allows you to create a RESTful API interface for accessing and manipulating data in your existing databases.api/graphql
: Enables the creation of a custom GraphQL API endpoint to interact with your project's databases.
name
The name of the source data.
type
The type of resource.
abi
The path to the smart contract's ABI file. The ABI defines the contract’s interface and is used to interact with it.
address
The address of the source data.
triggers
It contains an array of configurations linking smart contract events/functions to their corresponding handler functions.
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
contract/function
transaction/event
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 studio.yaml
Handler File Paths: Ensure handler file paths in the
Triggers
section match the actual file locations. Incorrect paths will cause webpack errors.Handler Definition: Define all handler functions at their respective file paths specified in the
subgraph.yaml
. Missing handlers will result in errors.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.
After completing your YAML file, it's recommended to run the blockflow validate
command before proceeding. This command ensures that your studio.yaml
file is correctly configured and free of errors.
Last updated