Skip to content

Commit 630a339

Browse files
committed
setup mnemonic-based accounts for generic ERC20
1 parent ba079d3 commit 630a339

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/hardhat/hardhat.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ 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");
@@ -14,6 +15,11 @@ const COREDAO_BLOCK_EXPLORER_API_KEY = vars.get("COREDAO_BLOCK_EXPLORER_API_KEY"
1415
const BSCSCAN_API_KEY = vars.get("BSCSCAN_API_KEY");
1516
const SCROLL_API_KEY = vars.get("SCROLL_API_KEY");
1617

18+
const phrase = process.env.TOKENSOFT_E2E_MNEMONIC || 'test test test test test test test test test test test junk'
19+
const mnemonic = ethers.HDNodeWallet.fromPhrase(phrase).mnemonic!
20+
21+
const wallet = ethers.HDNodeWallet.fromMnemonic(mnemonic, "m/44'/60'/0'/0/0")
22+
1723
const config: HardhatUserConfig = {
1824
solidity: {
1925
version: "0.8.21",
@@ -31,7 +37,7 @@ const config: HardhatUserConfig = {
3137
networks: {
3238
anvil: {
3339
url: 'http://localhost:8545',
34-
accounts: ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'],
40+
accounts: [wallet.privateKey]
3541
},
3642
sepolia: {
3743
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)