• finance /
  • crypto

Smart Contract - The Intelligent Contract?

  • Rush
    Rush Vermögenstracker e.U.

If we were to look at the whole thing theoretically, we would have to make this introduction: A contract always involves at least two parties. For a contract to come into force, there must be an offer. This offer must be accepted. All parties to the contract must agree on the elements of the contract. Then, in old-fashioned terms, a contract is drawn up and signed by both parties. After that, all contracting parties are bound by the agreement.

Smart contracts are intended to simplify precisely this last part of contract creation and execution.

For an easier understanding, it is beneficial to know how the blockchain works. Here you can find the basics.

However, let's dive into the topic of Smart Contracts. As you may already know, "Smart Contracts" are contracts that can be made between two or more parties on the Blockchain. The big advantage here is that no intermediaries are needed for proper execution. When we settle a contract with the help of a notary, for example, we have to trust that the notary is neutral to both parties to the contract and really only helps execute the agreed-upon parts of the contract, but does not favor one party.

If everything works smoothly, that's great. If the notary or even a bank is not honest, the trust loses its foundation. A person is quite simply not forgery-proof, to put it casually. Here we have already explained why it is almost impossible for the blockchain to be manipulated. For this reason, the interest of one party cannot outweigh the interest of the other party. All parties are entitled according to the contractual agreements. Subsequent modification is impossible. For this reason, it is much easier to trust this system.

Smart contracts are already being used in many different areas. For example, it is possible to use a smart contract to pay employees their salary at the end of the month. In another example, money is raised as part of a crowdfunding campaign, but the goal is not reached. Subsequently, the money can be automatically returned to all payers without having to go through a long bureaucratic process.

We explain how smart contracts work here using probably the best-known smart contract platform currently available. Ethereum. Like the Bitcoin blockchain, the Ethereum blockchain consists of miners and nodes.

As a special feature that also enables the execution of smart contracts, nodes of the Ethereum Blockchain have one more task.

With the help of a software, the Ethereum Virtual Machine, EVM for short, the smart contracts can be executed on the nodes. Nodes are basically a large number of computers or servers.  

But what does a smart contract actually look like and how does it get onto the blockchain? 

First, let's get to the concept of an account. An account can basically be compared to a bank account in its basic features. Ether, the basic currency of the Ethereum Blockchain, can be received, sent or held. To do this, you need to know that Ethereum recognizes two types of accounts. Accounts that are controlled by humans and those that are controlled by code.

A simple transaction of Ether looks like this:

    from: Jane

    to: John

    amount: 1 ether

    data: "Thank you for watering my flowers the last few days."

As with a traditional bank transfer, there is a sender and a recipient. Both of them are one account each. Both Jane and John have an account. This is controlled by them. Both can decide when and if they send funds and to whom they send them. They always decide anew. For this reason, these are human-controlled accounts. It is clear what amount of Ether should be sent. Additionally, there is another field here called "Data". You can write anything into this field in terms of content. In this case, this can be compared to the reference field of a bank transfer. In this case Jane sends an Ether to John. Jane's balance decreases by one Ether, John's balance increases by one Ether.

Additionally, there is a special form of this transaction. This one does not know a receiver.

    from: Jane

    to: null #!! amount: 0 ether

    data: ... # bytecode

Looks a bit scary at first glance, but don't worry, we'll clear up every single item here.

So, apparently, this transaction is sent into the system without a receiver. Such a transaction is used to create a smart contract. In the Data field, the code of the smart contract is stored, that is, everything that concerns the contractual agreements and their execution. In this way, it becomes clear who the recipient(s) of the transaction are and what quantities are to be sent. When the EVM recognizes that it is a smart contract, another account is generated. This is created specifically for this Smart Contract. This account is controlled by its code. John and Jane only have an indirect influence on it. By sending a transaction to this account, they can trigger the events agreed upon in the Smart Contract.

The example with the care of the plants is mainly for understanding. As we go on, we will see that there are more useful examples where it is even easier to see why a Smart Contract is a brilliant idea.

The EVM executes the transaction in the form of the smart contract. This changes the state of the EVM. However, this change must be checked for correctness by other nodes. In order to do this, the transaction is written into the next free block by the miner alongside other transactions. The block is handed over to the network for verification. If all nodes accept the block presented to them along with its transactions, the block is appended to the blockchain.

Whenever we use a third party to process contracts, for example a bank or a notary, fees are incurred. While settling a contract on the blockchain using smart contracts is a lot cheaper than doing it through an intermediary party, there are still small fees involved. The miners, who in the final step insert the smart contract transaction into a block and attach it to the blockchain, are paid for their work. Just as the working time of a notary is specified in hours, the miner's effort is also specified. However, this is not in the form of a time specification, but in the form of another unit. This unit is called "gas." 

Gas indicates the extent to which the miner's resources are used. Each gas unit is weighted with a certain amount of ether. The miner is then paid the corresponding amount of Ether for his work. These are the fees that a user of a smart contract has to pay.

As announced earlier, here we briefly show again how these whole theoretical facts become a bit easier to understand. 

Let's play a game

I flip a coin, we each bet one euro on one side of the coin. I bet heads, you bet tails. I suggest that you give me your Euro, then I flip the coin. If the result is tails, I give you my euro and your euro. You win the game. Otherwise I keep both coins. Since we don't know each other, it's probably hard for you to believe me that everything is fair and random. But if we call in an independent third party as a referee, it's easier to build up trust. But you can't be sure that I won't cooperate with the arbitrator and that we won't screw you over. You need an authority that is neutral in any case and that is recognizable for me as well as for you. A smart contract is ideal for this.

Smart contracts will have an influence in many areas of life in the future. Of course, you can also go much deeper into the matter here. For now, however, we hope that the basic functionality of a smart contract is now clear. In addition, we also got to know the Ethereum Blockchain.