Back to Home

MeatConversionCalculator

0x4ab274fc3a81...b94c81fa54d2
HomesteadAuthor-Published Source
Deployed March 24, 2016 (9 years ago)Block 1,211,128

This contract is not yet documented

Know something about this contract? Switch to the History tab and suggest an edit to help preserve Ethereum history.

Key Facts

Deployment Block
1,211,128
Deployment Date
Mar 24, 2016, 10:45 PM
Code Size
490.0 B
Transactions by Year
20161

Source Verified

SolidityAuthor-published source

Source code and compiler settings published by Alex Van de Sande (avsa). Converts Unicorn tokens into Unicorn Meat through a one-way grinder mechanism.

Homestead Era

The first planned hard fork. Removed the canary contract, adjusted gas costs.

Block span: 1,150,0001,919,999
March 14, 2016July 20, 2016

Bytecode Overview

Opcodes490
Unique Opcodes83
Jump Instructions36
Storage Operations15

Verified Source Available

Source code published by the original contract author.

View Verification Proof
Show source code (Solidity)
contract owned {
    address public owner;

    function owned() {
        owner = msg.sender;
    }

    modifier onlyOwner {
        if (msg.sender != owner) throw;
        _
    }

    function transferOwnership(address newOwner) onlyOwner {
        owner = newOwner;
    }
}



contract MeatConversionCalculator is owned {
    uint public amountOfMeatInUnicorn;
    uint public reliabilityPercentage;

    /* generates a number from 0 to 2^n based on the last n blocks */
    function multiBlockRandomGen(uint seed, uint size) constant returns (uint randomNumber) {
        uint n = 0;
        for (uint i = 0; i < size; i++){
            if (uint(sha3(block.blockhash(block.number-i-1), seed ))%2==0)
                n += 2**i;
        }
        return n;
    }
    
    function MeatConversionCalculator(
        uint averageAmountOfMeatInAUnicorn, 
        uint percentOfThatMeatThatAlwaysDeliver
    ) {
        changeMeatParameters(averageAmountOfMeatInAUnicorn, percentOfThatMeatThatAlwaysDeliver);
    }
    function changeMeatParameters(
        uint averageAmountOfMeatInAUnicorn, 
        uint percentOfThatMeatThatAlwaysDeliver
    ) onlyOwner {
        amountOfMeatInUnicorn = averageAmountOfMeatInAUnicorn * 1000;
        reliabilityPercentage = percentOfThatMeatThatAlwaysDeliver;
    }
    
    function calculateMeat(uint amountOfUnicorns) constant returns (uint amountOfMeat) {
        uint rnd = multiBlockRandomGen(uint(sha3(block.number, now, amountOfUnicorns)), 10);

       amountOfMeat = (reliabilityPercentage*amountOfUnicorns*amountOfMeatInUnicorn)/100;
       amountOfMeat += (1024*(100-reliabilityPercentage)*amountOfUnicorns*amountOfMeatInUnicorn)/(rnd*100);

    }
}

External Links