forked from sushi-labs/sushiswap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccounts.js
23 lines (17 loc) · 866 Bytes
/
accounts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { normalizeHardhatNetworkAccountsConfig } = require("hardhat/internal/core/providers/util")
const { BN, bufferToHex, privateToAddress, toBuffer } = require("ethereumjs-util")
module.exports = async function (taskArguments, hre, runSuper) {
const networkConfig = hre.config.networks["mainnet"]
console.log(networkConfig.accounts)
const accounts = normalizeHardhatNetworkAccountsConfig(networkConfig.accounts)
console.log("Accounts")
console.log("========")
for (const [index, account] of accounts.entries()) {
const address = bufferToHex(privateToAddress(toBuffer(account.privateKey)))
const privateKey = bufferToHex(toBuffer(account.privateKey))
const balance = new BN(account.balance).div(new BN(10).pow(new BN(18))).toString(10)
console.log(`Account #${index}: ${address} (${balance} ETH)
Private Key: ${privateKey}
`)
}
}