Leggi questo articolo in Italiano Italiano

What is a smart contract in blockchain?

By Luca Boiardi

Smart contracts are algorithms operating on blockchain. Thanks to them, it is possible to give rise to numerous applications and platforms: let's find out about them!

What is a smart contract in blockchain?

How a smart contract works

The idea of smart contracts was born together with Ethereum, the first blockchain aimed precisely at the development and execution of DApps (decentralized applications). We talked about it in depth in the article dedicated to Ethereum: check it out to learn more.

The concept on which smart contracts are based is to enable automated and programmable management of value, the backbone on which all disintermediated and decentralized financial services are built.

Let’s explore and clarify how it works in this in-depth discussion.

What are Ethereum smart contracts?

The first smart contracts were extremely simple and were limited to basic functions. Over time, people then began to combine them together and make them interact so that so-called DApps (decentralized applications, of which DeFi is an example) could be built.

One of the first functions performed by ethereum smart contracts involved crowdfunding and tokenization: the issuance of new tokens in exchange for a contribution, better known as ICO.
This allowed anyone to participate in fundraising for new crypto projects, while also becoming their “shareholders” (I put this in quotes because the tokens issued often gave no direct benefits, only utility on the platform of the project in question).

To achieve the goal, two blockchain smart contracts were needed : one to create the token and another to disburse it to contributors.

The smart contract to create the token contained its basic economic data such as supply (quantity of existing tokens), symbol (ticker) and name.
The crowdfunding one, on the other hand, governed its rules: the exchange rate, how many tokens need to be distributed at most, how much is the minimum below which the sale is cancelled in case of failure, and more.

Great care must be taken when creating a contract, as once it is uploaded to the blockchain it can no longer be modified (the only way is to create another one).

Simple as they were, these early Ethereum smart contract experiments laid the foundation for most of the projects that currently exist, based on the so-called ERC-20 tokens, the standard introduced by Ethereum.

Now that the elementary concepts are clear, we can move on.

"The token standard introduced by Ethereum is named ERC-20"

Smart contract and dApps

The next step was to combine several contracts with each other so as to create more complex logic. Thus was born the concept of DApps.

As the Ethereum ecosystem grew, people began to think about the first decentralized financial services platforms (the so-called DeFi). They could not be developed with only one smart contract behind them, whose functionality would have been too limited.
Therefore, different logics were thought of, achieved by combining several of them together, optimizing their execution and enabling previously unthinkable operations such as lending, cash management and collateralization.

Let us take as an example a “trivial” lending platform, such as AAVE may be. Its purpose is to connect those who have “parked” crypto liquidity to lend and those who need it and are willing to pay interest to borrow it, while also depositing collateral in the form of crypto as security.

The platform will need to know the real-time price of the coins it handles, know the collateralization rate of the loans, handle any liquidations, and change the interest rates in order to always incentivize the use of the platform. Good work. For each of these functions there is a contract that not only performs it but also communicates with others to coordinate.

Obviously, the user neither notices nor is aware of all this: the purpose is to make life easy for him and to bring as many people as possible closer to the services of decentralized finance.

Therefore, the individual will interact with a web page that, in turn, will talk to Metamask (or other crypto wallet), an interface that allows the browser to communicate with the Ethereum blockchain.

With clicks and keystrokes, the user will initialize the requested transactions, which will be forwarded to the smart contracts and executed.

The user will then get feedback on what he or she has just executed. Staying with the lending example, he will know how much liquidity he has deposited, how much he is earning, etc.

Be careful, however, because we are not limited to the world of finance: smart contracts allow NFTs marketplaces such as OpenSea to exist, for example .

"The DApp concept, the heart of DeFi, comes from the combination of several smart contracts"

How do smart contracts eliminate intermediation

Smart contracts are algorithms that run on blockchain. They are programmed to perform a wide variety of functions, designed to work without any human intervention.

Therefore, a smart contract, or an application formed by a plurality, moves autonomously and eliminates any kind of intermediary, precisely because there is no need for humans in this procedure.

How do you develop a smart contract?

Creating a smart contract requires in-depth programming skills, which are essential to succeed in the venture.

In any case, there are guided tutorials available on the Web that enable the creation of simple smart contracts, which are very interesting for anyone curious about this technology.

Smart Contract, DApp and Security

As the complexity of DApps increases, so does the risk of bugs and unwanted behavior.

Ethereum smart contracts are written in Solidity, a language called Turing Complete. Translated: it can be programmed to do almost anything.

As a result, it becomes difficult to formalize its security and ensure that the DApp will not have any errors or vehicles that can be used maliciously to harm users.

