Crypto Currencies

What are smart contracts? How do they work? a personal reflection

Surely you have heard of smart contracts.

Curious, because it's another one of those terms that end up being known by name in English, instead of using Spanish, which would be 'Smart Contracts' or it could also be 'Elegant Contracts', although I think it's best to stick with the first option.

Are you new to cryptocurrencies?
Are you new to cryptocurrencies?
If you want to start investing in cryptocurrencies, we recommend that you start buy your first tokens on Coinbase. If you deposit 100 euros by registering on OUR LINK, you will earn an extra 10 euros!

Well, to what are smart contracts used for?

What makes them smart?

We all know what a contract is, but smart needs to have explanations.

I will try to explain why they are smart.

What are smart contracts?

Smart contracts are those contracts that allow all kinds of exchanges to be carried out without the need for an intermediary, i.e. an agent, broker or dealer.

That in itself is an impressive benefit, isn't it?

Here is another way to see what a smart contract is:

It would be a program that uses blockchain infrastructure and as a program it has a code and data and a specific address.

So we see that it is a work of programming. For those unfamiliar with the subject, this may sound "Chinese", the truth, but the important thing here is to get the general idea.

How do Smart Contracts work?

Throughout much of the web, this term is associated with the cryptocurrency Ethereum, which is supposed to facilitate the operation of these contracts.

From this point of view, Smart Contracts would come to work thanks to Ether, which would be like a kind of energy supply so that these contracts can be executed.

However, this does not mean that the use of these contracts is only possible in Ethereum, as other blockchain applications can also be used for this.

To see how any of these contracts work, it's best to see an example.

Example of smart contracts

Pedro wants to buy a car owned by Juan.

In the case 1, or in real life, Pedro and Juan could trade the car privately, without the help of dealers or dealerships. This would approximate what a smart contract would be. In this case, Pedro pays Juan and the latter gives him the keys. But here it is unclear what the Smart Contract is, because the contract we are talking about is processed virtually, in the blockchain.

In case 2 we would have that Juan leaves the car at a dealership and Pedro buys it from said agent, with which Juan must let the previous one earn a commission for the transaction, and with this generate the written contract that gives rise to the same .

Case 2 would be what Smart Contracts “want to eliminate”.

In the case 3, in the world of Blockchain, Pedro sends the money to the application that manages the contract, then Juan sends a kind of "code" necessary to drive the car, then the transaction takes place: one receives the car and the other the code to start the car.

But how to be sure that Pedro will have the real car?

Because it could happen that Juan leaves the code, yes, but he does not leave the car, something that the blockchain or the Smart Contract could not easily verify.

You see?

In trying to give an example, we may find technical difficulties.

What does this tell me?

That the Smart Contracts model, from the outset, works much better for the virtual world, where the transaction can be verified automatically by exchanging “money” for a “token”, regardless of whether that token is a digital asset of any kind. In other words, when the token is given and the contract is executed, the token, i.e. the digital property, passes into the hands of the buyer.

What advantage does this have over the real example of John and Peter?

Well, this shows us that this is a perfect working model for a virtual economy, which has no limits or borders, and which allows citizens from anywhere in the world to buy and to sell tokens without the need for agents.

Therefore, if Juan is in Mexico and Pedro is in Spain, the two can exchange this digital property securely, transparently and efficiently through a smart contract.

Perfect.

However, there are doubts that arise, and for this we are going to see the example given in many powerful pages of the network, such as Ethereum.org itself, where they tell us about the example of the “vending machine” as best to explain how these smart contracts work.

On page Ethereum, they give us this example of what the code for this vending machine would look like, which would become a smart contract:

pragma solidity 0.6.11;

VendingMachine contract {

// Declare the state variables of the
address of the owner public contract;
mapping(address => uint) public cupcakeBalances;

// When the 'VendingMachine' contract is deployed:
// 1. set the deploy address as contract owner
// 2. set the cupcake balance of the deployed smart contract to 100
constructor() public {
owner = msg. sender;
cupcakeSales[address(this)] = 100;
}

// Allow owner to increase smart contract cupcake balance function
refill(uint amount) public {
require(msg.sender == owner, “Only owner can reload.”);
cupcakeBalances[address(this)] += amount;
}

// Allow anyone to buy cupcakes
function buy(uint amount) public payable {
require(msg.value >= amount * 1 ether, “You must pay at least 1 ETH per cupcake”);
require(cupcakeBalances[address(this)] >= amount, “Not enough cupcakes in stock to complete this purchase”);
cupcakeBalances[address(this)] -= amount;
cupcakeBalances[msg.sender] += amount;
}
}

Origin of smart contracts

To continue talking about this "vending machine" problem, what better way than to go back to the initial history of this concept.

The idea came from Nick Szabo, who in 1994 had the idea that a decentralized system was the best thing to use to be able to execute smart contracts or self-executing contracts by computer code.

