SHARE
TWEET

Untitled

a guest Oct 12th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pragma solidity ^0.4.13;
  2.  
  3. contract Token {
  4.     address public owner;
  5.     address public trustedThirdParty;
  6.  
  7.     function Token(address _trustedThirdParty) {
  8.         owner = msg.sender;
  9.         trustedThirdParty = _trustedThirdParty;
  10.     }
  11.  
  12.     modifier onlyOwner {
  13.         require(msg.sender == owner);
  14.         _;
  15.     }
  16.  
  17.     modifier onlyTrustedThirdParty {
  18.         require(msg.sender == trustedThirdParty);
  19.         _;
  20.     }
  21.  
  22.  
  23.     mapping (address => uint) public balanceOf;
  24.     uint public deposited;
  25.     uint public withdrawLimit;
  26.  
  27.     function deposit() payable {
  28.         require(deposited + msg.value > deposited);
  29.         require(balanceOf[msg.sender] + msg.value > balanceOf[msg.sender]); // Check for overflows
  30.         balanceOf[msg.sender] += msg.value;
  31.         deposited += msg.value;
  32.     }
  33.  
  34.     function balanceOf(address owner) constant returns (uint balance) {
  35.         return balanceOf[owner];
  36.     }
  37.  
  38.     function transfer(address to, uint value) {
  39.         require(balanceOf[msg.sender] >= value);
  40.         require(balanceOf[to] + value > balanceOf[to]); // Check for overflows
  41.         balanceOf[msg.sender] -= value;
  42.         balanceOf[to] += value;
  43.     }
  44.  
  45.     function setWithdrawLimit(uint newWithdrawLimit) onlyTrustedThirdParty {
  46.         withdrawLimit = newWithdrawLimit;
  47.     }
  48.  
  49.     function withdraw(uint amount) onlyOwner {
  50.         require(amount <= withdrawLimit);
  51.         require(amount <= deposited);
  52.         deposited -= amount;
  53.         withdrawLimit -= amount;
  54.         msg.sender.transfer(amount);
  55.     }
  56.  
  57.  
  58.  
  59.     uint[] public bonusCodes;
  60.  
  61.     function pushBonusCode(uint code) onlyOwner {
  62.         bonusCodes.push(code);
  63.     }
  64.  
  65.     function popBonusCode() onlyOwner {
  66.         require(bonusCodes.length >= 0);
  67.         bonusCodes.length--; // No pop() method?
  68.     }
  69.  
  70.     function modifyBonusCode(uint index, uint update) onlyOwner {
  71.         require(index < bonusCodes.length);
  72.         bonusCodes[index] = update;
  73.     }
  74. }
RAW Paste Data
Top