/ examples / mongo / starknet_to_mongo.js
starknet_to_mongo.js
 1  // Before running this script, you must start a local MongoDB server.
 2  // See README.md for instructions.
 3  import { decodeTransfersInBlock, filter } from "../common/starknet.js";
 4  
 5  // Configure indexer for streaming Starknet Goerli data starting at the specified block.
 6  export const config = {
 7    streamUrl: "https://goerli.starknet.a5a.ch",
 8    startingBlock: 800_000,
 9    network: "starknet",
10    filter,
11    sinkType: "mongo",
12    sinkOptions: {
13      database: "example",
14      collectionName: "transfers",
15    },
16    // Restrict invalidate queries to the specified network and symbol.
17    // This is useful if you are running multiple indexers on the same database.
18    invalidate: {
19      network: "starknet-goerli",
20      symbol: "ETH",
21    },
22  };
23  
24  // Transform each block using the function defined in starknet.js.
25  export default decodeTransfersInBlock;