Advertisement
societymediagroup

Untitled

Mar 29th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. pragma solidity ^0.4.19;
  2.  
  3. /**
  4. * @title SafeMath
  5. * @dev Math operations with safety checks that throw on error
  6. */
  7. library SafeMath {
  8.  
  9. function mul(uint256 a, uint256 b) internal constant returns (uint256) {
  10. uint256 c = a * b;
  11. assert(a == 0 || c / a == b);
  12. return c;
  13. }
  14.  
  15. function div(uint256 a, uint256 b) internal constant returns (uint256) {
  16. // assert(b > 0); // Solidity automatically throws when dividing by 0
  17. uint256 c = a / b;
  18. // assert(a == b * c + a % b); // There is no case in which this doesn't hold
  19. return c;
  20. }
  21.  
  22. function sub(uint256 a, uint256 b) internal constant returns (uint256) {
  23. assert(b <= a);
  24. return a - b;
  25. }
  26.  
  27. function add(uint256 a, uint256 b) internal constant returns (uint256) {
  28. uint256 c = a + b;
  29. assert(c >= a);
  30. return c;
  31. }
  32.  
  33. }
  34.  
  35. contract Token {
  36. /// @return total amount of tokens
  37. function totalSupply() constant returns (uint256 supply) {}
  38.  
  39. /// @param _owner The address from which the balance will be retrieved
  40. /// @return The balance
  41. function balanceOf(address _owner) constant returns (uint256 balance) {}
  42.  
  43. /// @notice send `_value` token to `_to` from `msg.sender`
  44. /// @param _to The address of the recipient
  45. /// @param _value The amount of token to be transferred
  46. /// @return Whether the transfer was successful or not
  47. function transfer(address _to, uint256 _value) returns (bool success) {}
  48.  
  49. /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
  50. /// @param _from The address of the sender
  51. /// @param _to The address of the recipient
  52. /// @param _value The amount of token to be transferred
  53. /// @return Whether the transfer was successful or not
  54. function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
  55.  
  56. /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
  57. /// @param _spender The address of the account able to transfer the tokens
  58. /// @param _value The amount of wei to be approved for transfer
  59. /// @return Whether the approval was successful or not
  60. function approve(address _spender, uint256 _value) returns (bool success) {}
  61.  
  62. /// @param _owner The address of the account owning tokens
  63. /// @param _spender The address of the account able to transfer the tokens
  64. /// @return Amount of remaining tokens allowed to spent
  65. function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
  66.  
  67. event Transfer(address indexed _from, address indexed _to, uint256 _value);
  68. event Approval(address indexed _owner, address indexed _spender, uint256 _value);
  69.  
  70. uint public decimals;
  71. string public name;
  72. }
  73. /**
  74. * @title Ownable
  75. * @dev The Ownable contract has an owner address, and provides basic authorization control
  76. * functions, this simplifies the implementation of "user permissions".
  77. */
  78. contract Ownable {
  79.  
  80. address public owner;
  81.  
  82. /**
  83. * @dev The Ownable constructor sets the original `owner` of the contract to the sender
  84. * account.
  85. */
  86. function Ownable() public {
  87. owner = msg.sender;
  88. }
  89.  
  90. /**
  91. * @dev Throws if called by any account other than the owner.
  92. */
  93. modifier onlyOwner() {
  94. require(msg.sender == owner);
  95. _;
  96. }
  97.  
  98. /**
  99. * @dev Allows the current owner to transfer control of the contract to a newOwner.
  100. * @param newOwner The address to transfer ownership to.
  101. */
  102. function transferOwnership(address newOwner) onlyOwner public {
  103. require(newOwner != address(0));
  104. owner = newOwner;
  105. }
  106.  
  107. }
  108. contract AirDrop is Ownable {
  109. address public tokenAddress;
  110. Token public token;
  111. uint256 public valueAirDrop;
  112. mapping (address => uint8) public payedAddress;
  113. function AirDrop() public{
  114. tokenAddress = 0xxxxxxxxxxxxxxxxxxxxxxxxxxxx;
  115. token = Token(tokenAddress);
  116. valueAirDrop = 100;
  117. }
  118. function setTokenAddress(address _address) onlyOwner public{
  119. tokenAddress = _address;
  120. token = Token(tokenAddress);
  121. }
  122. function refund() onlyOwner public{
  123. token.transfer(owner, token.balanceOf(this));
  124. }
  125. function () external payable {
  126. require(msg.value == 0);
  127. require(payedAddress[msg.sender] == 0);
  128. payedAddress[msg.sender] = 1;
  129. token.transfer(msg.sender, valueAirDrop);
  130. }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement