Skip to content

Instantly share code, notes, and snippets.

@mastercyb
Created December 21, 2015 17:44
Show Gist options
  • Save mastercyb/2f01254f4d91b3139f57 to your computer and use it in GitHub Desktop.
Save mastercyb/2f01254f4d91b3139f57 to your computer and use it in GitHub Desktop.
Типа коин
contract token {
mapping (address => uint) public coinBalanceOf;
event CoinTransfer(address sender, address receiver, uint amount);
/* Initializes contract with initial supply tokens to the creator of the contract */
function token(uint supply) {
if (supply == 0) supply = 10000;
coinBalanceOf[msg.sender] = supply;
}
/* Very simple trade function */
function sendCoin(address receiver, uint amount) returns(bool sufficient) {
if (coinBalanceOf[msg.sender] < amount) return false;
coinBalanceOf[msg.sender] -= amount;
coinBalanceOf[receiver] += amount;
CoinTransfer(msg.sender, receiver, amount);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment