forked from nicholasjpaterno/metacoin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoverload.js
35 lines (30 loc) · 1.02 KB
/
overload.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
const { callbackify } = require("util");
const MetaCoin = artifacts.require("MetaCoin");
const MetaCoin2 = artifacts.require("MetaCoin2");
const MetaCoin3 = artifacts.require("MetaCoin3");
const MetaCoin4 = artifacts.require("MetaCoin4");
const MetaCoin5 = artifacts.require("MetaCoin5");
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
module.exports = callbackify(async function (...args) {
const contracts = await Promise.all([
MetaCoin.deployed(),
MetaCoin2.deployed(),
MetaCoin3.deployed(),
MetaCoin4.deployed(),
MetaCoin5.deployed(),
]);
const accounts = await web3.eth.getAccounts();
const max = 10;
let j = 0;
for (let i = 0; i < max; i++) {
for (let contract of contracts) {
j++;
console.log(`${j} | Sending...`);
await contract.sendCoin(accounts[1], 1).then((res) => {
console.log(`${j} | to: ${res.receipt.to} | tx: ${res.tx}`);
});
}
}
// Make sure the logs appear even when theres not that many
await delay(2 * 60 * 1000);
});