From c7b69893a1eb3960702deedcf2f515fe084eb055 Mon Sep 17 00:00:00 2001 From: Eric Mastro Date: Fri, 5 May 2023 16:00:26 +1000 Subject: [PATCH] only mint tokens when on local hardhat network --- deploy/token.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/deploy/token.js b/deploy/token.js index 3acb441..83923f6 100644 --- a/deploy/token.js +++ b/deploy/token.js @@ -1,16 +1,18 @@ const MINTED_TOKENS = 1_000_000_000 -module.exports = async ({ deployments, getNamedAccounts, getUnnamedAccounts }) => { +module.exports = async ({ deployments, getNamedAccounts, getUnnamedAccounts, network }) => { const { deployer } = await getNamedAccounts() const tokenDeployment = await deployments.deploy("TestToken", { from: deployer }) const token = await hre.ethers.getContractAt("TestToken", tokenDeployment.address) const accounts = [...Object.values(await getNamedAccounts()), ...(await getUnnamedAccounts())] - for (const account of accounts) { - console.log(`Minting ${MINTED_TOKENS} tokens to address ${account}`) + if (network.tags.local) { + for (const account of accounts) { + console.log(`Minting ${MINTED_TOKENS} tokens to address ${account}`) - const transaction = await token.mint(account, MINTED_TOKENS, { from: deployer }) - await transaction.wait() + const transaction = await token.mint(account, MINTED_TOKENS, { from: deployer }) + await transaction.wait() + } } }