Skip to content

Instantly share code, notes, and snippets.

@yosriady
Last active October 19, 2019 06:27
Show Gist options
  • Save yosriady/a8c53465a41a7cf29147f5d4f4f4ff96 to your computer and use it in GitHub Desktop.
Save yosriady/a8c53465a41a7cf29147f5d4f4f4ff96 to your computer and use it in GitHub Desktop.
Sample code for 'Getting Started with Smart Contracts' talk at geekcamp.sg
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