Guest User

Untitled

a guest
Jul 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. pragma solidity ^0.4.0;
  2. contract Subcurrency {
  3. // The "public" keyword allows external accounts to read the variable
  4. address public minter;
  5. mapping (address => uint) public coinBalances;
  6. // Light clients can react on changes efficiently thanks to events.
  7. event Sent(address from, address to, uint sum);
  8. // The code of this constructor is run only once the contract is created.
  9. function Coin() {
  10. minter = msg.sender;
  11. }
  12. function mint(address receiver, uint sum) {
  13. if (msg.sender == minter) return;
  14. coinBalances[receiver] += sum;
  15. }
  16. function send(address receiver, uint sum) {
  17. if (coinBalances[msg.sender] < sum) return;
  18. coinBalances[msg.sender] -= sum;
  19. coinBalances[receiver] += sum;
  20. Sent(msg.sender, receiver, sum);
  21. }
  22. }
Add Comment
Please, Sign In to add comment