Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 0x45601D0497419Ec993552EF425927F08f73CE032
- [ { "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": " <span class=\"punctuation\">_</span> from", "template": "elements_input_address" }, { "name": "_to", "type": "address", "typeShort": "address", "bits": "", "displayName": " <span class=\"punctuation\">_</span> to", "template": "elements_input_address" }, { "name": "_value", "type": "uint256", "typeShort": "uint", "bits": "256", "displayName": " <span class=\"punctuation\">_</span> 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": " <span class=\"punctuation\">_</span> to", "template": "elements_input_address" }, { "name": "_value", "type": "uint256", "typeShort": "uint", "bits": "256", "displayName": " <span class=\"punctuation\">_</span> value", "template": "elements_input_uint" } ], "name": "transfer", "outputs": [], "type": "function", "displayName": "transfer" }, { "constant": false, "inputs": [ { "name": "_spender", "type": "address", "typeShort": "address", "bits": "", "displayName": " <span class=\"punctuation\">_</span> spender", "template": "elements_input_address" }, { "name": "_value", "type": "uint256", "typeShort": "uint", "bits": "256", "displayName": " <span class=\"punctuation\">_</span> value", "template": "elements_input_uint" }, { "name": "_extraData", "type": "bytes", "typeShort": "bytes", "bits": "", "displayName": " <span class=\"punctuation\">_</span> 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" } ]
- contract tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); }
- contract MyToken {
- /* Public variables of the token */
- string public name;
- string public symbol;
- uint8 public decimals;
- /* Proof of Work configuration */
- bytes32 public currentChallenge; // The coin starts with a challenge
- uint public timeOfLastProof; // Variable to keep track of when rewards were given
- uint public difficulty = 10**32; // Difficulty starts reasonably low
- /* This creates an array with all balances */
- mapping (address => uint256) public balanceOf;
- mapping (address => mapping (address => uint)) public allowance;
- mapping (address => mapping (address => uint)) public spentAllowance;
- /* This generates a public event on the blockchain that will notify clients */
- event Transfer(address indexed from, address indexed to, uint256 value);
- /* Initializes contract with initial supply tokens to the creator of the contract */
- function MyToken(uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol) {
- balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
- name = tokenName; // Set the name for display purposes
- symbol = tokenSymbol; // Set the symbol for display purposes
- decimals = decimalUnits; // Amount of decimals for display purposes
- timeOfLastProof = now;
- }
- function proofOfWork(uint nonce){
- bytes8 n = bytes8(sha3(nonce, currentChallenge)); // Generate a random hash based on input
- if (n < bytes8(difficulty)) throw; // Check if it's under the difficulty
- uint timeSinceLastProof = (now - timeOfLastProof); // Calculate time since last reward was given
- difficulty = difficulty * 1 minutes / timeSinceLastProof + 1; // Adjusts the difficulty
- timeOfLastProof = now; // Reset the counter
- currentChallenge = sha3(nonce, currentChallenge, block.blockhash(block.number)); // Save a hash that will be used as the next proof
- balanceOf[msg.sender] += timeSinceLastProof / 6 seconds; // The reward to the winner grows by the minute
- }
- /* Send coins */
- function transfer(address _to, uint256 _value) {
- if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
- if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
- balanceOf[msg.sender] -= _value; // Subtract from the sender
- balanceOf[_to] += _value; // Add the same to the recipient
- Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
- }
- /* Allow another contract to spend some tokens in your behalf */
- function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
- allowance[msg.sender][_spender] = _value;
- tokenRecipient spender = tokenRecipient(_spender);
- spender.receiveApproval(msg.sender, _value, this, _extraData);
- }
- /* A contract attempts to get the coins */
- function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
- if (balanceOf[_from] < _value) throw; // Check if the sender has enough
- if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
- if (spentAllowance[_from][msg.sender] + _value > allowance[_from][msg.sender]) throw; // Check allowance
- balanceOf[_from] -= _value; // Subtract from the sender
- balanceOf[_to] += _value; // Add the same to the recipient
- spentAllowance[_from][msg.sender] += _value;
- Transfer(msg.sender, _to, _value);
- }
- /* This unnamed function is called whenever someone tries to send ether to it */
- function () {
- throw; // Prevents accidental sending of ether
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement