33 lines
779 B
JavaScript
Raw Normal View History

const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules")
const MAX_ACCOUNTS = 20
const MINTED_TOKENS = 1_000_000_000_000_000n
module.exports = buildModule("Token", (m) => {
const deployer = m.getAccount(0)
2025-05-23 08:57:20 +02:00
let token
if (process.env.TOKEN_ADDRESS) {
token = m.contractAt("TestToken", process.env.TOKEN_ADDRESS, {})
} else {
token = m.contract("TestToken", [], {
from: deployer,
})
}
const config = hre.network.config
if (config && config.tags && config.tags.includes("local")) {
for (let i = 0; i < MAX_ACCOUNTS; i++) {
const account = m.getAccount(i)
2025-04-15 15:28:48 +02:00
m.call(token, "mint", [account, MINTED_TOKENS], {
from: deployer,
2025-05-16 20:46:23 +02:00
id: `SendingTestTokens_${i}`,
2025-04-15 15:28:48 +02:00
})
}
}
return { token }
})