Skip to content

Get Initial data for Contract  #5

Description

@vikiival

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)
            }
        }
    }
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions