Skip to content

Instantly share code, notes, and snippets.

@alexvandesande
Last active October 20, 2021 01:22
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save alexvandesande/eca0b87da89ab28fa50c to your computer and use it in GitHub Desktop.
Save alexvandesande/eca0b87da89ab28fa50c to your computer and use it in GitHub Desktop.

You all know the Unicorn Token a small gratitude token sent by the Foundation to all good samaritans. Althought it has been successful, unicorns have some issues: it's expensive (2014 finney), non divisible (you can't split a unicorn) and it can only be acquired by the pure of heart. Today, all of that will change:

The Unicorn Meat Grinder

Now all the evil etherians will finally be able hack your own unicorns into tiny little pieces. The Unicorn Meat Grinder is a contract that will take your unicorns, send them to unicorn heaven and will send you back a bunch of meat token. Each Unicorn is worth about a 1000 pieces of meat, but depending on your luck you might get more. Each token is divisible to 3 decimal places, so each single unicorn will be exchanged for more than a million smaller units.

What is this? You can't kill unicorns!!

No? Watch me.

Does the Ethereum Foundation Endorses the harming of unicorns??

No. This is all the work of a rogue ethereum developer. Our executive director Ming Chan was a little bit concerned with he harming of baby unicorns so I'd like to say that the Foundation does not endorse any part of this. So, grinding unicorns is not for the pure of heart and might put you on the nasty list.

I absolutely hate this. Can unicorn lovers put a stop to it?

As a matter of fact yes. All rules about Unicorn Grinding are controlled by the Unicorn Meat Grinder Association, a DAO that that allows anyone who owns unicorn tokens to vote on what to do. You can use it to increase the amount of meat in a unicorn, decrease the reliability, change the contract that calculates the amount of meat or change anything else you want. The Association is set up so that each negative vote is worth 4 support votes, meaning that a tiny vocal minority of 20% of all unicorns can veto any proposal. Also, there's a rumor that the Association might take bribes when counting votes. The kids today call it "quadratic voting".

Also, I donated a little bit of moola to the Association, in the hopes that it uses that to build some sort of site or app.

Is this an April first joke?

Yes and no. Of course, this is in the spirit of April fools, but the contract code is 100% real and functional. More importantly than that, it showcases some important functionalities that are crucial to other token creators, specially the ability to upgrade a token, by locking an old token and sending a new token back to the holder. It also tests the ability of a contract to receive tokens and execute functions, something that is crucial in order to build more functionalities like a decentralized exchange. Finally, these contracts also test a semi random function, and quadratic voting. During the development of these functions (mostly during my free time) I also found out some very nasty bugs in the Wallet, Mix and on the token standard, so it was very productive.

Enough talk, let's make some Unicorn Meat!

First you'll need to add these contracts to your watch list on the wallet:


Unicorn Token Admin page

Address: 0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7

Interface:

