Smart contracts explained to a kid

Smart contracts are a huge revolution of todays financial system. They have a really great impact on every deal, by automatic…

Smart contracts explained to a kid

Smart contracts are a huge revolution of todays financial system. They have a really great impact on every deal, by automatic implementation of code on blockchain. This solution skips payment to the middlemen, by granting assets to participants, and also fees for validating transactions.


Agenda:

  • Intro,
  • Definition,
  • How it works,
  • Example,
  • Benefits of smart contract,
  • How to build smart contract

Definition

Smart contracts are the pieces of code stored on the blockchain. These programs run when predetermined conditions are met. It focuses on automatic updates execution, so that outcome can be immediately determined.


How it works

Smart contracts work by following simple statements, like “if/else”. As it is decentralized code, the network has to approve validation, there is no place for cheating. Let’s see on the example:

Example

Two users bet with each other which football team will win the match. They can bet by simple agreement, then trust themselves that the second side will pay winner promised holdings.

On the other hand, they can have a decentralized contract, which automatically will charge the loser and pay the winner, with small fee. There is no way back, blockchain is immutable, so cheating is not an option.

If you want to learn more about blockchain, visit my latest thread:

https://twitter.com/kacperhernacki/status/1543931257301630976?s=21


Benefits of smart contract

  • speed, efficiency and accuracy

It is executed immediately and is totally digital. No paperwork and delay.

  • Trust and transparency

Practically, it is as safe as blockchain. Totally encrypted and decentralized.

If you do not know how blockchain is validating new transactions, check the post about hashing:

https://twitter.com/kacperhernacki/status/1544663304567721985?s=21


  • Savings

Smart contracts remove third party institutions from the “circle of money”. There is no need to pay them anything.


How to build smart contract

Let’s quickly go through what is needed to create smart contract. Firstly, it is important to become the part of the network, by creating a wallet and buying some assets on blockchain which we want to use.

Secondly, use the programming language dedicated to writing smart contracts: solidity or rust. Highly recommend doing it with editor Remix, it is very intuitive and deploying is with literally two clicks.

Like described above, deploy the code and pay fees. Quality of code is the big factor of fees value, using unnecessary variables can increase the payment. However, there are tested and ready contracts available on different libraries.