Skip to content

Events

Events

var MyContract = new ethers.Contract(contract_addresses[0], ERC721_abi, provider)
// Old Way
try{
    let events_listed = await provider.getLogs({
        address: contract_addresses[1],
        fromBlock: 13000001,
        toBlock:13100001
    })
        console.log(events_listed)
}
catch(err) {
    console.log(err)
    console.log("ERC-165 not supported")
}
// Another Example
my_events = await provider.getLogs({
    fromBlock: 13000000,
    toBlock: 13000100,
    topics: [ethers.utils.id("Transfer(address,address,uint256)")]
})
// New Way
try{
    let events_listed = await MyContract.queryFilter({
        events_listed: [
            MyContract.filters[0]
        ],
    }, 13018622, 13109622)
    console.log(events_listed)
}
catch(err) {
    console.log(err)
    console.log("ERC-165 not supported")
}

Resent Blocks

Block tags may be given as negative numbers in filters and Provider API calls; for example, erc20Token.queryFilter("Transfer", -1234) will find all ERC-20 transfer events in the last 1,234 blocks. * Beta Release: ethers.js v5. It’s been a while since a new version… | by RicMoo | RicMoo