[ { "constant": true, "inputs": [], "name": "name", "outputs": [ { "name": "", "type": "string", "value": "Unicorns", "displayName": "" } ], "type": "function", "displayName": "name" }, { "constant": false, "inputs": [ { "name": "_spender", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;spender", "template": "elements_input_address" }, { "name": "_value", "type": "uint256", "index": 1, "typeShort": "uint", "bits": "256", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;value", "template": "elements_input_uint" } ], "name": "approve", "outputs": [ { "name": "success", "type": "bool" } ], "type": "function", "displayName": "approve" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [ { "name": "", "type": "uint256", "value": "709", "displayName": "" } ], "type": "function", "displayName": "total Supply" }, { "constant": false, "inputs": [ { "name": "_from", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;from", "template": "elements_input_address" }, { "name": "_to", "type": "address", "index": 1, "typeShort": "address", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;to", "template": "elements_input_address" }, { "name": "_value", "type": "uint256", "index": 2, "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": "", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" } ], "name": "balanceOf", "outputs": [ { "name": "", "type": "uint256", "value": "0", "displayName": "" } ], "type": "function", "displayName": "balance Of" }, { "constant": false, "inputs": [ { "name": "target", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "target", "template": "elements_input_address" }, { "name": "mintedAmount", "type": "uint256", "index": 1, "typeShort": "uint", "bits": "256", "displayName": "minted Amount", "template": "elements_input_uint" } ], "name": "mintToken", "outputs": [], "type": "function", "displayName": "mint Token" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [ { "name": "", "type": "address", "value": "0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359", "displayName": "" } ], "type": "function", "displayName": "owner" }, { "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "name": "", "type": "string", "value": "🦄", "displayName": "" } ], "type": "function", "displayName": "symbol" }, { "constant": false, "inputs": [ { "name": "_to", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;to", "template": "elements_input_address" }, { "name": "_value", "type": "uint256", "index": 1, "typeShort": "uint", "bits": "256", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;value", "template": "elements_input_uint" } ], "name": "transfer", "outputs": [], "type": "function", "displayName": "transfer" }, { "constant": true, "inputs": [ { "name": "", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" } ], "name": "frozenAccount", "outputs": [ { "name": "", "type": "bool", "value": false, "displayName": "" } ], "type": "function", "displayName": "frozen Account" }, { "constant": true, "inputs": [ { "name": "", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" }, { "name": "", "type": "address", "index": 1, "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", "index": 0, "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" }, { "name": "", "type": "address", "index": 1, "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" } ], "name": "allowance", "outputs": [ { "name": "", "type": "uint256", "value": "0", "displayName": "" } ], "type": "function", "displayName": "allowance" }, { "constant": false, "inputs": [ { "name": "target", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "target", "template": "elements_input_address" }, { "name": "freeze", "type": "bool", "index": 1, "typeShort": "bool", "bits": "", "displayName": "freeze", "template": "elements_input_bool" } ], "name": "freezeAccount", "outputs": [], "type": "function", "displayName": "freeze Account" }, { "constant": false, "inputs": [ { "name": "newOwner", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "new Owner", "template": "elements_input_address" } ], "name": "transferOwnership", "outputs": [], "type": "function", "displayName": "transfer Ownership" }, { "inputs": [ { "name": "initialSupply", "type": "uint256" }, { "name": "tokenName", "type": "string" }, { "name": "decimalUnits", "type": "uint8" }, { "name": "tokenSymbol", "type": "string" }, { "name": "centralMinter", "type": "address" } ], "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" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "target", "type": "address" }, { "indexed": false, "name": "frozen", "type": "bool" } ], "name": "FrozenFunds", "type": "event" } ]

Unicorn Meat Grinder Association

Address: 0xc7e9dDd5358e08417b1C88ed6f1a73149BEeaa32 Interface:

