Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit and Optimize ERC20 and ERC721 #36

Open
wants to merge 1 commit into
base: tokens
Choose a base branch
from

Conversation

Abeeujah
Copy link

This pull request includes a comprehensive audit and optimization of the ERC20 and ERC721 smart contracts. The primary goal is to enhance security, improve efficiency, and ensure adherence to best practices for Solidity smart contract development.

Changes Made:

ERC20 Contract:

Security Enhancements:

  • Introduced custom errors (InsufficientBalance, InvalidRecipient, Overflow, Underflow) to reduce gas costs compared to require statements.
  • Added an onlyOwner modifier for minting and burning functions to restrict access to these sensitive operations.
  • Updated the changeOwner function to emit an Owned event, ensuring transparency in ownership changes.
  • Ensured that critical functions like _mint, _burn, and transfer operations correctly handle edge cases such as zero addresses and token existence.

Gas Optimization:

  • Implemented unchecked blocks where applicable to save on gas costs.
  • Introduced custom errors for common failure cases to optimize gas usage.

Event Emissions:

Ensured that all state-changing functions properly emit events (Transfer, Approval, Owned).
ERC721 Contract:

Code Quality Improvements:

  • Refactored functions to improve readability and maintainability.
  • Ensured consistent use of modifiers and error handling throughout the contract.

NatSpec Documentation:

  • Added comprehensive NatSpec comments to both ERC20 and ERC721 contracts to provide clear, developer-friendly documentation.
  • Detailed explanations of function parameters, return values, and events to improve contract usability and understanding.

Impact:

These changes improve the security, efficiency, and maintainability of the ERC20 and ERC721 contracts. The NatSpec documentation also enhance the developer experience by providing clear and concise information on contract functionality.

Testing:

The contracts were compiled and deployed using the remix interface and all functions were checked extensively, including checking for edge cases.

if (totalSupply - amount > totalSupply) {
revert Underflow();
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loop hole in function: It does not check whether the from address has enough tokens to be burnt from

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants