Skip to content

Commit

Permalink
misc: add script to deploy mock ERC20 tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
antoncoding committed Jul 10, 2021
1 parent 8964405 commit 6f48d13
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/mocks/MockERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ contract MockERC20 is ERC20PermitUpgradeable {
}

function mint(address account, uint256 amount) public {
require(amount < 1e22, "Greedy.");
_mint(account, amount);
}
}
2 changes: 2 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import "hardhat-prettier";
import * as fs from 'fs';
import * as dotenv from 'dotenv'

import './tasks/deployERC20'

dotenv.config()

const mnemonic = fs.existsSync('.secret')
Expand Down
26 changes: 26 additions & 0 deletions tasks/deployERC20.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { task, types } from "hardhat/config";
import "@nomiclabs/hardhat-waffle";

// Example execution
// npx hardhat deployERC20 --decimals 18 --name QuickSwap --symbol QUICK --network mumbai
task("deployERC20", "Deploy a MockERC20")
.addParam('name', 'Token name', undefined, types.string)
.addParam('symbol', 'Token symbol', undefined, types.string)
.addParam('decimals', 'Token decimals', 18, types.string)
.setAction(async ({name, symbol, decimals}, hre) => {


const ERC20 = await hre.ethers.getContractFactory("MockERC20");
const erc20 = await ERC20.deploy();

await erc20.deployed();
console.log(`New mock ERC20 deployed at ${erc20.address} 🍜`)

console.log(`Setting token detail... 🍨`)
await erc20.init(name, symbol, decimals)

await hre.run("verify:verify", {
address: erc20.address,
network: hre.ethers.provider.network
})
});

0 comments on commit 6f48d13

Please sign in to comment.