What is Smart Contract and how does it work?
Smart contracts are little computer programs that are stored in Ethereum blockchain and can be activated by funding them with some ether (ETH), the Ethereum’s native token. A smart contract contains rules and regulations between a buyer and a seller. It can facilitate the exchange of documents, company shares, money, property, and almost anything of value. Its main goal is to digitally oversee, verify, enforce, or sign an agreement.
Unlike a normal contract that requires the presence of banks, governments, brokers, agent, or lawyers, a smart contract is self-executing. It can automatically verify a contract and then executes the agreed upon terms without a third party or middlemen.
While bitcoin blockchain can also carry out smart contracts, its programming language is very complex and too restrictive to develop anything. Ethereum blockchain, on the other hand, is very friendly for developers as it can run any program regardless of the programming language.
How does it work
1. Creation of Terms - The agreement between a buyer and a seller are directly converted into lines of code. All the transactions or contracts that happened and will happen are automatically recorded in Ethereum Blockchain. Every contract has its own blockchain address. Once a smart contract is broadcasted into the Ethereum Blockchain, anyone can interact with it through that address.
2. Triggering Events - A required event with an expiration date is needed to be fulfilled for the contract to execute itself based on the coded terms. The code pertains to the “series of instructions”, written using the programming language “solidity”, which works on the basis of IF-THIS-THEN-THAT logic. This means that, if the first set of instructions are accomplished, then the required function will happen, and so on until you reach the end of the contract.
3. Closing the Agreement - Once the smart contract is created, both buyer and seller need to trigger the set of events required to their side. If no action is created by one side of the party before the agreed date, blockchain will release a refund to the other party.