-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { task } from 'hardhat/config'; | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
|
||
type TestTokenDeploymentParameters = { | ||
tokenAddress: string; | ||
receiver: string; | ||
amount: string; | ||
}; | ||
|
||
task('mint_test_tokens', 'Mint Test Trace Tokens') | ||
.addParam<string>('tokenAddress', 'Token Address') | ||
.addParam<string>('receiver', 'Receiver Address') | ||
.addParam<string>('amount', 'Amount of tokens to mint') | ||
.setAction(async (taskArgs: TestTokenDeploymentParameters, hre: HardhatRuntimeEnvironment) => { | ||
const { tokenAddress, receiver, amount } = taskArgs; | ||
const { minter } = await hre.getNamedAccounts(); | ||
|
||
const Token = await hre.ethers.getContractAt('Token', tokenAddress); | ||
|
||
const minterRole = await Token.MINTER_ROLE(); | ||
if (!(await Token.hasRole(minterRole, minter))) { | ||
console.log(`Setting minter role for ${minter}.`); | ||
const setupMinterTx = await Token.setupRole(minter); | ||
await setupMinterTx.wait(); | ||
} | ||
|
||
const amountToMint = hre.ethers.utils.parseEther(amount); | ||
|
||
const mintTx = await Token.mint(receiver, amountToMint, { from: minter }); | ||
await mintTx.wait(); | ||
|
||
const tokenSymbol = await Token.symbol(); | ||
|
||
console.log( | ||
`${amountToMint.toString()} $${tokenSymbol} has been minted to ${tokenAddress} on the ${ | ||
hre.network.name | ||
} blockchain!`, | ||
); | ||
}); |