Project Structure
This page provides an overview of the project structure of a blockflow project. It covers top-level files and folders, configuration file, and schema file.
Click the file and folder names to learn more about each convention.
Top-Level Folders
After completing the project initiation step, the CLI generates a folder structure with all the necessary boilerplate code set up. Let's explore this folder structure in detail:
studio.yaml
The studio.yaml
file is a crucial component of your project. It serves as the main configuration file, defining the structure and behaviour of your indexer.
This YAML file specifies the details of the subgraph, including:
The blockchain network it will connect to (e.g., Ethereum, Polygon, etc.)
The smart contracts it will index and their addresses
The events and data entities to be indexed from those contracts
The mapping functions that transform the raw blockchain data into the desired format
studio.schema.ts
The studio.schema.ts
file is a TypeScript file responsible for defining the data model or schema of your database. It specifies the entities and their relationships within the indexed blockchain data.
In this file, you define the structure of the data entities that will be stored in the database. These entities represent the various types of data you want to index from the blockchain, such as smart contracts, events, and any relevant data associated with them.
Remember no comments are allowed in studio.schema.ts
Once done with defining the schema. You need to run below code to get started.
A types
folder will generated inside src folder containing schema.ts
file.
handlers
The mapping functions defined in the handlers
directory are automatically triggered and executed whenever a specific event or function is emitted or called on the blockchain. Each mapping function is associated with a particular event or function from the smart contracts being indexed defined in studio.yaml
file.
To generate boilerplate code for these handler use below command.
Here, an example of handler's boilerplate code.
We will dive deeper into this code in handlers section.
abis
The abis
folder is used to store the Application Binary Interface (ABI) files for the smart contracts being indexed.