Last active
October 19, 2019 06:27
-
-
Save yosriady/a8c53465a41a7cf29147f5d4f4f4ff96 to your computer and use it in GitHub Desktop.
Sample code for 'Getting Started with Smart Contracts' talk at geekcamp.sg
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.5.11; | |
contract SimpleToken { | |
string public constant name = "GeekCamp Token"; | |
string public constant symbol = "GEEK"; | |
uint8 public constant decimals = 0; | |
address public minter; | |
mapping (address => uint) private _balances; | |
constructor() public { | |
minter = msg.sender; | |
} | |
function balanceOf(address account) public view returns (uint) { | |
return _balances[account]; | |
} | |
function mint(address to, uint amount) public returns (bool) { | |
require(msg.sender == minter); | |
require(amount > 0); | |
_balances[to] += amount; | |
return true; | |
} | |
function transfer(address to, uint amount) public returns (bool) { | |
require(amount <= _balances[msg.sender], "Insufficient balance."); | |
_balances[msg.sender] -= amount; | |
_balances[to] += amount; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment