Skip to content

Instantly share code, notes, and snippets.

@yosriady
Last active July 31, 2019 11:57
Show Gist options
  • Save yosriady/325a98ead35fbb89222228f56289e23a to your computer and use it in GitHub Desktop.
Save yosriady/325a98ead35fbb89222228f56289e23a to your computer and use it in GitHub Desktop.
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;
}
}
@yosriady
Copy link
Author

interface IERC20 {
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);

    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment