Saltar al contenido principal
Buscar Buscador
Salir

Encuentra lo que estás buscando

Smart Contracts

Smart contracts are computer programs that run automatically on a blockchain when certain predefined conditions are met. This enables the creation of decentralized (dApps) and centralized applications that can perform transactions and agreements in an automated manner.

Smart contracts have been one of the most important developments in the blockchain industry in recent years. 

Although originally created for Ethereum, smart contracts have quickly become a valuable tool for many blockchains.

For example, they can be used to automatically trigger an electronic payment once a certain determinable event, which has been previously programmed, has occurred. This facilitates execution.


How does a smart contract work?

Smart contracts can operate autonomously thanks to the network on which they are deployed, and transaction security is guaranteed by blockchain technology. All that is required is to indicate to the computer program what the expected outcome is and what event will trigger that outcome. It would be something like this: If X, then Y.

The established rules and steps to be executed must be known and accepted before deploying the program because, once this occurs, it will be impossible to change the rules that have been programmed. This is because each line of code is recorded in the blockchain and is therefore immutable. 

An illustrative example of what an irrevocable transaction would be is vending machines. These only dispense products when the correct amount of money is inserted and the corresponding button is pressed. Both the items sold and the money received are stored inside the machine, which protects them from “external attacks.”


Advantages of smart contracts

One of the main advantages is that smart contracts offer security to the parties in terms of automatic compliance with what was programmed.

This same automatic nature also eliminates any possible human error (beyond possible coding errors), while promoting the creation of smart contracts that are, in practice, almost immutable. Being automatic, costs and problems are reduced, also facilitating the process of executing them.

Smart contracts also allow the creation of new tokens within a network, such as the aforementioned tokens that follow the ERC-20 standard, or NFTs, which follow the ERC-721 standard. These tokens are created from an issuance smart contract that follows these standards and are deployed on the Ethereum network or others that allow it, so that it is possible to keep a sub-account of the transactions carried out with these tokens in the Ethereum ledger, with their own unit of account. All this is done without mixing the balances of ether or other tokens with those of the token in question, and guaranteeing the transparency, traceability, and security provided by the Ethereum network.

Problems of smart contractsHowever, smart contracts are also vulnerable to certain risks or legal issues.

  • One of these problems would be the loss of control over the results, a direct consequence of the automatable and programmable nature of smart contracts. As soon as the events that trigger the smart contract occur, the code will make the changes immediately. The problem is that, by its very nature, it is not possible to adjust the results of the smart contract to the context or circumstances surrounding its execution, so it is not possible to anticipate unforeseen events.

  • They can also give rise to operational risks. For example, if the code is incorrect, it can cause a very difficult problem to solve, since all operations are linked and integrated into the blockchain and are executed automatically. Thus, erroneous code may not accurately reflect your intention and result in operational risk. 

  • Furthermore, much of the results of a smart contract depend on external information (crypto asset quotes, asset prices, etc.), which means that execution can be vulnerable to erroneous information, calling into question its autonomy and self-sufficiency. In addition, updating smart contracts can be complicated due to their immutability. The sources of information used to integrate external data into a blockchain (for example, the price of a particular stock) are called oracles.

Smart Contracts and the Ethereum Virtual Machine

The relationship between smart contracts and the Ethereum Virtual Machine (EVM) is close and fundamental. The EVM is software that runs on every node in the Ethereum network, providing a basic operating system that allows smart contracts to be executed. 

In other words, smart contracts are programmed in a programming language compatible with these virtual machines, such as Solidity, and then loaded into the EVM, where they are executed.

The EVM is a Turing-complete virtual machine, which means it can execute any type of computer program, as long as it complies with the consensus rules of the Ethereum network. The EVM is also responsible for maintaining the record of the states of smart contracts and updating them after each transaction.

Smart contracts and the EVM are the key to programmability on Ethereum and have enabled the creation of a large number of decentralized applications (dApps) on its blockchain.