Blockchain, a buzz word that everyone has heard of these days, often mentioned alongside with the best known cryptocurrency: Bitcoin. But how much do we actually know about blockchain? Do we really grasp the underlying technology? Is there more to blockchain than Bitcoin? Can we as software developers write software applying blockchain technology? These are some of the questions we asked ourselves on the last meetup at Sourcelabs.
At the beginning of the day, we wanted to get a better understanding of blockchain technology, before delving into its applications. The video of 3Blue1Brown gives a very clear and visual explanation on how blocks are created, what information they contain, and how they are chained together (hence the name).
The video explains how it is possible that users can trust the information on the blockchain without having to trust its contributors. It explains what mining actually means, and how hashing is used to construct a Proof of Work. Understanding this also led us to why crypto mining is so energy inefficient: miners have to do lots and lots of complex (and in itself useless) computations to prove that the new block on the chain is valid. Also, when one miner solves the puzzle earlier than the others, the work of the others was basically done for nothing.
Blockchain in Kotlin
Because we are Kotlin enthusiasts, we briefly looked at an article that implements a cryptocurrency in Kotlin from scratch. Because: you really understand something if you can build it yourself.
Is there more to blockchain than Bitcoin?
Bitcoin is the best known cryptocurrency that uses blockchain technology. The second-largest blockchain is Ethereum. Ethereum also has a cryptocurrency, called Ether, but is much more than that. Ethereum was designed to allow developers to write their own software and publish it to and run it on the blockchain. Such a decentralized application is called a smart contract. The programming language on Ethereum to write these is Solidity. We watched two videos to understand what smart contracts are and how to write a simple implementation.
Of course we also wanted to get our hands dirty and write some code. This tutorial explains the basics of Solidity, how to define variables, write functions, etc.
After having seen the basics of Solidity, we were still slightly puzzled on how smart contracts actually work. How is the code deployed to the blockchain? How is the state maintained? We did get quite a better understanding when we used Ganache CLI to run an emulated blockchain on localhost. Using the Ethereum IDE Remix, others could connect over the network to the blockchain. We discovered how to write a contract, compile it, and deploy it to the blockchain. The code itself is then added as a transaction on the blockchain, and can be run by others. You do need to provide others with the address on which the code resides. If you write a simple program that updates the value of a (global) variable, then that update action is also added as a transaction on the blockchain, and allows others to get the latest state of the value. When we got to this point, we had to get ready for the first post-pandemic team barbecue. In the future, it would be cool to implement our own SlabsStash cryptocurrency, or perhaps an ‘EK pool’, on which we can win points by guessing what the results of the matches will be in the European soccer championship, and see what others have guessed.
After a long period of online meetups only, it was very pleasant to meat each other in real life again. We ended the day with a nice barbecue in the garden. For many colleagues, this was the first time they saw each other in real life! We look forward to the time that we can safely go to a restaurant with the team again, or perhaps on a trip abroad?