Created
August 20, 2022 04:29
-
-
Save ChanJuiHuang/f288490e6a96fd0ce639c4cedafd296b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.4; | |
contract XXXToken { | |
string public name; | |
string public symbol; | |
uint256 public totalSupply; | |
mapping(address => uint256) private balances; | |
address owner; | |
event Transfer(address _from, address _to, uint256 _value); | |
constructor(string memory _name, string memory _symbol, uint256 _totalSupply) { | |
name = _name; | |
symbol = _symbol; | |
totalSupply = _totalSupply; | |
owner = msg.sender; | |
balances[msg.sender] = _totalSupply; | |
} | |
function transfer(address _to, uint256 _amount) public { | |
require(balances[msg.sender] >= _amount, "You don't have enough balance!"); | |
balances[msg.sender] = balances[msg.sender] - _amount; | |
balances[_to] = balances[_to] + _amount; | |
emit Transfer(msg.sender, _to, _amount); | |
} | |
function balanceOf(address account) public view returns(uint256) { | |
return balances[account]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment