Skip to content

Instantly share code, notes, and snippets.

@ra0x3
Last active April 27, 2023 14:22
Show Gist options
  • Save ra0x3/dd3508c4e3dc982d940f3aa23f8ac468 to your computer and use it in GitHub Desktop.
Save ra0x3/dd3508c4e3dc982d940f3aa23f8ac468 to your computer and use it in GitHub Desktop.
Example indexer lib
extern crate alloc;
use fuel_indexer_macros::indexer;
use fuel_indexer_plugin::prelude::*;
#[indexer(manifest = "tech_talk.manifest.yaml")]
pub mod tech_talk_index_mod {
fn tech_talk_handler(block_data: BlockData) {
Logger::info("Processing a block. (>'.')>");
let block_id = first8_bytes_to_u64(block_data.id);
let block = Block{ id: block_id, height: block_data.height, hash: block_data.id };
block.save();
for transaction in block_data.transactions.iter() {
Logger::info("Handling a transaction (>'.')>");
let tx = Tx{ id: first8_bytes_to_u64(transaction.id), block: block_id, hash: transaction.id };
tx.save();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment