How to index transactions? (DEPRECATED)

I’ve tried to add TransactionData as a function parameter to my indexer as the doc says, but I get the following error when building the code:

$ cargo build

error: Type with ident 'Ident { ident: "TransactionData", span: #0 bytes(1290..1305) }' not defined in the ABI.

Am I doing something wrong? Everything works on my side if I change TransactionData to BlockData though.

active toolchain
-----------------
beta-3-aarch64-apple-darwin (default)
  forc : 0.37.3
    - forc-client
      - forc-deploy : 0.37.3
      - forc-run : 0.37.3
    - forc-doc : 0.37.3
    - forc-explore : 0.28.1
    - forc-fmt : 0.37.3
    - forc-index : 0.11.2
    - forc-lsp : 0.37.3
    - forc-tx : 0.37.3
    - forc-wallet : 0.2.2
  fuel-core : 0.17.11
  fuel-indexer : 0.11.2

fuels versions
---------------
forc : 0.39

Can you share your indexer code?

Sure

extern crate alloc;
use fuel_indexer_macros::indexer;
use fuel_indexer_plugin::prelude::*;

#[indexer(manifest = "my_indexer.manifest.yaml")]
pub mod my_indexer_index_mod {
    fn handle_tx(tx: TransactionData) {
      Logger::info(format!("Tx data: {}", tx.id).as_str());
    }
}

Manifest:

---
namespace: my_namespace
abi: ~
identifier: my_indexer
fuel_client: "beta-3.fuel.network:80"
graphql_schema: schema/my_indexer.schema.graphql
module:
  wasm: target/wasm32-unknown-unknown/release/my_indexer.wasm
metrics: ~
contract_id: ~
start_block: 480000
resumable: true

I don’t think that we’ve added this as an explicit warning, but indexer functions are triggered when struct objects are received from the Fuel node; the TransactionData struct is not sent on its own from the node and is actually part of the BlockData struct. If you’d like to handle a transaction, you can grab the transactions from BlockData and do the desired work then.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.