ERC20 Exercise 1
Intro
Your goal is to create an ERC20 token, based on OpenZeppelin ERC20.sol contract, deploy it to your local hardhat chain, and test it.
Accounts
- 0 - Deployer & Owner
- 1 - User1
- 2 - User2
- 3 - User3
Tasks
Create your contract under the ./contracts/erc20-1 folder:
- Import and inherit from OpenZeppelin
ERC20.solcontract - Choose your token NAME and SYMBOl
- Set a contract owner upon deployment
- Implement an external
mint()function which can be called only from owner
Testing:
- Deploy your contract from the deployer account
- Mint 100K tokens to yourself (Deployer)
- Mint 5K tokens to each one of the users
- Verify with a test that every user has the right amount of tokens
- Transfer 100 tokens from User2 to User3
- From User3: approve User1 to spend 1K tokens
- Test that User1 has the right allowance that was given by User3
- From User1: using
transferFrom(), transfer 1K tokens from User3 to User1 - Verify with a test that every user has the right amount of tokens
Links that might be useful
- ERC20 Standard on Ethereum Website https://ethereum.org/en/developers/docs/standards/tokens/erc-20/
- ERC20 Source code on Github https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC20
- Hardhat Tests https://hardhat.org/tutorial/testing-contracts