Solidity is the predominant language for writing smart contracts on blockchain platforms such as Celo. One of its many use cases involves creating digital tokens compliant with specific standards, such as the ERC-20. This challenge involves creating an ERC-20 compliant token contract using Solidity.
Develop a smart contract that creates a digital token adhering to the ERC-20 standard with the following requirements:
- The token should have a name, symbol, and a fixed supply that is pre-allocated to the contract creator.
- The contract should comply with the ERC-20 standard, which includes functions like
- The contract should handle edge cases like transfers to the zero address and transfers exceeding the sender’s balance.
- Use state variables to store token details, total supply, and balances for each address.
msg.senderglobal variable can be used to assign the total supply to the contract creator.
- Implement checks in the transfer and approval functions to handle edge cases.
eventkeyword can be used to emit Transfer and Approval events.
- Correctness: The contract should compile without errors and meet all the requirements of the ERC-20 standard.
- Readability: The contract should be well-documented, with comments explaining the code.
- Testability: You should provide examples of how to test each function of the contract.
Note that handling real assets on a blockchain requires extreme care and extensive testing. This challenge is a simple exercise and doesn’t cover aspects such as security, efficiency, and upgradability, which are essential for a real-world token contract.
For a comprehensive understanding of Celo smart contracts and Solidity, please refer to the Celo and Solidity tutorials.
Please reply with a link to your PR on https://github.com/celo-academy/Creating-a-Digital-Token-in-Solidity-The-ERC-20-Coding-Challenge, including your ERC-20 token contract. Also, include any notes or comments you think are necessary to understand your design and choices. Lastly, provide a brief explanation about how each function of the contract should be tested.