Skip to content

Commit

Permalink
Print list of accounts, fund accounts and check balances.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgcardona committed Mar 1, 2021
1 parent 391504f commit e92e9f3
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion scripts/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e92e9f3

Please sign in to comment.