Last active
July 31, 2019 11:57
-
-
Save yosriady/325a98ead35fbb89222228f56289e23a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
pragma solidity ^0.5.10; | |
interface ISimpleERC20 { | |
event Transfer(address indexed from, address indexed to, uint256 value); | |
function mint(address to, uint amount) external; | |
function balanceOf(address account) external view returns (uint); | |
function transfer(address to, uint amount) external returns (bool); | |
} | |
contract SimpleERC20 is ISimpleERC20 { | |
string public constant name = "Yos Token"; | |
string public constant symbol = "YOS"; | |
uint8 public constant decimals = 18; | |
address public minter; | |
mapping (address => uint) private _balances; | |
event Transfer(address from, address to, uint amount); | |
constructor() public { | |
minter = msg.sender; | |
} | |
function balanceOf(address account) public view returns (uint) { | |
return _balances[account]; | |
} | |
function mint(address to, uint amount) public { | |
require(msg.sender == minter); | |
require(amount > 0); | |
_balances[to] += amount; | |
} | |
function transfer(address to, uint amount) public returns (bool) { | |
require(amount <= _balances[msg.sender], "Insufficient balance."); | |
_balances[msg.sender] -= amount; | |
_balances[to] += amount; | |
emit Transfer(msg.sender, to, amount); | |
return true; | |
} | |
} |
Author
yosriady
commented
Jul 31, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment