-
-
Save mastercyb/2f01254f4d91b3139f57 to your computer and use it in GitHub Desktop.
Типа коин
This file contains 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 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