A Smart Contract is a program, it runs on the Ethereum blockchain 2.0. It has a predefined set of rules and agreements between two persons or entities. Moreover, it always runs when predefined conditions and a set of rules are met. However, it is not controlled by a single user, instead, it is deployed on a blockchain network and executed as software or program. Each user in a network first interacts with the contract and then they will be able to perform transactions if and only when they meet the conditions.
How Do Ethereum Smart Contracts Work
In the Ethereum network, all the transactions are done by using a smart contract, without smart contract deployment, you cannot perform even a single transaction in the Ethereum network. It is a piece of code and set of instructions that automatically executes and verified the transaction if and only when it meets the conditions. It works in the following flow:
- Pre-defined contract
- Chain of events
- Value Transfer
- Settlement Agreement
Here I’m going to describe the step-by-step working of the smart contract.
1: Smart Contract Deployment
If you are new to the Ethereum blockchain network, the very first step you have to perform is smart contract deployment. It is a set of instructions or pieces of code you have to install on your specific node, it is always stored in the distributed ledger on the blockchain.
The purpose to install this piece of code is to give you equal rights to transfer the transactions in the decentralized network.
For instance, Tom wants to send a transaction to Alice by using the blockchain network. To be a part of the blockchain network he has to install smart contracts on his entire machine. After that, he would be able to perform the transaction.
2: Chain of Events
If you perform an event that is specified in the condition, then the event will be executed otherwise it would be discarded. For instance, if you initiate a transaction firstly it would be broadcast to each node, and every node verifies the transaction after verification it would be performed.
3: Value Transfer
After execution, the terms and conditions of the contract would automatically transfer value (asset: ETH: Mainnet, Arbitrum, Optimism, AVAX/MATIC/BNB) to the relevant entities. It is also called internal transactions.
4: Settlement Agreement
After a successful transaction without any dispute or fraud, it would be updated in the distributed ledger on the blockchain network.
Smart contracts run on the Ethereum blockchain, which is a piece of code or set of instructions that must be installed on each node in a decentralized network. It is the set of rules or agreements through which the transactions would be verified and done over the blockchain network. After a successful transaction, it would be updated on the distributed ledger.