Created
October 10, 2022 11:43
-
-
Save ChanJuiHuang/ae01a3883398afd494688fd63604379e 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: GPL-3.0 | |
pragma solidity ^0.4.24; | |
contract BasicToken { | |
uint256 totalSupply_; | |
mapping(address => uint256) balances; | |
constructor(uint256 _initialSupply) public { | |
totalSupply_ = _initialSupply; | |
balances[msg.sender] = _initialSupply; | |
} | |
function totalSupply() public view returns (uint256) { | |
return totalSupply_; | |
} | |
function transfer(address _to, uint256 _value) public returns (bool) { | |
require(_to != address(0)); | |
require(_value <= balances[msg.sender]); | |
balances[msg.sender] = balances[msg.sender] - _value; | |
balances[_to] = balances[_to] + _value; | |
return true; | |
} | |
function balanceOf(address _owner) public view returns (uint256) { | |
return balances[_owner]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment