forked from nicholasjpaterno/metacoin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtx.js
27 lines (22 loc) · 748 Bytes
/
tx.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
const { callbackify } = require("util");
const MetaCoin = artifacts.require("MetaCoin");
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
module.exports = callbackify(async function (...args) {
const contracts = await Promise.all([
MetaCoin.deployed(),
]);
const accounts = await web3.eth.getAccounts();
const max = 1;
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} | Sent to: ${res.receipt.to} | tx: ${res.tx}`);
});
}
}
// Make sure the logs appear even when theres not that many
await delay(2 * 60 * 1000);
});