Smart Contract

In the world of blockchain, there are two major players – Bitcoin and Ethereum. While the world’s first decentralized currency bitcoin was invented to uproot the monopoly of banking institutions, Ethereum explored blockchain for a different goal.

Ethereum project envisioned smart contract, and its capabilities to further the cause of decentralization sparked by the Bitcoin project.

A smart contract is nothing more than a computer program. It’s worth noting that there is no legal meaning behind the word “contract”. What makes this program smart is the fact that it is self-executing and that it can handle monetary transactions without human intervention.

Smart contract lives as a block on the blockchain. This means it can not be modified post-deployment. Re deploying the edited version to the blockchain is the only option to modify a smart contract. EVM, short for Ethereum Virtual Machine runs the smart contract, which executes it on every node of Ethereum blockchain.

Smart contracts can be written in several high-level languages, Solidity is the most popular. Then this code gets compiled to low level-level bytecode. This bytecode runs on EVM. After compilation, a smart contract gets deployed on Ethereum blockchain as a ‘contract creation’ transaction.

Contract creation transaction is basically sending the smart contract to contract creation address – 0x0, which returns the contract address. Every smart contract is identified by an address in the Ethereum ecosystem. Contract address can be used to send funds to a smart contract. Unlike externally owned accounts (EOAs), there is no private key exists for contract accounts.

A contract can call another contract, but its initially called by an EOA. This means a contract stays inactive until it is called by an EOA. This is how contract executes for the very first time. Once called, it can call a chain of contracts.

Instructions in smart contract consume gas. A gas, in the context of Ethereum, is defined as the measure of the amount of computational effort required to execute certain operations. This gas is essentially ETH and is used to pay miners who support the network by mining new block(s) for the transaction.

While submitting a transaction to the network, some predefined limit of gas is passed as a parameter. If all the gas is utilized during the execution, the program will halt, and any leftover gas is refunded. Having gas amount associated with operations also ensures that the program will not run forever.

Leave a Comment

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