Introduction to Smart Contracts

Nowadays we usually hear about Smart contracts, but what are they? Are they related to law contracts ? Which are the benefits that they bring to the network ? How can I develop a smart contract? In this blog I would like to introduce you to the concept of smart contracts, answering all of these questions and giving you some resources so you can investigate and do your own research.

What is a smart contract?

Smart contracts is a concept introduced in blockchain by the Ethereum network in 2014. We tend to get confused because of the name, they are not legal contracts at all but a set of programmable tasks or a piece of code that is deployed on a blockchain. These tasks are automatically executed each time that some conditions (that are written in the contract) are met. Once the contract is deployed on the blockchain it can’t change any more and is visible to all users of said blockchain.

With this awesome tool we can solve many different complex problems, starting with the transparent exchange between two parts without the need for a central authority, legal system, or external enforcement mechanism. Also, we have many different use cases, such as traceability of products, transparent charity, creation of new tokens, etc.

Benefits and disadvantages of smart contracts

  • Efficiency and accuracy: Digital and automated tasks bring up less probability of errors than manually filling documents.
  • Trust and transparency: There’s no third party involved, and all transactions are shared across participants. There’s no need to question whether the information has been altered for personal benefit.
  • Security: Records are encrypted and stored on the blockchain. This makes them very hard to hack and impossible to change.
  • Interruption-free: This means that once the execution started, it cannot be stopped or interrupted
  • Savings: Smart contracts remove the need for intermediaries to handle transactions and, by extension, their associated time delays and fees.

The most important disadvantages are:

  • Faulty Code: This means that if there is a bug in your smart contract it can result in a big waste of money. One can keep and save data in smart contracts safely and void of any distortions, only if the code is written perfectly and precisely. Humans can be tired or make clerical errors and thus the whole system is compromised. That’s why there are some standards like ERC20, that provide the security basics for your contract. Another solution to this problem are the DAO’s, but this is a topic for another blog.
  • Third party agents: The need for lawyers experienced in IT increases in the future because the programmers of smart contracts will need consultations before making new kinds of contracts.
  • Inmutable: You can’t change a smart contract once it is deployed. Later we will see how to solve this problem.

Currently, smart contracts are used for different types of use cases. Most of them are related to transparency needed activities. Some of these are:

  • Digital Identification
  • Data recording (Financial or any type)
  • Supply chain management
  • Insurance
  • Government
  • Financial services and security

Currently all the blockchains have their own way to develop smart contracts and interact with the network programmatically. The most used language is Solidity, this is specifically for ethereum networks, but in some cases you can develop in solidity for other networks also.

This is an example of smart contract that implements the simplest of a coin:

Note that the syntax is very related to object oriented programming. You start the contract with the reserved word contract and then write “attributes” and “methods” as it was a class. You can check this example at solidity official doc, to understand better. If you are interested in smart contracts development you can also check these fantastic resources:

  • https://docs.soliditylang.org/en/v0.5.8/index.html
  • https://cryptozombies.io/
  • https://www.dappuniversity.com/
  • https://ethereum.org/en/developers/docs/
  • https://remix.ethereum.org/

As i said before, once the contract is deployed on the blockchain it can’t change any more, and you should be asking yourself what if there is a problem, bug or security issue, or maybe you need an upgrade to add some new feature. Well, smart contracts can´t be changed but we don’t need to change them, for this purpose you can use a proxy contract, in order to maintain the logic implemented separated form the transaction entry point. This proxy contract forwards any transaction to the corresponding contract. So if you need to make a change to the logic, you simply deploy a new contract with the change, and point your proxy contract to the new one.

Read also blog post about blockchain loans!

You want to know more? Get in touch!
You need to confirm Privacy Policy before submitting.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.