-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathganache.js
More file actions
29 lines (25 loc) · 685 Bytes
/
ganache.js
File metadata and controls
29 lines (25 loc) · 685 Bytes
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
require("dotenv").config();
const ganache = require("ganache");
const Web3 = require('web3');
const options = {
account_keys_path: "ganache.json",
wallet: {
accounts: [
{
secretKey: `${process.env.PRIVATE_KEY}`,
balance: Web3.utils.toHex(`${process.env.INITIAL_BALANCE}`)
}
],
}
};
const port = parseInt(process.env.PORT) || 8545;
const server = ganache.server(options);
server.listen(port, async err => {
if (err) throw err;
console.log(`ganache listening on port ${port}...`);
const provider = server.provider;
await provider.request({
method: "eth_accounts",
params: []
}).then(accounts => console.log(accounts));
});