Created
June 28, 2023 17:30
-
-
Save cgcardona/b70fc9e72d7dd21ac2e4544735a4b636 to your computer and use it in GitHub Desktop.
Config file for using Hardhat with Avalanche. More info: https://hardhat.org. https://docs.avax.network.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { task } from "hardhat/config" | |
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers" | |
import { BigNumber } from "ethers" | |
import "@nomiclabs/hardhat-waffle" | |
// When using the hardhat network, you may choose to fork Fuji or Avalanche Mainnet | |
// This will allow you to debug contracts using the hardhat network while keeping the current network state | |
// To enable forking, turn one of these booleans on, and then run your tasks/scripts using ``--network hardhat`` | |
// For more information go to the hardhat guide | |
// https://hardhat.org/hardhat-network/ | |
// https://hardhat.org/guides/mainnet-forking.html | |
const FORK_FUJI = false | |
const FORK_MAINNET = false | |
const forkingData = FORK_FUJI ? { | |
url: 'https://api.avax-test.network/ext/bc/C/rpc', | |
} : FORK_MAINNET ? { | |
url: 'https://api.avax.network/ext/bc/C/rpc' | |
} : undefined | |
task("accounts", "Prints the list of accounts", async (args, hre): Promise<void> => { | |
const accounts: SignerWithAddress[] = await hre.ethers.getSigners() | |
accounts.forEach((account: SignerWithAddress): void => { | |
console.log(account.address) | |
}) | |
}) | |
task("balances", "Prints the list of AVAX account balances", async (args, hre): Promise<void> => { | |
const accounts: SignerWithAddress[] = await hre.ethers.getSigners() | |
for(const account of accounts){ | |
const balance: BigNumber = await hre.ethers.provider.getBalance( | |
account.address | |
); | |
console.log(`${account.address} has balance ${balance.toString()}`); | |
} | |
}) | |
export default { | |
solidity: { | |
compilers: [ | |
{ | |
version: "0.5.16" | |
}, | |
{ | |
version: "0.6.2" | |
}, | |
{ | |
version: "0.6.4" | |
}, | |
{ | |
version: "0.7.0" | |
}, | |
{ | |
version: "0.8.0" | |
} | |
] | |
}, | |
networks: { | |
hardhat: { | |
gasPrice: 225000000000, | |
chainId: !forkingData ? 43112 : undefined, //Only specify a chainId if we are not forking | |
forking: forkingData | |
}, | |
local: { | |
url: 'http://localhost:9650/ext/bc/C/rpc', | |
gasPrice: 225000000000, | |
chainId: 43112, | |
accounts: [ | |
"0x56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027" | |
] | |
}, | |
fuji: { | |
url: 'https://api.avax-test.network/ext/bc/C/rpc', | |
gasPrice: 225000000000, | |
chainId: 43113, | |
accounts: [] | |
}, | |
mainnet: { | |
url: 'https://api.avax.network/ext/bc/C/rpc', | |
gasPrice: 225000000000, | |
chainId: 43114, | |
accounts: [] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment