hardhat
Version: 
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
26 lines (20 loc) • 611 B
text/typescript
import {
  Account,
  Address,
  privateToAddress,
  toBytes,
} from "@nomicfoundation/ethereumjs-util";
import { GenesisAccount } from "../node-types";
import { isHexPrefixed } from "./isHexPrefixed";
export function makeAccount(ga: GenesisAccount) {
  let balance: bigint;
  if (typeof ga.balance === "string" && isHexPrefixed(ga.balance)) {
    balance = BigInt(ga.balance);
  } else {
    balance = BigInt(ga.balance);
  }
  const account = Account.fromAccountData({ balance });
  const pk = toBytes(ga.privateKey);
  const address = new Address(privateToAddress(pk));
  return { account, address };
}