This template contain standard ERC20 token contract with implemented non-payable mint() function and Ownable inheritance. Use this template for fast token deployment.
- Clone the repository
- Run
yarn installcommand - Run
yarn compilecommand - Add
.envfile. Example is in the example file
In case of using custom chains - configure custom chain params in the hardhat config
Specify token contract name in the ERC20 file. Name should be the same as in the .env file.
contract NEW_TOKEN_NAME is ERC20, Ownable...For all tasks use --network param, eg.:
yarn hardhat DeployToken --network sepoliaor configure this param in the hardhat config:
const config: HardhatUserConfig = {
defaultNetwork: "sepolia",
networks: {
mainnet: {...
},
sepolia: {...
},
}
}yarn hardhat DeployTokenyarn hardhat VerifyToken- Description: Get the total number of minted tokens.
- Return:
bigint - Access: Public
yarn hardhat getTotalSupply- Description: Get the balance of tokens for a given address.
- Params:
address- address to get balance of.
- Return:
bigint - Access: Public
yarn hardhat getBalanceOf --address address- Description: Mint amount of tokens to the
toaddress. - Params:
to- address to mint tokens toamount- number of tokens to mint. Note: will be converted according to token.decimals()
- Access: Only owner
yarn hardhat mint --to to --amount amount- Description: Set an
amountas the allowance ofspenderover the caller's tokens. - Params:
spender- address to approve tokens toamount- number of tokens to approve. Note: will be converted according to token.decimals()
- Access: Public
yarn hardhat approve --spender spender --amount amount- Description: Transfer
amountof tokens from the caller totoaddress. - Params:
to- address to transfer tokens toamount- number of tokens to transfer. Note: will be converted according to token.decimals()
- Access: Public
yarn hardhat transfer --to to --amount amount- Description: Transfer
amountof tokens fromfromaddress totoaddress. - Params:
from- address to transfer tokens fromto- address to transfer tokens toamount- number of tokens to transfer. Note: will be converted according to token.decimals()
- Access: Public
yarn hardhat transferFrom --from from --to to --amount amount- Description: Get token contract owner.
- Return:
address - Access: Public
yarn hardhat getOwner- Description: Transfer ownership to the given address.
- Params:
address- address to transfer ownership to
- Access: Only owner
yarn hardhat transferOwnership --address address