⌘K

Icon SunFilledIcon MoonStars
Project Components

Icon LinkA Fuel Indexer Project

Icon LinkUse Cases

The Fuel indexer project can currently be used in a number of different ways:

  • as tooling to interact with indexers
  • as a standalone service
  • as a part of a larger Fuel project, alongside other components of the Fuel ecosystem (e.g. Sway smart contracts Icon Link)

We'll describe these three different use cases below.

Icon LinkAs tooling to interact with indexers

The Fuel indexer provides functionality to make it easy to build and compile abitrary indexers by using the forc index CLI tool. Using forc index, users can create, build, deploy, and remove indexers, as well as authenticate against a running indexer service, and check the status of running indexers.

Icon LinkExample

Create, deploy, and check the status of a new indexer.

forc index new fuel && \
    cd fuel && forc index deploy --url http://indexer.fuel.network && \
        forc index status --url http://indexer.fuel.network --auth $MY_TOKEN

Icon LinkAs a standalone service

You can also start the Fuel indexer as a standalone service that connects to a Fuel node in order to monitor the Fuel blockchain for new blocks and transactions. To do so, run the requisite database migrations, adjust the configuration to connect to a Fuel node, and start the service.

Icon LinkExample

Create, deploy, and check the status of a new indexer.

fuel-indexer run \
    --fuel-node-host beta-4.fuel.network \
    --fuel-node-port 80 \
    --run-migrations \
    --accept-sql-queries \
    --replace-indexer

Icon LinkAs part of a Fuel project

Finally, you can run the Fuel indexer as part of a project that uses other components of the Fuel ecosystem, such as Sway. The convention for a Fuel project layout including an indexer is as follows:

.
├── contracts
│   └── hello-contract
│       ├── Forc.toml
│       └── src
│           └── main.sw
├── frontend
│   └── index.html
└── indexer
    └── hello-indexer
        ├── Cargo.toml
        ├── hello_indexer.manifest.yaml
        ├── schema
        │   └── hello_indexer.schema.graphql
        └── src
            └── lib.rs

Icon LinkAn Indexer Project at a Glance

Every Fuel indexer project requires three components:

  • a Manifest describing how the indexer should work
  • a Schema containing data models for the data that is to be indexed
  • a Module which contains the logic for how data coming from the FuelVM should be saved into an index