Advertisement
Guest User

Untitled

a guest
Mar 8th, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 0x45601D0497419Ec993552EF425927F08f73CE032
  2.  
  3. [ { "constant": true, "inputs": [], "name": "name", "outputs": [ { "name": "", "type": "string", "value": "Love", "displayName": "" } ], "type": "function", "displayName": "name" }, { "constant": true, "inputs": [], "name": "difficulty", "outputs": [ { "name": "", "type": "uint256", "value": "1.46341463414634146341463414634147e+32", "displayName": "" } ], "type": "function", "displayName": "difficulty" }, { "constant": false, "inputs": [ { "name": "_from", "type": "address", "typeShort": "address", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;from", "template": "elements_input_address" }, { "name": "_to", "type": "address", "typeShort": "address", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;to", "template": "elements_input_address" }, { "name": "_value", "type": "uint256", "typeShort": "uint", "bits": "256", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;value", "template": "elements_input_uint" } ], "name": "transferFrom", "outputs": [ { "name": "success", "type": "bool" } ], "type": "function", "displayName": "transfer From" }, { "constant": true, "inputs": [], "name": "decimals", "outputs": [ { "name": "", "type": "uint8", "value": "0", "displayName": "" } ], "type": "function", "displayName": "decimals" }, { "constant": true, "inputs": [], "name": "currentChallenge", "outputs": [ { "name": "", "type": "bytes32", "value": "0x54060960907e6648f4a69534bfc5e81efccf8a4b4d86a718b4af40ad4d8b7299", "displayName": "" } ], "type": "function", "displayName": "current Challenge" }, { "constant": false, "inputs": [ { "name": "nonce", "type": "uint256", "typeShort": "uint", "bits": "256", "displayName": "nonce", "template": "elements_input_uint" } ], "name": "proofOfWork", "outputs": [], "type": "function", "displayName": "proof Of Work" }, { "constant": true, "inputs": [ { "name": "", "type": "address", "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" } ], "name": "balanceOf", "outputs": [ { "name": "", "type": "uint256", "value": "0", "displayName": "" } ], "type": "function", "displayName": "balance Of" }, { "constant": true, "inputs": [], "name": "timeOfLastProof", "outputs": [ { "name": "", "type": "uint256", "value": "1457432745", "displayName": "" } ], "type": "function", "displayName": "time Of Last Proof" }, { "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "name": "", "type": "string", "value": "♥", "displayName": "" } ], "type": "function", "displayName": "symbol" }, { "constant": false, "inputs": [ { "name": "_to", "type": "address", "typeShort": "address", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;to", "template": "elements_input_address" }, { "name": "_value", "type": "uint256", "typeShort": "uint", "bits": "256", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;value", "template": "elements_input_uint" } ], "name": "transfer", "outputs": [], "type": "function", "displayName": "transfer" }, { "constant": false, "inputs": [ { "name": "_spender", "type": "address", "typeShort": "address", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;spender", "template": "elements_input_address" }, { "name": "_value", "type": "uint256", "typeShort": "uint", "bits": "256", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;value", "template": "elements_input_uint" }, { "name": "_extraData", "type": "bytes", "typeShort": "bytes", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;extra Data", "template": "elements_input_bytes" } ], "name": "approveAndCall", "outputs": [ { "name": "success", "type": "bool" } ], "type": "function", "displayName": "approve And Call" }, { "constant": true, "inputs": [ { "name": "", "type": "address", "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" }, { "name": "", "type": "address", "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" } ], "name": "spentAllowance", "outputs": [ { "name": "", "type": "uint256", "value": "0", "displayName": "" } ], "type": "function", "displayName": "spent Allowance" }, { "constant": true, "inputs": [ { "name": "", "type": "address", "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" }, { "name": "", "type": "address", "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" } ], "name": "allowance", "outputs": [ { "name": "", "type": "uint256", "value": "0", "displayName": "" } ], "type": "function", "displayName": "allowance" }, { "inputs": [ { "name": "initialSupply", "type": "uint256", "typeShort": "uint", "bits": "256", "displayName": "initial Supply", "template": "elements_input_uint", "value": "0" }, { "name": "tokenName", "type": "string", "typeShort": "string", "bits": "", "displayName": "token Name", "template": "elements_input_string", "value": "Love" }, { "name": "decimalUnits", "type": "uint8", "typeShort": "uint", "bits": "8", "displayName": "decimal Units", "template": "elements_input_uint", "value": "0" }, { "name": "tokenSymbol", "type": "string", "typeShort": "string", "bits": "", "displayName": "token Symbol", "template": "elements_input_string", "value": "♥" } ], "type": "constructor" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "from", "type": "address" }, { "indexed": true, "name": "to", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" } ], "name": "Transfer", "type": "event" } ]
  4.  
  5. contract tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); }
  6.  
  7. contract MyToken {
  8.     /* Public variables of the token */
  9.     string public name;
  10.     string public symbol;
  11.     uint8 public decimals;
  12.    
  13.     /* Proof of Work configuration */
  14.     bytes32 public currentChallenge;                         // The coin starts with a challenge
  15.     uint public timeOfLastProof;                             // Variable to keep track of when rewards were given
  16.     uint public difficulty = 10**32;                         // Difficulty starts reasonably low
  17.  
  18.     /* This creates an array with all balances */
  19.     mapping (address => uint256) public balanceOf;
  20.     mapping (address => mapping (address => uint)) public allowance;
  21.     mapping (address => mapping (address => uint)) public spentAllowance;
  22.  
  23.     /* This generates a public event on the blockchain that will notify clients */
  24.     event Transfer(address indexed from, address indexed to, uint256 value);
  25.  
  26.     /* Initializes contract with initial supply tokens to the creator of the contract */
  27.     function MyToken(uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol) {
  28.         balanceOf[msg.sender] = initialSupply;              // Give the creator all initial tokens                    
  29.         name = tokenName;                                   // Set the name for display purposes    
  30.         symbol = tokenSymbol;                               // Set the symbol for display purposes    
  31.         decimals = decimalUnits;                            // Amount of decimals for display purposes        
  32.         timeOfLastProof = now;
  33.     }
  34.  
  35.     function proofOfWork(uint nonce){
  36.         bytes8 n = bytes8(sha3(nonce, currentChallenge));    // Generate a random hash based on input
  37.         if (n < bytes8(difficulty)) throw;                   // Check if it's under the difficulty
  38.  
  39.         uint timeSinceLastProof = (now - timeOfLastProof);  // Calculate time since last reward was given
  40.  
  41.         difficulty = difficulty * 1 minutes / timeSinceLastProof + 1;  // Adjusts the difficulty
  42.  
  43.         timeOfLastProof = now;                              // Reset the counter
  44.         currentChallenge = sha3(nonce, currentChallenge, block.blockhash(block.number));  // Save a hash that will be used as the next proof
  45.         balanceOf[msg.sender] += timeSinceLastProof / 6 seconds;  // The reward to the winner grows by the minute
  46.     }
  47.  
  48.     /* Send coins */
  49.     function transfer(address _to, uint256 _value) {
  50.         if (balanceOf[msg.sender] < _value) throw;           // Check if the sender has enough  
  51.         if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
  52.         balanceOf[msg.sender] -= _value;                     // Subtract from the sender
  53.         balanceOf[_to] += _value;                            // Add the same to the recipient            
  54.         Transfer(msg.sender, _to, _value);                   // Notify anyone listening that this transfer took place
  55.     }
  56.  
  57.     /* Allow another contract to spend some tokens in your behalf */
  58.  
  59.     function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
  60.         allowance[msg.sender][_spender] = _value;    
  61.         tokenRecipient spender = tokenRecipient(_spender);
  62.         spender.receiveApproval(msg.sender, _value, this, _extraData);  
  63.     }
  64.  
  65.     /* A contract attempts to get the coins */
  66.  
  67.     function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
  68.         if (balanceOf[_from] < _value) throw;                 // Check if the sender has enough  
  69.         if (balanceOf[_to] + _value < balanceOf[_to]) throw;  // Check for overflows
  70.         if (spentAllowance[_from][msg.sender] + _value > allowance[_from][msg.sender]) throw;   // Check allowance
  71.         balanceOf[_from] -= _value;                          // Subtract from the sender
  72.         balanceOf[_to] += _value;                            // Add the same to the recipient            
  73.         spentAllowance[_from][msg.sender] += _value;
  74.         Transfer(msg.sender, _to, _value);
  75.     }
  76.  
  77.     /* This unnamed function is called whenever someone tries to send ether to it */
  78.     function () {
  79.         throw;     // Prevents accidental sending of ether
  80.     }        
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement