Skip to content

Instantly share code, notes, and snippets.

@GrandSchtroumpf
Created July 11, 2019 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GrandSchtroumpf/08ad6415311ae51b9b6fd747fed579fa to your computer and use it in GitHub Desktop.
Save GrandSchtroumpf/08ad6415311ae51b9b6fd747fed579fa to your computer and use it in GitHub Desktop.
Enjoy
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