[ { "constant": true, "inputs": [ { "name": "", "type": "uint256", "index": 0, "typeShort": "uint", "bits": "256", "displayName": "", "template": "elements_input_uint" } ], "name": "proposals", "outputs": [ { "name": "recipient", "type": "address" }, { "name": "amount", "type": "uint256" }, { "name": "description", "type": "string" }, { "name": "votingDeadline", "type": "uint256" }, { "name": "executed", "type": "bool" }, { "name": "proposalPassed", "type": "bool" }, { "name": "numberOfVotes", "type": "uint256" }, { "name": "proposalHash", "type": "bytes32" } ], "type": "function", "displayName": "proposals" }, { "constant": true, "inputs": [], "name": "rejectionMultiplier", "outputs": [ { "name": "", "type": "uint256", "value": "4", "displayName": "" } ], "type": "function", "displayName": "rejection Multiplier" }, { "constant": false, "inputs": [ { "name": "proposalNumber", "type": "uint256", "index": 0, "typeShort": "uint", "bits": "256", "displayName": "proposal Number", "template": "elements_input_uint" }, { "name": "transactionBytecode", "type": "bytes", "index": 1, "typeShort": "bytes", "bits": "", "displayName": "transaction Bytecode", "template": "elements_input_bytes" } ], "name": "executeProposal", "outputs": [ { "name": "result", "type": "int256" } ], "type": "function", "displayName": "execute Proposal" }, { "constant": true, "inputs": [], "name": "numProposals", "outputs": [ { "name": "", "type": "uint256", "value": "0", "displayName": "" } ], "type": "function", "displayName": "num Proposals" }, { "constant": false, "inputs": [ { "name": "_from", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;from", "template": "elements_input_address" }, { "name": "_value", "type": "uint256", "index": 1, "typeShort": "uint", "bits": "256", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;value", "template": "elements_input_uint" }, { "name": "_token", "type": "address", "index": 2, "typeShort": "address", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;token", "template": "elements_input_address" } ], "name": "receiveApproval", "outputs": [], "type": "function", "displayName": "receive Approval" }, { "constant": false, "inputs": [ { "name": "amountOfUnicornsToGrind", "type": "uint256", "index": 0, "typeShort": "uint", "bits": "256", "displayName": "amount Of Unicorns To Grind", "template": "elements_input_uint" } ], "name": "grindUnicorns", "outputs": [], "type": "function", "displayName": "grind Unicorns" }, { "constant": false, "inputs": [ { "name": "unicornAddress", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "unicorn Address", "template": "elements_input_address" }, { "name": "meatAddress", "type": "address", "index": 1, "typeShort": "address", "bits": "", "displayName": "meat Address", "template": "elements_input_address" }, { "name": "minimumSharesToPassAVote", "type": "uint256", "index": 2, "typeShort": "uint", "bits": "256", "displayName": "minimum Shares To Pass A Vote", "template": "elements_input_uint" }, { "name": "minutesForDebate", "type": "uint256", "index": 3, "typeShort": "uint", "bits": "256", "displayName": "minutes For Debate", "template": "elements_input_uint" }, { "name": "multiplierForVotesAgainst", "type": "uint256", "index": 4, "typeShort": "uint", "bits": "256", "displayName": "multiplier For Votes Against", "template": "elements_input_uint" } ], "name": "changeVotingRules", "outputs": [], "type": "function", "displayName": "change Voting Rules" }, { "constant": true, "inputs": [], "name": "unicornTokenAddress", "outputs": [ { "name": "", "type": "address", "value": "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7", "displayName": "" } ], "type": "function", "displayName": "unicorn Token Address" }, { "constant": true, "inputs": [ { "name": "x", "type": "uint256", "index": 0, "typeShort": "uint", "bits": "256", "displayName": "x", "template": "elements_input_uint" } ], "name": "sqrt", "outputs": [ { "name": "y", "type": "uint256", "value": "0", "displayName": "y" } ], "type": "function", "displayName": "sqrt" }, { "constant": true, "inputs": [], "name": "debatingPeriodInMinutes", "outputs": [ { "name": "", "type": "uint256", "value": "0", "displayName": "" } ], "type": "function", "displayName": "debating Period In Minutes" }, { "constant": true, "inputs": [], "name": "minimumQuorum", "outputs": [ { "name": "", "type": "uint256", "value": "1", "displayName": "" } ], "type": "function", "displayName": "minimum Quorum" }, { "constant": true, "inputs": [ { "name": "", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "", "template": "elements_input_address" } ], "name": "unicornsKilled", "outputs": [ { "name": "", "type": "uint256", "value": "0", "displayName": "" } ], "type": "function", "displayName": "unicorns Killed" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [ { "name": "", "type": "address", "value": "0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb", "displayName": "" } ], "type": "function", "displayName": "owner" }, { "constant": false, "inputs": [ { "name": "beneficiary", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "beneficiary", "template": "elements_input_address" }, { "name": "etherAmount", "type": "uint256", "index": 1, "typeShort": "uint", "bits": "256", "displayName": "ether Amount", "template": "elements_input_uint" }, { "name": "JobDescription", "type": "string", "index": 2, "typeShort": "string", "bits": "", "displayName": " Job Description", "template": "elements_input_string" }, { "name": "transactionBytecode", "type": "bytes", "index": 3, "typeShort": "bytes", "bits": "", "displayName": "transaction Bytecode", "template": "elements_input_bytes" } ], "name": "newProposal", "outputs": [ { "name": "proposalID", "type": "uint256" } ], "type": "function", "displayName": "new Proposal" }, { "constant": false, "inputs": [ { "name": "proposalNumber", "type": "uint256", "index": 0, "typeShort": "uint", "bits": "256", "displayName": "proposal Number", "template": "elements_input_uint" }, { "name": "supportsProposal", "type": "bool", "index": 1, "typeShort": "bool", "bits": "", "displayName": "supports Proposal", "template": "elements_input_bool" } ], "name": "vote", "outputs": [ { "name": "voteID", "type": "uint256" } ], "type": "function", "displayName": "vote" }, { "constant": true, "inputs": [], "name": "totalUnicornsKilled", "outputs": [ { "name": "", "type": "uint256", "value": "0", "displayName": "" } ], "type": "function", "displayName": "total Unicorns Killed" }, { "constant": true, "inputs": [], "name": "meatTokenAddress", "outputs": [ { "name": "", "type": "address", "value": "0xed6ac8de7c7ca7e3a22952e09c2a2a1232ddef9a", "displayName": "" } ], "type": "function", "displayName": "meat Token Address" }, { "constant": false, "inputs": [ { "name": "newMeatProvider", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "new Meat Provider", "template": "elements_input_address" } ], "name": "changeMeatProvider", "outputs": [], "type": "function", "displayName": "change Meat Provider" }, { "constant": true, "inputs": [ { "name": "proposalNumber", "type": "uint256", "index": 0, "typeShort": "uint", "bits": "256", "displayName": "proposal Number", "template": "elements_input_uint" }, { "name": "beneficiary", "type": "address", "index": 1, "typeShort": "address", "bits": "", "displayName": "beneficiary", "template": "elements_input_address" }, { "name": "etherAmount", "type": "uint256", "index": 2, "typeShort": "uint", "bits": "256", "displayName": "ether Amount", "template": "elements_input_uint" }, { "name": "transactionBytecode", "type": "bytes", "index": 3, "typeShort": "bytes", "bits": "", "displayName": "transaction Bytecode", "template": "elements_input_bytes" } ], "name": "checkProposalCode", "outputs": [ { "name": "codeChecksOut", "type": "bool", "value": false, "displayName": "code Checks Out" } ], "type": "function", "displayName": "check Proposal Code" }, { "constant": true, "inputs": [], "name": "meatProvider", "outputs": [ { "name": "", "type": "address", "value": "0x4ab274fc3a81b300a0016b3805d9b94c81fa54d2", "displayName": "" } ], "type": "function", "displayName": "meat Provider" }, { "constant": false, "inputs": [ { "name": "newOwner", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "new Owner", "template": "elements_input_address" } ], "name": "transferOwnership", "outputs": [], "type": "function", "displayName": "transfer Ownership" }, { "inputs": [ { "name": "unicornAddress", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "unicorn Address", "template": "elements_input_address", "value": "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7" }, { "name": "meatAddress", "type": "address", "index": 1, "typeShort": "address", "bits": "", "displayName": "meat Address", "template": "elements_input_address", "value": "0xED6aC8de7c7CA7e3A22952e09C2a2A1232DDef9A" }, { "name": "minimumUnicornsToPassAVote", "type": "uint256", "index": 2, "typeShort": "uint", "bits": "256", "displayName": "minimum Unicorns To Pass A Vote", "template": "elements_input_uint", "value": "1" }, { "name": "minutesForDebate", "type": "uint256", "index": 3, "typeShort": "uint", "bits": "256", "displayName": "minutes For Debate", "template": "elements_input_uint", "value": "" }, { "name": "multiplierForVotesAgainst", "type": "uint256", "index": 4, "typeShort": "uint", "bits": "256", "displayName": "multiplier For Votes Against", "template": "elements_input_uint", "value": "4" }, { "name": "meatCalculator", "type": "address", "index": 5, "typeShort": "address", "bits": "", "displayName": "meat Calculator", "template": "elements_input_address", "value": "0x4AB274FC3A81B300A0016b3805d9b94C81FA54d2" } ], "type": "constructor" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "proposalID", "type": "uint256" }, { "indexed": false, "name": "recipient", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" }, { "indexed": false, "name": "description", "type": "string" } ], "name": "ProposalAdded", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "proposalID", "type": "uint256" }, { "indexed": false, "name": "position", "type": "bool" }, { "indexed": false, "name": "voter", "type": "address" } ], "name": "Voted", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "proposalID", "type": "uint256" }, { "indexed": false, "name": "result", "type": "int256" }, { "indexed": false, "name": "quorum", "type": "uint256" }, { "indexed": false, "name": "active", "type": "bool" } ], "name": "ProposalTallied", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "minimumQuorum", "type": "uint256" }, { "indexed": false, "name": "debatingPeriodInMinutes", "type": "uint256" }, { "indexed": false, "name": "sharesTokenAddress", "type": "address" } ], "name": "ChangeOfRules", "type": "event" } ]

