Skip to content

Commit b28003a

Browse files
committed
setup mnemonic-based accounts for generic ERC20
1 parent ddebaab commit b28003a

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

packages/hardhat/hardhat.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@ import "@nomicfoundation/hardhat-toolbox";
33
import "@nomicfoundation/hardhat-foundry";
44
import "@nomicfoundation/hardhat-ignition-ethers";
55
import "hardhat-jest"; // Typescript
6+
import { ethers } from 'ethers'
67

78
// Add the following variables to the configuration variables.
89
const ALCHEMY_API_KEY = vars.get("ALCHEMY_API_KEY");
910
const EVM_PRIVATE_KEY_1 = vars.get("EVM_PRIVATE_KEY_1");
10-
const EVM_PRIVATE_KEY_2 = vars.get("EVM_PRIVATE_KEY_2");
11+
// const EVM_PRIVATE_KEY_2 = vars.get("EVM_PRIVATE_KEY_2");
1112
const ETHERSCAN_API_KEY = vars.get("ETHERSCAN_API_KEY");
1213
const BASESCAN_API_KEY = vars.get("BASESCAN_API_KEY");
1314
const COREDAO_BLOCK_EXPLORER_API_KEY = vars.get("COREDAO_BLOCK_EXPLORER_API_KEY");
1415
const SCROLL_API_KEY = vars.get("SCROLL_API_KEY");
1516

17+
const phrase = process.env.TOKENSOFT_E2E_MNEMONIC || 'test test test test test test test test test test test junk'
18+
const mnemonic = ethers.HDNodeWallet.fromPhrase(phrase).mnemonic!
19+
20+
const wallet = ethers.HDNodeWallet.fromMnemonic(mnemonic, "m/44'/60'/0'/0/0")
21+
1622
const config: HardhatUserConfig = {
1723
solidity: {
1824
version: "0.8.21",
@@ -30,7 +36,7 @@ const config: HardhatUserConfig = {
3036
networks: {
3137
anvil: {
3238
url: 'http://localhost:8545',
33-
accounts: ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'],
39+
accounts: [wallet.privateKey]
3440
},
3541
sepolia: {
3642
url: `https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,

packages/hardhat/ignition/modules/Deploy_GenericERC20.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1+
import { ethers } from 'ethers'
12
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
23

4+
const mnemonic = process.env.TOKENSOFT_E2E_MNEMONIC || 'test test test test test test test test test test test junk'
5+
36
const DeployGenericERC20Module = buildModule("DeployGenericERC20Module", m => {
47
const _name = m.getParameter("_name", "My New Token");
58
const _symbol = m.getParameter("_symbol", "ABC");
69
const _decimals = m.getParameter("_decimals", 18);
7-
const supply = m.getParameter("supply", 1000000000000000000000000000n);
10+
const supply = m.getParameter("supply", 1_000_000_000_000000000000000000n);
811

912
const genericERC20 = m.contract("GenericERC20", [_name, _symbol, _decimals, supply]);
1013

14+
for (let i = 0; i < 10; i++) {
15+
const wallet = ethers.HDNodeWallet.fromMnemonic(
16+
ethers.HDNodeWallet.fromPhrase(mnemonic).mnemonic!
17+
, `m/44'/60'/0'/0/${i}`)
18+
m.call(genericERC20, 'transfer', [wallet.address, 1_000_000_000000000000000000n], {
19+
id: `DeployGenericERC20Module_GenericERC20_transfer${wallet.address}`
20+
})
21+
}
22+
1123
return { genericERC20 };
1224
});
1325

0 commit comments

Comments
 (0)