Indexing transaction receipts
In this step-by-step tutorial we will look into a squid that indexes Fuel Network data. Pre-requisites: Node.js v20 or newer, Git, Docker.Download the project
Begin by retrieving the template and installing the dependencies:Configuring the data source
“Data source” is a component that defines what data should be retrieved and where to get it. To configure the data source to retrieve the data produced by thereceipt field of the fuel transaction, we initialize it like this:
src/main.ts
https://v2.archive.subsquid.io/network/fuel-mainnetis the address for the public SQD Network gateway for Fuel. Check out the exhaustive public gateways list.- The argument of
addReceipt()is a set of filters that tells the processor to retrieve all receipts of typeLOG. - The argument of
setFields()specifies the exact fields we need for every data item type. In this case we requestcontractandreceiptTypefor receipt data items.
FuelDataSource reference and the comments in main.ts of the fuel-example repo.
With a data source it becomes possible to retrieve filtered blockchain data from SQD Network, transform it and save the result to a destination of choice.
Decoding the event data
The other part of the squid processor (the ingester process of the indexer) is the callback function used to process batches of the filtered data, the batch handler. In Fuel Squid SDK it is typically defined within arun() call, like this:
dataSourceis the data source object described in the previous sectiondatabaseis aDatabaseimplementation specific to the target data sink. We want to store the data in a PostgreSQL database and present with a GraphQL API, so we provide aTypeormDatabaseobject here.ctxis a batch context object that exposes a batch of data (atctx.blocks) and any data persistence facilities derived fromdb(atctx.store). See Block data for Fuel for details on how the data batches are presented.
src/main.ts
LOG_DATA", reads the contract field from the receipt and saves it to the database.
At this point the squid is ready for its first test run. Execute

