/
05_event_logs
24 lines (17 loc) · 801 Bytes
/
05_event_logs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { ethers } = require("ethers");
const provider = new ethers.JsonRpcProvider(`https://mainnet.infura.io/v3/8b9750710d56460d940aeff47967c4ba`);
const ERC20_ABI = [
"function name() view returns (string)",
"function symbol() view returns (string)",
"function totalSupply() view returns (uint256)",
"function balanceOf(address) view returns (uint)",
"event Transfer(address indexed from, address indexed to, uint amount)"
];
const address = '0x6B175474E89094C44Da98b954EedeAC495271d0F' // DAI Contract
const contract = new ethers.Contract(address, ERC20_ABI, provider)
const main = async () => {
const block = await provider.getBlockNumber()
const transferEvents = await contract.queryFilter('Transfer', block - 20, block)
console.log(transferEvents)
}
main()