From 7398ac9bbcdea80fdebe7bf1085c1ee4578de56a Mon Sep 17 00:00:00 2001 From: Ayanami Date: Thu, 27 Jan 2022 15:17:19 +0900 Subject: [PATCH] Don't use await for encodeABI() since it is not a promise --- cli.js | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/cli.js b/cli.js index 2ac2a21..af54652 100755 --- a/cli.js +++ b/cli.js @@ -42,16 +42,19 @@ function toHex(number, length = 32) { /** Display ETH account balance */ async function printETHBalance({ address, name }) { - console.log(`${name} balance is`, web3.utils.fromWei(await web3.eth.getBalance(address)),`${netSymbol}`) + const checkBalance = await web3.eth.getBalance(address) + console.log(`${name} balance is`, web3.utils.fromWei(checkBalance),`${netSymbol}`) } /** Display ERC20 account balance */ async function printERC20Balance({ address, name, tokenAddress }) { const erc20ContractJson = require('./build/contracts/ERC20Mock.json') erc20 = tokenAddress ? new web3.eth.Contract(erc20ContractJson.abi, tokenAddress) : erc20 - balance = await erc20.methods.balanceOf(address).call() - decimals = await erc20.methods.decimals().call() - console.log(`${name}`,(await erc20.methods.name().call()),`Token Balance is`,toDecimals(balance, decimals, (balance.length + decimals)).toString().replace(/\B(?