Open vikiival opened 1 year ago
Example
import {SubstrateBatchProcessor} from "@subsquid/substrate-processor" import {TypeormDatabase} from "@subsquid/typeorm-store" import * as erc20 from "./erc20" const CONTRACT_ADDRESS = '0x5207202c27b646ceeb294ce516d4334edafbd771f869215cb070ba51dd7e2c72' const processor = new SubstrateBatchProcessor() .setDataSource({ archive: "https://shibuya.archive.subsquid.io/graphql" }) .addEvent( 'Contracts.Instantiated', { range: {from: 1000000, to: 1000000}, // block number where your contract was deployed data: {call: {args: true}}, } ) processor.run(new TypeormDatabase(), async ctx => { for (let block of ctx.blocks) { for (let item of block.items) { if (item.kind == 'event' && item.name == 'Contracts.Instantiated' && item.event.args.contract == CONTRACT_ADDRESS) { erc20.decodeConstructor(item.event.call.args.data) } } } })
Idea: Just save item.event.call.args.data as jsonb when someone will register the contract we will use that
Example