24 Blocks — Building an Blockchain Advent Calendar

Sebastian Gerske
HackerNoon.com
3 min readDec 20, 2017

--

congerdesign / pixabay

After such a crazy year in the Blockchain / Cryptocurrency scene i wanted to build something new and unique for my beloved. Suddenly the idea came to my mind to connect the Blockchain topic to the Christmas topic and i started making up an Blockchain Advent Calendar. Calendars tend to be linear like a Blockchain so why not give it a try and combine both.

What you need:

  • 24 Containers like Boxes, Bags, Socks or what ever can contain your sweets
  • 24 Items to put in the containers (thats the hardest part)
  • Node JS (>= 9.3.0) / npm or yarn / basic JavaScript programming Skills (or just copy & paste my scripts)
  • Printer / Scissors / Glue / Office materials

Basically the whole Calendar logic is described in the calendar.js seen below. For every item in the list a new Block is created and attached to the Blockchain. After all Blocks are added the program prints out the whole Blockchain. You just have to list your 24 Items you would like to put in the Calendar in the Array starting at Line 4. This script is using a Blockchain library called Blockchain lite. You have to install it prior with the command:

or

if you are using yarn. This should install the package blockchain-lite from the npm registry.

After running the command:

You should get an output like it’s shown in the calendar-output.txt file below. I used the command:

To pipe the output to a text file called calendar.txt

After that we ended up with an array of 24 (0 to 23) Blocks containing all the information we inserted earlier and additional meta information like timestamp and index. All the blocks and the data inside are consistent and hashed correctly. If you would change a single item in the Blockchain the whole chain would be inconsistent and it would be necessary to rewrite the whole chain to become consistent again. The first block does not have a previous hash. This block is our genesis block or 1st of December. The block with the index 23 is our last block or 24th of December.

After piping the output to the calendar.txt file i have altered the file manually. I removed all the meta information and the data from the file. I wanted to keep my ledger private ;).

I also shortened parts of the hashes between character 12 and 52 to make sure the output fits on my boxes. Also it was not necessary to have 64 character long hashes, they are unique in 24 blocks anyway.

Now you just need to print out the blocks (calendar.txt) on Christmas like paper (thick red cardboard or something like this). Fill the containers with the items. Cut the printed Block hashes in pieces and attach the to the right container. Mix all the containers and you are done. At the 1st of December you would need to search for the block without a previous hash or the genesis block. On the 2nd of December you need to search for the container that’s previous hash is identical with the hash of the container of the day before. And so one, this should get easier every day.

Do yourself a favour and don’t line up the containers on a string because that would spoil the fun searching for the right hash / previous hash combination.

I would like to wish you happy chaining, happy holidays and a happy new year. Take care.

--

--

HackerNoon.com
HackerNoon.com

Published in HackerNoon.com

Elijah McClain, George Floyd, Eric Garner, Breonna Taylor, Ahmaud Arbery, Michael Brown, Oscar Grant, Atatiana Jefferson, Tamir Rice, Bettie Jones, Botham Jean

Sebastian Gerske
Sebastian Gerske

Written by Sebastian Gerske

Extroverted nerd, Language agnostic software developer, Cloud evangelist, Agile minded, Speaker, Founder, Obsessed with new technology especially Blockchain.

Responses (3)