Thus auditors are born, whose job is to examine the code and find any flaws.
As for what was said just now, not even one audit guarantees complete security on a smart contract, which is why more than one is often done. As in anything, you are never totally safe from the unexpected.

More than the number of audits received, the security of a DApp depends on its history and longevity. Indeed, if it manages high capital and has been doing so for a long time without ever having been hacked, it is much more likely to be secure. However, we reiterate with certainty that zero risk, at least for now, does not exist.

Let us also not forget the importance of privacy and security from malware and other network threats. On this, Nord VPN can come to our rescue.

Final considerations

To conclude, we can say that a smart contract is an algorithm executed on blockchain that receives specific inputs, processes them according to the rules it contains, and eventually returns outputs.
Compared to a classic computer program, the differences are obvious:

  • What technology are smart contracts based on? It is the blockchain that is the protagonist, as well as the most notable diversity from traditional software.
  • The first is that the inputs and outputs of a smart contract are financial transactions on blockchain containing data and cryptocurrency.
  • In addition, execution is decentralized: there is no central server on which the program runs, but it is distributed over a multitude of nodes.
  • Finally, Ethereum has a programming language created specifically for smart contract development, called Solidity.

Anyone can write a contract and upload it to the Ethereum blockchain. Once done, it can no longer be modified or deleted, and will forever execute the commands programmed into it, or at least as long as it receives the necessary interactions as input.

Smart contracts have enabled everything we now know as DeFi, one of the biggest innovations not only in the cryptocurrency industry, but undoubtedly also in technology and finance.


X

Vuoi essere sempre sul pezzo?

Iscriviti alla newsletter per ricevere approfondimenti esclusivi e analisi ogni settimana.

Se ti iscrivi c’è un regalo per te!

bitcoin
Bitcoin (BTC) $ 69,763.69
ethereum
Ethereum (ETH) $ 2,435.70
tether
Tether (USDT) $ 0.999965
bnb
BNB (BNB) $ 566.61
solana
Solana (SOL) $ 167.21
usd-coin
USDC (USDC) $ 0.999982
xrp
XRP (XRP) $ 0.515039
dogecoin
Dogecoin (DOGE) $ 0.172175
staked-ether
Lido Staked Ether (STETH) $ 2,434.59
tron
TRON (TRX) $ 0.160415
the-open-network
Toncoin (TON) $ 4.71
cardano
Cardano (ADA) $ 0.334805
shiba-inu
Shiba Inu (SHIB) $ 0.000018
wrapped-steth
Wrapped stETH (WSTETH) $ 2,878.73
wrapped-bitcoin
Wrapped Bitcoin (WBTC) $ 69,574.64
avalanche-2
Avalanche (AVAX) $ 24.09
weth
WETH (WETH) $ 2,434.58
chainlink
Chainlink (LINK) $ 10.88
bitcoin-cash
Bitcoin Cash (BCH) $ 344.36
sui
Sui (SUI) $ 2.01
leo-token
LEO Token (LEO) $ 6.04
usds
USDS (USDS) $ 0.992830
polkadot
Polkadot (DOT) $ 3.87
litecoin
Litecoin (LTC) $ 66.08
near
NEAR Protocol (NEAR) $ 3.83
aptos
Aptos (APT) $ 8.51
wrapped-eeth
Wrapped eETH (WEETH) $ 2,561.41
uniswap
Uniswap (UNI) $ 7.19
pepe
Pepe (PEPE) $ 0.000009
internet-computer
Internet Computer (ICP) $ 7.38
bittensor
Bittensor (TAO) $ 457.17
dai
Dai (DAI) $ 1.00
fetch-ai
Artificial Superintelligence Alliance (FET) $ 1.25
monero
Monero (XMR) $ 158.49
kaspa
Kaspa (KAS) $ 0.111965
ethena-usde
Ethena USDe (USDE) $ 1.00
stellar
Stellar (XLM) $ 0.093675
whitebit
WhiteBIT Coin (WBT) $ 19.08
ethereum-classic
Ethereum Classic (ETC) $ 18.26
first-digital-usd
First Digital USD (FDUSD) $ 1.00
polygon-ecosystem-token
POL (ex-MATIC) (POL) $ 0.304639
blockstack
Stacks (STX) $ 1.53
okb
OKB (OKB) $ 38.06
dogwifcoin
dogwifhat (WIF) $ 2.10
aave
Aave (AAVE) $ 136.17
filecoin
Filecoin (FIL) $ 3.40
arbitrum
Arbitrum (ARB) $ 0.492079
crypto-com-chain
Cronos (CRO) $ 0.072305
mantle
Mantle (MNT) $ 0.564623
immutable-x
Immutable (IMX) $ 1.09