This repository has been archived by the owner on Jun 23, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
faucet.js
executable file
·50 lines (43 loc) · 1.52 KB
/
faucet.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
50
#!/usr/bin/env node
'use strict';
const ethers = require('ethers');
async function deploy () {
const FAUCET = require('./build/contracts/Faucet.json');
const provider = ethers.getDefaultProvider('ropsten');
const wallet = new ethers.Wallet(
'0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200'
).connect(provider);
const contract = new ethers.ContractFactory(FAUCET.abi, FAUCET.bytecode, wallet);
const faucet = await contract.deploy();
const tx = await faucet.deployTransaction.wait();
console.log(wallet.address);
console.log(faucet.address);
}
(async function () {
const provider = new ethers.providers.JsonRpcProvider('http://localhost:8000');
const wallet = ethers.Wallet.createRandom().connect(provider);
const faucet = new ethers.Contract(
// Faucet contract on ropsten
'0x0ab5ca008a524fa5160ddb0323f8632ec357a0db',
[
'event Transfer(address indexed from, address indexed to, uint256 value)',
// get some tokens
'function drain()',
// register a token
'function sink(address)',
],
wallet
);
console.log(wallet.address);
// this gets us one (10 ** 18) token for every registered ERC20 (if the faucet has enough balance)
const tx = await (await faucet.drain()).wait();
console.log(tx);
tx.events.forEach(
function (event) {
console.log(event.eventSignature);
console.log(event.args);
}
);
// this registers a token
// const tx = await (await faucet.sink('0x3D09885E87182933e7798C61472D7AD6581293B5')).wait();
})();