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 install
command - Run
yarn compile
command - Add
.env
file. 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 sepolia
or configure this param in the hardhat config:
const config: HardhatUserConfig = {
defaultNetwork: "sepolia",
networks: {
mainnet: {...
},
sepolia: {...
},
}
}
yarn hardhat DeployToken
yarn 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
to
address. - 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
amount
as the allowance ofspender
over 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
amount
of tokens from the caller toto
address. - 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
amount
of tokens fromfrom
address toto
address. - 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