Add this to your Watch Token List (not the contract watch list)

Unicorn Meat

address: 0xED6aC8de7c7CA7e3A22952e09C2a2A1232DDef9A


And of course, the unicorn token if you don't have it already: 0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7


  1. Do not send unicorn tokens directly to the meatGrind! First you need to give the Unicorn token an approval for a contract to get some unicorns from your wallet. Click on the Unicorn Token Admin page and select the function "Approve". On the _spender field, add the address of the Association: 0xc7e9dDd5358e08417b1C88ed6f1a73149BEeaa32 and on the _value add the amount of unicorns you want to grind. (If you have already grinded some unicorns, you need to add the total, not the new amount, so if you already killed 2 unicorns and now want to kill 3 more, put _value as 5.)

  2. Now go to the association page and select the "Grind Unicorns" function. Select the number of unicorns you want to grind now (it doesnt matter if you have grinded some before). And press execute. Wait a few seconds and you'll be receiving at least a 1000 pieces of meat. There's a small chance you'll get much more than that.

If you want to create a new proposal or vote on proposals, just follow the instructions at the dao page. There are two distinctions from a normal DAO: first, votes against a proposal larger weight, to protect against a simple 51% attack. Secondly, your vote weight will also have a multiplier based on the square of the amount you paid in transaction fees + whatever amount you sent to the association. This means that a vote that sends 100 finney will be 10x more weighted in than a vote that sends only 1 finney.

Is there a Unicorn Killers Hall of Fame?

Not yet. But on the last link you'll find the code for a partially constructed Unicorn Killer Hall of fame. You can feel free to finish it.

Source and more information

All code is licensed as WTFPL. You can find the source code, as well as some other information that might help you verify it's authenticity here.

@zelig
Copy link

zelig commented Mar 25, 2016

grattitude -> gratitude
sucessful -> successful
little bit concerned witht he -> with the

@alexvandesande
Copy link
Author

Thanks Viktor!

@gcolvin
Copy link

gcolvin commented Mar 27, 2016

a little bit concerned with he -> distraught beyond all consolation at the

@rfikki
Copy link

rfikki commented Apr 1, 2016

Get a life! You UnoCorn dividers.

@ethchamps
Copy link

Is this compatible with Ripple?

@yanik-ai
Copy link

yanik-ai commented Apr 1, 2016

oh no! NO NO NO!

@best14you2
Copy link

Dang, I was hoping to get like a million unicorns :) Microcorns or nanocorns, LOL. Can we at least mate them? I mean, a horse pregnancy is like 11-12 months right? I think Unicorns have babies in a similar rate of time.... https://discord.gg/awkwuBR You are invited to join the Crypto Escape Room chat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment