Smart Contracts in Blockchain

Smart Contracts in Blockchain

4 mins read1.6K Views Comment
Updated on Jun 30, 2022 17:28 IST
Recommended online courses

Best-suited Blockchain courses for you

Learn Blockchain with these high-rated online courses

β‚Ή1.7 L
2 years
β‚Ή1.7 L
2 years
β‚Ή1.14 L
3 years
β‚Ή70 K
1 year
β‚Ή1.8 L
10 months
β‚Ή2.25 L
9 months
β‚Ή3.15 L
9 months
β‚Ή1.18 L
5 months

Introduction

A smart contract is not a new concept. However, a self-executing smart contract on the blockchain network is. The article below explains the working of smart contracts on the Ethereum network and the role of the Ethereum Virtual Machine. 

Let’s begin!

A Brief about Ethereum and EVM

Ethereum is a decentralized public blockchain and a cryptocurrency (ETH). The Ethereum network has multiple applications. One of them is Smart Contracts

example1

As we all know, the concept of blockchain technology allows for the addition of a new block in the network under consensus algorithms. The smart contracts are also added as a new block in the Ethereum network. Hence, they are irreversible, traceable, and cryptographically secured.

The smart contracts are executed on Ethereum Virtual Machine (EVM) by developers building decentralized applications (dApps). These are written in Solidity programming language. However, smart contracts in solidity can’t be executed by EVM directly. First, it converts solidity code into low-level machine language Opcodes. Then those opcodes convert into bytecode. Hence, the bytecode of the smart contract gets executed by EVM.

The execution process of the smart contract initiates the Gas amount. Ethereum Gas is a transaction fee charge for adding a new block to the network. The gas amount depends on the size of the contract and execution urgency. The longer you wait, the lesser will be the gas fees for you.

This additional amount uses to reward miners and strengthen the global financial blockchain system.

What are Smart Contracts?

In 1994, Nick Szabo (inventor of BitGold and a computer scientist) proposed the concept of Smart Contracts. He defined a smart contract as computerized transaction protocols that execute the rules defined in the contract. Years later, Vitalik Buterin (co-founder of Ethereum) reinstated the concept and created EVM to execute smart contracts.

A smart contract includes an automatically-executable program of the business logic or requirement mentioned. It follows if-then statements. If a particular condition is true, then do a specific operation. The smart contract programs are executed by Ethereum Virtual Machine (EVM). Once the program gets executed, the action will be taken automatically as defined in the contract.

Let’s take a simple example to understand the above.

For instance, what if there’s a smart contract established between customers and vendors on online shopping? 

  • On a prepaid order, the payment by the customer goes to an escrow account. 
  • The payment will not be transferred to the vendor until the customer gets their order.
  • Once the customer receives the order, the payment automatically transacts to the vendor.  
  • If the order does not deliver, the payment goes back to the customer after a specific number of days.
example2

Features of Smart contract:

  • Self-executable code
  • Deployed on Blockchain networks like Ethereum
  • Follows IF-THEN conditions for contract
  • Irreversible, can’t alter later
  • Traceable and Transparent
  • An Agreement between Buyer and Seller
  • Secure and Reliable

How does Smart Contract work?

Following are the steps to run an Ethereum smart contract:

  1. Contract deal between buyer (party A) and the seller (party B).
  2. A developer writes the smart contract in the solidity programming language.
  3. Solidity code (converted into) β†’ Opcodes (compiles into) β†’ Byte code
  4. Byte code (low-level machine language) saved by Ethereum Virtual Machine (EVM).
  5. Miners convert the smart contract into a new block to add to the Ethereum blockchain network.
  6. When the conditions meet, the contract automatically executes. Hence, payment release to the seller (party B).
  7. Verification of payment transaction.
example3

There are numerous applications of Smart Contracts, such as a Voting System, Insurance, crowdfunding, identity verification, supply chain, satellite communication, healthcare, etc.

Benefits of Smart contracts

Following are the advantages of Ethereum-based Smart Contracts: 

  • Smart contracts are automatically executable programs.
  • It removes the need for middle parties or intermediaries. Hence, it eliminates the risk of manipulation and cost-cutting.
  • No fear of data loss as the contract has multiple copies shared across the blockchain network.
  • Impressions of digital signing and cryptography ensure the safety and authenticity of the contract.
  • Saves time and effort in producing real business contracts.
  • Eliminate manual human errors while filling out forms.

Limitations of Smart contracts

Following are the disadvantages of Ethereum-based Smart Contracts: 

  • Once the smart contract code is deployed, it’s impossible to alter it.
  • There are possibilities of loopholes in the contract
  • Not a complete elimination of intermediaries as developers require them to establish rules for smart contact.
  • Not legally binded yet. No approval by any jurisdiction.

In Conclusion

In the above article, we went through the origin of Ethereum Smart Contracts and the use of Ethereum Virtual Machine (EVM). We covered the working of the Smart contract in detail. In addition, we saw the application and use cases of Smart Contracts. Furthermore, we have gone through the pros and cons of using Smart Contracts.

Hope you enjoyed reading the article. Do share the comment and queries in the link below.

Also, read: Blockchain Interview Questions

Recently completed any professional course/certification from the market? Tell us what liked or disliked in the course for more curated content.

Click here to submit its review with Shiksha Online.

FAQs

What is Ethereum?

Ethereum is a decentralized public blockchain network and a Cryptocurrency with multiple applications.

What is Ethereum Virtual Machine (EVM)?

EVM is a platform to execute smart contracts on the Ethereum blockchain network.

What are dApps?

Decentralized applications (dApps) are web or mobile applications for users on a blockchain network. It uses smart contracts to execute a set of operations.

About the Author

This is a collection of insightful articles from domain experts in the fields of Cloud Computing, DevOps, AWS, Data Science, Machine Learning, AI, and Natural Language Processing. The range of topics caters to upski... Read Full Bio