ethers.js v5 기준 hardhat 태스크
import { LedgerSigner } from "@anders-t/ethers-ledger";
import { task } from "hardhat/config";
task("checkHW", "Check HW Wallet")
.addOptionalPositionalParam("accountNumber", "Index of the address of the HW wallet")
.setAction(async (taskArgs) => {
const accountNumber = taskArgs.accountNumber;
const _master = new LedgerSigner(ethers.provider, `m/44'/60'/${accountNumber}'/0/0`);
_master.getFeeData = async () => {
return {
gasPrice: ethers.BigNumber.from(0),
lastBaseFeePerGas: ethers.BigNumber.from(0),
maxFeePerGas: ethers.utils.parseUnits("800", "gwei"),
maxPriorityFeePerGas: ethers.utils.parseUnits("800", "gwei"),
};
};
const master = _master;
console.log(`HW Ledger: [${accountNumber}]:${await master.getAddress()}: ${ethers.utils.formatEther(await master.getBalance())} ETH`);
});
사용은 hh checkHW 0
와 같이 한다.