-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathindex.js
49 lines (43 loc) · 1.09 KB
/
index.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
47
48
49
// Imports
const fs = require("fs");
const ethers = require("ethers");
const { abi } = require("./abi");
// Setup contract
const lootAddress = "0xFF9C1b15B16263C61d017ee9F65C50e4AE0113D7";
const rpc = new ethers.providers.JsonRpcProvider("http://localhost:8545");
const loot = new ethers.Contract(lootAddress, abi, rpc);
(async () => {
// In-mem retrieval
let retrievedLoot = [];
// Collect 1...8000 ids
for (let i = 1; i <= 8000; i++) {
console.log("Collecting: ", i);
// Collect parts
const [chest, foot, hand, head, neck, ring, waist, weapon] =
await Promise.all([
loot.getChest(i),
loot.getFoot(i),
loot.getHand(i),
loot.getHead(i),
loot.getNeck(i),
loot.getRing(i),
loot.getWaist(i),
loot.getWeapon(i),
]);
// Push parts to array
retrievedLoot.push({
[i]: {
chest,
foot,
hand,
head,
neck,
ring,
waist,
weapon,
},
});
}
// Write output
fs.writeFileSync("./output/loot.json", JSON.stringify(retrievedLoot));
})();