Skip to content

Include this one trick to speed up event tracking #3

@fulldecent

Description

@fulldecent

One trick that I use in production is not shown here.

Current code:

    const outputs = await this.contract.getPastEvents("Transfer", {
      fromBlock: 0,
      toBlock: "latest",
      topics: [
        sha3("Transfer(address,address,uint256)"),
        padLeft(owner, 64),
        null
      ]
    });

    const inputs = await this.contract.getPastEvents("Transfer", {
      fromBlock: 0,
      toBlock: "latest",
      topics: [
        sha3("Transfer(address,address,uint256)"),
        null,
        padLeft(owner, 64)
      ]
    });

If you change fromBlock to the contract deployment block then events come 2x–10x faster.

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