Add example task for balance with arg to STDOUT

This commit is contained in:
Oskar Thoren 2021-02-05 19:57:38 +08:00
parent bbd31b7b10
commit c0d448a932
No known key found for this signature in database
GPG Key ID: BDB55C8C0EF29911
2 changed files with 15 additions and 0 deletions

View File

@ -42,3 +42,7 @@ npx hardhat run scripts/redeem-cheque.js --network localhost
```
Now Alice has send a cheque to Bob, and Bob has received it from the Swap contract. Cheques can be sent and received off-chain, and only settled once Bob wants to.
## Example task
`npx hardhat balance --account 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266`

View File

@ -1,3 +1,5 @@
require("@nomiclabs/hardhat-web3");
require("@nomiclabs/hardhat-waffle");
// This is a sample Hardhat task. To learn how to create your own go to
@ -10,6 +12,15 @@ task("accounts", "Prints the list of accounts", async () => {
}
});
task("balance", "Prints an account's balance")
.addParam("account", "The account's address")
.setAction(async taskArgs => {
const account = web3.utils.toChecksumAddress(taskArgs.account);
const balance = await web3.eth.getBalance(account);
console.log(web3.utils.fromWei(balance, "ether"), "ETH");
});
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more