In 1997 he wrote an article titled “the idea of ​​smart contracts”. He talked about the example of the “vending machine”.

How is the vending machine metaphor?

Basically, this metaphor tells us that the machine would be the "accounting book" or Smart Contract, and that an individual A could obtain a service B (for example, a bar of chocolate), simply by putting money in the machine. This way, the smart contract would be executed with the shipment of the item.

This way, in theory, there would be no need for this intermediary agent so necessary until today for most transactions in the physical or real world.

The machine would take care of eliminating the “man in the middle”.

But is it true?

In theory yes, but at the start a question arises.

The vending machine has an owner.

Who owns the smart contract?

This brings us to other questions like Who owns the Ethereum ecosystem?

Many will say that these items have no owner; which belong to everyone and no one at the same time.

However, doubt continues to assail me, because immediately I see that the example of the "vending machine" has this defect. This machine has an owner, that is, the company that owns these machines. He thinks that it is not necessarily a company but that it can also be the State.

This leads me to wonder about the security of these contracts.

Are Smart Contracts safe?

In theory yes, they are supposed to be crafted in such a way that they cannot be broken without all participants in the system noticing.

However, in practice the matter is not so simple.

Well known are the episodes of hacks in the past in which there were weaknesses in the system par excellence of the smart contract: Ethereum. For example, the episode of July 2017, where a significant amount of Ethereum was stolen. There are more hacks if we start looking.

Then, if we read several interesting sources on the subject, such as a article brutal from Blockgeeks, where in one of its sections it says something like this:

The votes protected by Libros would have to be decrypted and this would require enormous computing power. Nobody has that much ability, so God would have to hack the system.

Well, This statement drops two things:

  • It is very difficult to hack a well-designed smart contract
  • With enough skill, you can hack

In other words, even if they overdo it (with “God”), they recognize that the system can fail.

Also, if we start to investigate, we will see a lot of "literature" about the need to create contracts following specific security models, which also shows that before these models there were many problems of interference and flight.

Each cryptocurrency used for this type of contract has a different set of recommendations, be it Ethereum, NEO or EOS.

What to do to avoid security issues?

There are a few steps to follow, such as:

  • Follow the recommendations of the communities of each cryptocurrency
  • Perform comprehensive testing before the contract goes to market
  • Apply continuous audits to find bugs and errors

Unfortunately, the very technological nature of these Smart Contracts will make it impossible to secure them 100%.

Attention, I am not saying that they will not be implemented or that they are very insecure, but that they can never be implemented safely.

This is a fact that we must take into account.

Then all that remains is to create these contracts with the best security practices and develop a monitoring system to prevent possible attacks.

There is therefore still quite a long way to go here, which is normal given that we are in the “infancy” of this world of virtual contracts.

The future of smart contracts

Seeing how the panorama is in the world, I think it seems that this type of contract will rise like foam in the years to come. He already does, in fact.

The strong rise of cryptocurrencies, with Bitcoin and Ethereum in the lead, gives us the necessary clue to understand that the adoption of virtual realities is already a fact, and more importantly, that this adoption seems to be trending exponentially.

At the rate we are going, I don't think it will take long for us to get to a virtual economy in which physical money has disappeared and the main economic activity has shifted almost entirely to the virtual world.

This is where the concept of Smart Contract will take precedence over most economic activities.

However, this has causes and consequences.

The causes of this adoption stem from the global push towards a more virtual and sustainable (supposedly) economy given the urgency posed by climate change and the pandemic. This adoption could not be so easily explained without this massive push being led by world governments.

This is crucial to understand.

What i mean is that the adoption of this type of contract is accelerated due to massive state interventionism, an interventionism that monopolizes more and more branches of the economy and society that we have known so far.

As I said in the first part of the article, these contracts are particularly effective for a virtual reality, but not necessarily as effective for a physical reality; at least not with the controlling government paradigm that we have today.

I mean, the idea is great.

With a smart contract I can buy a house without the need for a lawyer, a notary or even a banker, but this cannot be in a reality where the state controls this process as much as possible and forces the individuals to contract these services.

In this sense, the most important thing is state regulation, and I think it is easy to understand that it controls real or physical activity. You cannot escape it, neither with a smart contract nor without it.

What the smart contract has is an innate facility to facilitate virtual transactions. The only thing that will interest the State here is that you declare your income. If you made X money selling tokens and put them into the real economy, the state wants its share of that money.

Let's remember what the old contracts looked like:

  • word first
  • Then came the acts of private lawyers
  • Third parties with notaries and property registers

These types of contracts have an obvious disadvantage in a virtual world where there are no borders.

That, and the fact that states will increasingly control the physical economy, will push activity into the virtual world, and that's where Smart Contracts will take over the leadership of this world, in theory, decentralized.

However, this question keeps popping up in my head:

Who owns the bender?

Similar items

Leave your comment

Your email address will not be published. Required fields are marked with *

Button back to top