daily pastebin goal
52%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pragma solidity ^0.4.16;
  2.  
  3. /** This contract is build for nDEX - Next Generation Decentralize Exchange Ticker : NDX . Any one can use this code to make contract is
  4.   not subject to copyright law */
  5.  
  6. interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
  7.  
  8. contract NDEX {
  9.     // Public variables of the token
  10.     string public name = "nDEX";
  11.     string public symbol = "NDX";
  12.     uint8 public decimals = 18;
  13.  
  14.     // 18 decimals is the strongly suggested default
  15.     uint256 public totalSupply;
  16.     uint256 public NdexSupply = 15000000000;
  17.     uint256 public buyPrice = 10000000;
  18.     address public creator;
  19.  
  20.     // This creates an array with all balances
  21.     mapping (address => uint256) public balanceOf;
  22.     mapping (address => mapping (address => uint256)) public allowance;
  23.  
  24.     // This generates a public event on the blockchain that will notify clients
  25.     event Transfer(address indexed from, address indexed to, uint256 value);
  26.     event FundTransfer(address backer, uint amount, bool isContribution);
  27.    
  28.    
  29.     /**
  30.      * Constrctor function
  31.      *
  32.      * Initializes contract with initial supply tokens to the creator of the contract
  33.      */
  34.     function NDEX() public {
  35.         totalSupply = NdexSupply * 10 ** uint256(decimals);     // Update total supply with the decimal amount
  36.         balanceOf[msg.sender] = totalSupply;            // Give NDX Mint the total created tokens
  37.         creator = msg.sender;
  38.     }
  39.     /**
  40.      * Internal transfer, only can be called by this contract
  41.      */
  42.     function _transfer(address _from, address _to, uint _value) internal {
  43.         // Prevent transfer to 0x0 address. Use burn() instead
  44.         require(_to != 0x0);
  45.         // Check if the sender has enough
  46.         require(balanceOf[_from] >= _value);
  47.         // Check for overflows
  48.         require(balanceOf[_to] + _value >= balanceOf[_to]);
  49.     // Save this for an assertion in the future
  50.         uint previousBalances = balanceOf[_from] + balanceOf[_to];
  51.         // Subtract from the sender
  52.         balanceOf[_from] -= _value;
  53.         // Add the same to the recipient
  54.         balanceOf[_to] += _value;
  55.         emit Transfer(_from, _to, _value);
  56.         // Asserts are used to use static analysis to find bugs in your code. They should never fail
  57.         assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
  58.     }
  59.  
  60.     /**
  61.      * Transfer tokens
  62.      *
  63.      * Send `_value` tokens to `_to` from your account
  64.      *
  65.      * @param _to The address of the recipient
  66.      * @param _value the amount to send
  67.      */
  68.    
  69.    function transfer(address _to, uint256 _value) public {
  70.         _transfer(msg.sender, _to, _value);
  71.     }
  72.  
  73.    
  74.    
  75.     /// @notice Buy tokens from contract by sending ether
  76.     function () payable internal {
  77.         uint amount = msg.value * buyPrice;                      // calculates the amount
  78.         uint amountRaised;                                    
  79.         amountRaised += msg.value;                              //many thanks bois, couldnt do it without r/me_irl
  80.         require(balanceOf[creator] >= amount);                     // checks if it has enough to sell
  81.         require(msg.value <= 10**17);                         // so any person who wants to put more then 0.1 ETH has time to think!
  82.         balanceOf[msg.sender] += amount;                     // adds the amount to buyer's balance
  83.         balanceOf[creator] -= amount;                         // sends ETH to NDXMint
  84.         emit Transfer(creator, msg.sender, amount);                  // execute an event reflecting the change
  85.         creator.transfer(amountRaised);
  86.     }
  87.  
  88.  }
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