Introduction to Ethereum, Smart Contracts and Solidity
Beginners Guide to Solidity Development - Episode 1
Episode 1: Introduction into Ethereum, Smart Contracts and Solidity
TheTokener Explains, the beginners guide to developing smart contracts using the Solidity programing language on top of the Ethereum Blockchain platform. In this first episode, I will introduce Ethereum and the concepts Smarts Contracts and Solidity to you.
About this guide:
This guide will be a practical guide to quickly develop your own smart contracts. As such we will not go into a lot of theoretical background about Ethereum. There is a lot of interesting stuff there, and we highly recommend that you check it out. In this guide, we'll only give you some overview information just enough to easily get you started and understanding how you can interact with it.
It really helps if you already have some prior knowledge if you want to use this guide, maybe if you already used different programing language before.
Also, we will be using a terminal or command line interface in some of the later episodes. So if you know your way around on the command line it does really help to understand what's going on.
Brief introduction of Ethereum
Alright, let start with a little bit of background information in the history of how Ethereum came to be because this really helps to understand how you can use it.
In 2008. Satoshi Nakamoto published a whitepaper, an academic paper about Bitcoin. Bitcoin was the first system, a first software system that allowed to perform payments in a decentralized way, digitally. He was able to do so by using the technology he introduced, called the block chain. A block chain can be understood as a data store stored in many different locations containing all transactions that have taken place so far in the system. For bitcoin, these transactions were only monetary transactions so how much money one person paid another person. But it didn't take very long before people realize that you can also store other types of information in there.
In 2013. Vitalik Buterin published an academic paper about Ethereum.
Ethereum improved on the ideas of Bitcoin by altering the blockchain so that it could store arbitrary information, including programming code.
So, you could run programs on top of the blockchain system. Buterin realized that you could use this to create decentralized computer programs both financial nature as well as computer games, also to create voting applications to allow you to manage organizations in a decentralized or an autonomous way. He also realized that you could create a value representation of many different kinds and in this way transfer value or ownership of all kinds of things on this system without any centralized oversight. This system is known as a blockchain network that executes smart contracts.
That is what Ethereum at its core is. Of course, what exactly do these two terms mean? Well, that is what I am going to explain next.
A Blockchain Network is a group of nodes that are able to talk to each other over the internet.
A Node is a piece of software that anyone who wants to join can run on their computer. Now, this network as a whole is used to store information and of course also transfer information from one place to another. And, every one of these nodes of this software instances manages a complete copy of a blockchain. So, every node knows everything that happened so far. This is important because this is the property that allows every node to validate what someone tries to do or execute and check if that is indeed allowed and this is what allows the system to run without any centralized oversight.
Now, on top of this blockchain network of Ethereum, we are able to execute what is known as smart contracts. They can be understood as pieces of program code that lives on top of the Ethereum blockchain. Now, a smart contract basically consists of two parts:
it might contain a couple of data fields which are basically
containers that might contain a little bit of information and what exactly, what type or what value is stored in there might actually change while time goes on.
The smart contract can also contain a couple of functions that
read the values that are currently stored in the data fields or alter the value stored in there. It's important to note that smart contract once published in the blockchain can never be altered anymore.
While you're able to change what value is stored inside the data fields you are only allowed to do this using the functions that a current computer code provides. Actual code itself can never be altered anymore. This means that if you made a mistake in your code, there is no way to fix this late on. This is why smart contract development is very very difficult to do properly, but also why is it an extremely exciting subject.
Interacting with a Smart Contract
When you published a smart contract you can interact with it by communicating with it through your locally running node software (AKA the Ethereum Client). Of course, you can also communicate with a node that runs on someone else's computer but in this case you have to completely trust that that computer gives you valid information at all times. Smart Contract in itself is very rudimentary in the types of values it is able to store and the type of information it gives you back. Also, it rather slow and you have to wait a long time before (with a long time I mean a couple of seconds, up to a couple of minutes) before you receive confirmation of some change you made. This means that to actually create a program that is interesting to the user you'll require to write some front-end software as well. Nowadays there are some very interesting technologies and we will go into more details about it in some later episode that allows you to create such a front-end program which is often known also as decentralized application('Dapp') and store this in a way that is decentralized.
Alright, when we write smart contract then this is usually done using the Solidity programming language.
Solidity is usually stored as a text file with a
.sol extension. Its
means exactly is something we will explore in one or two episodes down
Now, sometimes what Solidity does and doesn't do for you or does support and does not support can be quite counterintuitive or tricky to understand. I will try to point these things out to you because there are some mistakes to be made there and most of these things happen because Solidity doesn't run on a normal computer but rather it runs on top of a blockchain system. I will try to point these out whenever we encounter them, of course.