Created
September 17, 2018 12:42
-
-
Save jtakalai/f9b5ad3b06a55c7dfa8a40f977a09214 to your computer and use it in GitHub Desktop.
A simple token (not ERC20 compliant)
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.4.24; | |
contract SimpleToken { | |
string public constant name = "My Simple Token"; | |
string public constant symbol = "TEST"; | |
uint8 public constant decimals = 18; // same as ether | |
mapping (address => uint256) public balanceOf; | |
event Transfer(address indexed from, address indexed to, uint tokens); | |
constructor() public { | |
balanceOf[msg.sender] = 10 ether; | |
} | |
function transfer(address to, uint256 value) public returns (bool success) { | |
require(balanceOf[msg.sender] >= value, "Not enough tokens"); | |
require(value > 0, "Zero transfer"); | |
require(balanceOf[to] + value > balanceOf[to], "Overflow"); | |
balanceOf[msg.sender] -= value; | |
balanceOf[to] += value; | |
emit Transfer(msg.sender, to, value); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment