Created
December 20, 2016 22:19
-
-
Save RFV/66c361f620674ae87a5b1150072e0955 to your computer and use it in GitHub Desktop.
old coin contract implementation
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
contract Coin { | |
// The keyword "public" makes those variables | |
// readable from outside. | |
address public minter; | |
mapping (address => uint) public balances; | |
// Events allow light clients to react on | |
// changes efficiently. | |
event Sent(address from, address to, uint amount); | |
// This is the constructor whose code is | |
// run only when the contract is created. | |
function Coin() { | |
minter = msg.sender; | |
} | |
function mint(address receiver, uint amount) { | |
if (msg.sender != minter) return; | |
balances[receiver] += amount; | |
} | |
function send(address receiver, uint amount) { | |
if (balances[msg.sender] < amount) return; | |
balances[msg.sender] -= amount; | |
balances[receiver] += amount; | |
Sent(msg.sender, receiver, amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment