-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
46 lines (36 loc) · 1.36 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const CampaignFactory = require("./artifacts/contracts/Campaign.sol/CampaignFactory.json");
const Campaign = require("./artifacts/contracts/Campaign.sol/Campaign.json");
const { ethers } = require("ethers");
require("dotenv").config({ path: "./.env.local" });
const main = async () => {
// const provider = new ethers.providers.JsonRpcProvider(
// process.env.NEXT_PUBLIC_RPC_URL
// );
// const contract = new ethers.Contract(
// process.env.NEXT_PUBLIC_ADDRESS,
// CampaignFactory.abi,
// provider
// );
// const getDeployedCampaign = contract.filters.campaignCreated(null,null,null,null,null,null,'Health');
// let events = await contract.queryFilter(getDeployedCampaign);
// let event = events.reverse();
// console.log(event);
const provider = new ethers.providers.JsonRpcProvider(
process.env.NEXT_PUBLIC_RPC_URL
);
const contract = new ethers.Contract(
"0x813b7E7972D4E64D0481BA48517bCe4df480d51e",
Campaign.abi,
provider
);
const Donations = contract.filters.donated('0xc538779A628a21D7CCA7b1a3E57E92f5226C3E27');
const AllDonations = await contract.queryFilter(Donations);
const DonationsData = AllDonations.map((e) => {
return {
donar: e.args.donar,
amount: parseInt(e.args.amount),
timestamp : parseInt(e.args.timestamp)
}});
console.log(DonationsData);
};
main();