daily pastebin goal
76%
SHARE
TWEET

OneCoin OFC Smart Contract

a guest Aug 23rd, 2018 456 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pragma solidity ^0.4.19;
  2.  
  3. /**
  4.  * @title ERC20Basic
  5.  * @dev Simpler version of ERC20 interface
  6.  * @dev see https://github.com/ethereum/EIPs/issues/179
  7.  */
  8. contract ERC20Basic {
  9.   function totalSupply() public view returns (uint256);
  10.   function balanceOf(address who) public view returns (uint256);
  11.   function transfer(address to, uint256 value) public returns (bool);
  12.   event Transfer(address indexed from, address indexed to, uint256 value);
  13. }
  14.  
  15. /**
  16.  * @title ERC20 interface
  17.  * @dev see https://github.com/ethereum/EIPs/issues/20
  18.  */
  19. contract ERC20 is ERC20Basic {
  20.   function allowance(address owner, address spender) public view returns (uint256);
  21.   function transferFrom(address from, address to, uint256 value) public returns (bool);
  22.   function approve(address spender, uint256 value) public returns (bool);
  23.   event Approval(address indexed owner, address indexed spender, uint256 value);
  24. }
  25.  
  26. /**
  27.  * @title SafeMath
  28.  * @dev Math operations with safety checks that throw on error
  29.  */
  30. library SafeMath {
  31.  
  32.   /**
  33.   * @dev Multiplies two numbers, throws on overflow.
  34.   */
  35.   function mul(uint256 a, uint256 b) internal pure returns (uint256) {
  36.     if (a == 0) {
  37.       return 0;
  38.     }
  39.     uint256 c = a * b;
  40.     assert(c / a == b);
  41.     return c;
  42.   }
  43.  
  44.   /**
  45.   * @dev Integer division of two numbers, truncating the quotient.
  46.   */
  47.   function div(uint256 a, uint256 b) internal pure returns (uint256) {
  48.     // assert(b > 0); // Solidity automatically throws when dividing by 0
  49.     // uint256 c = a / b;
  50.     // assert(a == b * c + a % b); // There is no case in which this doesn't hold
  51.     return a / b;
  52.   }
  53.  
  54.   /**
  55.   * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
  56.   */
  57.   function sub(uint256 a, uint256 b) internal pure returns (uint256) {
  58.     assert(b <= a);
  59.     return a - b;
  60.   }
  61.  
  62.   /**
  63.   * @dev Adds two numbers, throws on overflow.
  64.   */
  65.   function add(uint256 a, uint256 b) internal pure returns (uint256) {
  66.     uint256 c = a + b;
  67.     assert(c >= a);
  68.     return c;
  69.   }
  70. }
  71.  
  72. /**
  73.  * @title Basic token
  74.  * @dev Basic version of StandardToken, with no allowances.
  75.  */
  76. contract BasicToken is ERC20Basic {
  77.   using SafeMath for uint256;
  78.  
  79.   mapping(address => uint256) balances;
  80.  
  81.   uint256 totalSupply_;
  82.  
  83.   /**
  84.   * @dev total number of tokens in existence
  85.   */
  86.   function totalSupply() public view returns (uint256) {
  87.     return totalSupply_;
  88.   }
  89.  
  90.   /**
  91.   * @dev transfer token for a specified address
  92.   * @param _to The address to transfer to.
  93.   * @param _value The amount to be transferred.
  94.   */
  95.   function transfer(address _to, uint256 _value) public returns (bool) {
  96.     require(_to != address(0));
  97.     require(_value <= balances[msg.sender]);
  98.  
  99.     balances[msg.sender] = balances[msg.sender].sub(_value);
  100.     balances[_to] = balances[_to].add(_value);
  101.     emit Transfer(msg.sender, _to, _value);
  102.     return true;
  103.   }
  104.  
  105.   /**
  106.   * @dev Gets the balance of the specified address.
  107.   * @param _owner The address to query the the balance of.
  108.   * @return An uint256 representing the amount owned by the passed address.
  109.   */
  110.   function balanceOf(address _owner) public view returns (uint256 balance) {
  111.     return balances[_owner];
  112.   }
  113.  
  114. }
  115. /**
  116.  * @title Standard ERC20 token
  117.  *
  118.  * @dev Implementation of the basic standard token.
  119.  * @dev https://github.com/ethereum/EIPs/issues/20
  120.  * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
  121.  */
  122. contract StandardToken is ERC20, BasicToken {
  123.  
  124.   mapping (address => mapping (address => uint256)) internal allowed;
  125.  
  126.  
  127.   /**
  128.    * @dev Transfer tokens from one address to another
  129.    * @param _from address The address which you want to send tokens from
  130.    * @param _to address The address which you want to transfer to
  131.    * @param _value uint256 the amount of tokens to be transferred
  132.    */
  133.   function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
  134.     require(_to != address(0));
  135.     require(_value <= balances[_from]);
  136.     require(_value <= allowed[_from][msg.sender]);
  137.  
  138.     balances[_from] = balances[_from].sub(_value);
  139.     balances[_to] = balances[_to].add(_value);
  140.     allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
  141.     emit Transfer(_from, _to, _value);
  142.     return true;
  143.   }
  144.  
  145.   /**
  146.    * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
  147.    *
  148.    * Beware that changing an allowance with this method brings the risk that someone may use both the old
  149.    * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
  150.    * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
  151.    * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
  152.    * @param _spender The address which will spend the funds.
  153.    * @param _value The amount of tokens to be spent.
  154.    */
  155.   function approve(address _spender, uint256 _value) public returns (bool) {
  156.     allowed[msg.sender][_spender] = _value;
  157.     emit Approval(msg.sender, _spender, _value);
  158.     return true;
  159.   }
  160.  
  161.   /**
  162.    * @dev Function to check the amount of tokens that an owner allowed to a spender.
  163.    * @param _owner address The address which owns the funds.
  164.    * @param _spender address The address which will spend the funds.
  165.    * @return A uint256 specifying the amount of tokens still available for the spender.
  166.    */
  167.   function allowance(address _owner, address _spender) public view returns (uint256) {
  168.     return allowed[_owner][_spender];
  169.   }
  170.  
  171.   /**
  172.    * @dev Increase the amount of tokens that an owner allowed to a spender.
  173.    *
  174.    * approve should be called when allowed[_spender] == 0. To increment
  175.    * allowed value is better to use this function to avoid 2 calls (and wait until
  176.    * the first transaction is mined)
  177.    * From MonolithDAO Token.sol
  178.    * @param _spender The address which will spend the funds.
  179.    * @param _addedValue The amount of tokens to increase the allowance by.
  180.    */
  181.   function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
  182.     allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
  183.     emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
  184.     return true;
  185.   }
  186.  
  187.   /**
  188.    * @dev Decrease the amount of tokens that an owner allowed to a spender.
  189.    *
  190.    * approve should be called when allowed[_spender] == 0. To decrement
  191.    * allowed value is better to use this function to avoid 2 calls (and wait until
  192.    * the first transaction is mined)
  193.    * From MonolithDAO Token.sol
  194.    * @param _spender The address which will spend the funds.
  195.    * @param _subtractedValue The amount of tokens to decrease the allowance by.
  196.    */
  197.   function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
  198.     uint oldValue = allowed[msg.sender][_spender];
  199.     if (_subtractedValue > oldValue) {
  200.       allowed[msg.sender][_spender] = 0;
  201.     } else {
  202.       allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
  203.     }
  204.     emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
  205.     return true;
  206.   }
  207.  
  208. }
  209.  
  210. /**
  211.  * @title Ownable
  212.  * @dev The Ownable contract has an owner address, and provides basic authorization control
  213.  * functions, this simplifies the implementation of "user permissions".
  214.  */
  215. contract Ownable {
  216.   address public owner;
  217.  
  218.  
  219.   event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  220.  
  221.  
  222.   /**
  223.    * @dev The Ownable constructor sets the original `owner` of the contract to the sender
  224.    * account.
  225.    */
  226.   function Ownable() public {
  227.     owner = msg.sender;
  228.   }
  229.  
  230.   /**
  231.    * @dev Throws if called by any account other than the owner.
  232.    */
  233.   modifier onlyOwner() {
  234.     require(msg.sender == owner);
  235.     _;
  236.   }
  237.  
  238.   /**
  239.    * @dev Allows the current owner to transfer control of the contract to a newOwner.
  240.    * @param newOwner The address to transfer ownership to.
  241.    */
  242.   function transferOwnership(address newOwner) public onlyOwner {
  243.     require(newOwner != address(0));
  244.     emit OwnershipTransferred(owner, newOwner);
  245.     owner = newOwner;
  246.   }
  247.  
  248. }
  249.  
  250.  
  251. contract OFC is Ownable, StandardToken  {
  252.  
  253.   string public constant name = "OneCoin";
  254.   string public constant symbol = "OFC";
  255.   uint8 public constant decimals = 7;
  256.  
  257.   uint256 public constant INITIAL_SUPPLY = (120000 * (10**6)) * (10 ** uint256(decimals));
  258.  
  259.   constructor() public {
  260.       totalSupply_ = INITIAL_SUPPLY;
  261.       balances[this] = INITIAL_SUPPLY;
  262.       emit Transfer(address(0), this, INITIAL_SUPPLY);
  263.   }
  264.  
  265.   //sending tokens from contract address
  266.   function send(address to, uint amount) public onlyOwner {
  267.       require(to != address(0));
  268.       require(amount > 0);
  269.  
  270.       // SafeMath.sub will throw if there is not enough balance.
  271.       balances[this] = balances[this].sub(amount);
  272.       balances[to] = balances[to].add(amount);
  273.       emit Transfer(this, to, amount);
  274.   }
  275.  
  276.   //mining tokens and sending to address
  277.   function mint(address to, uint amount) public onlyOwner {
  278.       require(to != address(0));
  279.       require(amount > 0);
  280.  
  281.       totalSupply_ = totalSupply_.add(amount);
  282.       balances[to] = balances[to].add(amount);
  283.       emit Transfer(address(0), to, amount);
  284.   }
  285.  
  286.   //burning tokens from address
  287.   function burn(address from, uint amount) public onlyOwner {
  288.       require(from != address(0));
  289.       require(amount > 0);
  290.  
  291.       // SafeMath.sub will throw if there is not enough balance.
  292.       totalSupply_ = totalSupply_.sub(amount);
  293.       balances[from] = balances[from].sub(amount);
  294.       emit Transfer(from, address(0), amount);
  295.   }
  296.  
  297.  function() public payable {}
  298.  
  299.   //Sendin Ethers
  300.   function sendEther(address to, uint amount) public onlyOwner {
  301.       require(to != address(0));
  302.       require(amount > 0);
  303.       to.transfer(amount);
  304.   }
  305.  
  306.  
  307. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top