Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Initial data for Contract #5

Open
vikiival opened this issue Jan 17, 2023 · 1 comment
Open

Get Initial data for Contract #5

vikiival opened this issue Jan 17, 2023 · 1 comment

Comments

@vikiival
Copy link
Owner

vikiival commented Jan 17, 2023

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)
            }
        }
    }
})
@vikiival
Copy link
Owner Author

Idea:
Just save item.event.call.args.data as jsonb
when someone will register the contract we will use that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant