Created
July 11, 2019 16:55
-
-
Save GrandSchtroumpf/08ad6415311ae51b9b6fd747fed579fa to your computer and use it in GitHub Desktop.
Enjoy
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
pragma solidity >=0.5.0 <0.6.0; | |
import "https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol"; | |
contract ERC20 { | |
using SafeMath for uint256; | |
uint256 private _totalSupply; | |
mapping(address => uint256) private _balances; | |
event Transfer(address indexed from, address indexed to, uint256 amount); | |
constructor(uint256 amount) public { | |
_totalSupply = amount; | |
_balances[msg.sender] = amount; | |
} | |
function transfer(address to, uint256 amount) external returns (bool) { | |
_balances[msg.sender] = _balances[msg.sender].sub(amount); // Remove the amount from msg.sender balance | |
_balances[to] = _balances[to].add(amount);// Add the amount to "to" | |
emit Transfer(msg.sender, to, amount); | |
return true; | |
} | |
function totalSupply() external view returns (uint256) { | |
return _totalSupply; | |
} | |
function balanceOf(address who) external view returns (uint256) { | |
return _balances[who]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment