32 lines
795 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) => {
2025-05-23 08:57:20 +02:00
let token
if (process.env.TOKEN_ADDRESS) {
2025-05-29 15:38:57 +02:00
console.log(
"Using existing TestToken on address: ",
process.env.TOKEN_ADDRESS,
)
2025-05-23 08:57:20 +02:00
token = m.contractAt("TestToken", process.env.TOKEN_ADDRESS, {})
} else {
2025-06-20 06:16:07 +02:00
token = m.contract("TestToken", [], {})
2025-05-23 08:57:20 +02:00
}
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], {
2025-05-16 20:46:23 +02:00
id: `SendingTestTokens_${i}`,
2025-04-15 15:28:48 +02:00
})
}
}
return { token }
})