Skip to content

Instantly share code, notes, and snippets.

@jtakalai
Created September 17, 2018 12:42
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 jtakalai/f9b5ad3b06a55c7dfa8a40f977a09214 to your computer and use it in GitHub Desktop.
Save jtakalai/f9b5ad3b06a55c7dfa8a40f977a09214 to your computer and use it in GitHub Desktop.
A simple token (not ERC20 compliant)
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