Created
October 8, 2022 13:23
-
-
Save dobestan/7a504870346f9f0df2e5d0b6fd547954 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.0; | |
contract TokenStandardInterface { | |
// Events | |
event Transfer(address indexed _from, address indexed _to, uint256 _value); | |
event Approval(address indexed _owner, address indexed _spender, uint256 _value); | |
// Data | |
string public _name; // "SuchanToken" | |
string private _symbol; // "SCT" | |
uint8 private _decimals; // 18 | |
uint private _totalSupply; // 발행량: 42,000 | |
mapping(address => uint) private _balances; | |
mapping(address => mapping(address => uint)) private _allowances; | |
function name() public view returns (string memory) { | |
return _name; | |
} | |
function symbol() public view returns (string memory) { | |
return _symbol; | |
} | |
function decimals() public view returns (uint8) { | |
return _decimals; | |
} | |
function totalSupply() public view returns (uint256) { | |
return _totalSupply; | |
} | |
function balanceOf(address _owner) public view returns (uint256 balance) { | |
return _balances[_owner]; | |
} | |
function transfer(address _to, uint256 _value) public returns (bool success) { | |
_transfer(msg.sender, _to, _value); | |
return true; | |
} | |
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { | |
require(_allowances[_from][msg.sender] >= _value); | |
_allowances[_from][msg.sender] -= _value; | |
_transfer(_from, _to, _value); | |
return true; | |
} | |
function _transfer(address _from, address _to, uint _value) public returns (bool success) { | |
require(_from != address(0)); | |
require(_to != address(0)); | |
require(_balances[_from] >= _value); | |
_balances[_from] -= _value; | |
_balances[_to] += _value; | |
emit Transfer(_from, _to, _value); | |
return true; | |
} | |
function approve(address _spender, uint256 _value) public returns (bool success) { | |
_allowances[msg.sender][_spender] = _value; | |
emit Approval(msg.sender, _spender, _value); | |
return true; | |
} | |
function allowance(address _owner, address _spender) public view returns (uint256 remaining) { | |
return _allowances[_owner][_spender]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment