bansaltushar014 / Chapter-Solidity

Help Solidity developer to learn fast via providing simple code and examples. This repository containing the most popular smart contracts collections.
MIT License
11 stars 16 forks source link

added ERC20 #18

Closed BChainbuddy closed 1 year ago

BChainbuddy commented 1 year ago

Changes

Added a new ERC20 token which follows the ERC20 token standard. Also added Readme.md, which leads a user to remix to try and experiment with the contract.

FUNCTIONS AND EVENTS

I closely followed token standard and implemented all needed functionalities.

Token standard

Non-standard token functionalities

These two functionalities need to be included due to their high importance.

Mint function

    function mint(address to, uint256 amount) public onlyOwner {
        _totalSupply += amount;
        tokenBalance[to] += amount;
        emit Mint(to, amount);
    }

Burn function

    function burn(uint256 amount) public {
        require(tokenBalance[msg.sender] >= amount, "Balance not high enough");
        tokenBalance[msg.sender] -= amount;
        _totalSupply -= amount;
        tokenBalance[address(0)] += amount;
    }
bansaltushar014 commented 1 year ago

Reviewed!