diff --git a/README.md b/README.md index 2c0c004..f4d8643 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/hardhat.config.js b/hardhat.config.js index c51cfb9..5dcb850 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -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