From 42b2638115fb3925af0e3e05475b632ca314f03c Mon Sep 17 00:00:00 2001 From: Gabriel Cardona Date: Mon, 1 Mar 2021 14:47:48 -0800 Subject: [PATCH] Print list of accounts, fund accounts and check balances. --- README.md | 66 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/example.js | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 971967b..f0c5b16 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,29 @@ You can define custom hardhat tasks in [hardhat.config.js](./hardhat.config.js). `yarn accounts` will print the list of accounts. `yarn balances` prints the list of AVAX account balances. As with other `yarn` scripts you can pass in a `--network` flag to hardhat tasks. For example, to check the balances of the accounts on the `avash` network. +### Accounts + +Print a list of accounts. + +```zsh +yarn accounts --network avash +yarn run v1.22.4 +$ npx hardhat accounts --network avash +0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC +0x9632a79656af553F58738B0FB750320158495942 +0x55ee05dF718f1a5C1441e76190EB1a19eE2C9430 +0x4Cf2eD3665F6bFA95cE6A11CFDb7A2EF5FC1C7E4 +0x0B891dB1901D4875056896f28B6665083935C7A8 +0x01F253bE2EBF0bd64649FA468bF7b95ca933BDe2 +0x78A23300E04FB5d5D2820E23cc679738982e1fd5 +0x3C7daE394BBf8e9EE1359ad14C1C47003bD06293 +0x61e0B3CD93F36847Abbd5d40d6F00a8eC6f3cfFB +0x0Fa8EA536Be85F32724D57A37758761B86416123 +``` + +### Balances + +Print a list of accounts and their corresponding AVAX balance. ```zsh yarn balances --network avash @@ -110,6 +133,49 @@ $ npx hardhat balances --network avash Run it with `yarn send-avax`. +## Funding Accounts + +[package.json](./package.json) has a `fund-cchain-addresses` script. [fund-cchain-addresses](./scripts/fund-cchain-addresses.js) will fund each of the C-Chain `accounts` on the `avash` network with 1000 AVAX. + +```json +"scripts": { + ... + "fund-cchain-addresses": "npx hardhat run scripts/fund-cchain-addresses.js" +} +``` + +This is a utility script which handles funding accounts on the C-Chain since it's a prerequisite for running smart contracts. It's currently hardcoded to use the `12345` or `avash` network. + +```zsh +yarn fund-cchain-addresses +yarn run v1.22.4 +$ npx hardhat run scripts/fund-cchain-addresses.js +Exporting 1000 AVAX to each address on the C-Chain... +2b75ae74ScLkWe5GVFTYJoP2EniMywkcZySQUoFGN2EJLiPDgp +Importing AVAX to the C-Chain... +2dyXcQGiCk1ckCX4Fs8nLgL8GJgsM72f9Ga13rX5v9TAguVJYM +✨ Done in 4.07s. +``` + +You can confirm that it worked by running `yarn balance --network avash`. + +```zsh +yarn balances --network avash +yarn run v1.22.4 +$ npx hardhat balances --network avash +0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC has balance 1000000000000000000000 +0x9632a79656af553F58738B0FB750320158495942 has balance 1000000000000000000000 +0x55ee05dF718f1a5C1441e76190EB1a19eE2C9430 has balance 1000000000000000000000 +0x4Cf2eD3665F6bFA95cE6A11CFDb7A2EF5FC1C7E4 has balance 1000000000000000000000 +0x0B891dB1901D4875056896f28B6665083935C7A8 has balance 1000000000000000000000 +0x01F253bE2EBF0bd64649FA468bF7b95ca933BDe2 has balance 1000000000000000000000 +0x78A23300E04FB5d5D2820E23cc679738982e1fd5 has balance 1000000000000000000000 +0x3C7daE394BBf8e9EE1359ad14C1C47003bD06293 has balance 1000000000000000000000 +0x61e0B3CD93F36847Abbd5d40d6F00a8eC6f3cfFB has balance 1000000000000000000000 +0x0Fa8EA536Be85F32724D57A37758761B86416123 has balance 1000000000000000000000 +✨ Done in 0.62s. +``` + ## Hardhat Help You can run `yarn hardhat` to list hardhat version, usage instructions, global options and available tasks. diff --git a/scripts/example.js b/scripts/example.js index 10027bf..849fccd 100644 --- a/scripts/example.js +++ b/scripts/example.js @@ -2,7 +2,7 @@ const { Contract } = require("ethers"); const hre = require("hardhat"); // TODO: Enter your deployed contract address -const COIN_ADDR = "0xcB65daD78320a8d15Ad8a88001324e4e163ca534"; +const COIN_ADDR = "0x0000000000000000000000000000000000000000"; /** * Empty. Try calling some functions here.