The term Smart Contract was coined by Nick Szabo in 1997, long before Bitcoin was created. He referred to the term as a distributed ledger to store contracts. Smarts Contracts are the contracts or the computer programs stored inside the blockchain. Smart Contracts are programmed in the blockchain networks like Bitcoin, Ethereum and Neo.
How does Smart Contract work?
Just like a contract in the real world that states the terms between the two parties and negotiates the deal, Smart Contracts are computer programs that stores the rules for negotiation and terms of agreements, verifies the fulfilment automatically, and executes the agreed terms. Smarts eliminates the dependency on third party while establishing a business relation, the parties reaching an agreement can transact directly with each other. Smarts Contracts can replace any third party mediator.
Let suppose, Mr. A is travelling to France country and want to rent an apartment there. Mr. B has an apartment in France and want to rent has apartment. AirBnB works as a third part to negotiate the deal between A and B and charges fees for its service. Lets suppose Mr. A sends funds to AirBnB which deducts its fee and pays to Mr.B. In case the both party are not happy, the settlement takes a long time. However, if the agreement was executed over Smart Contracts, agreement will work according to the stated terms and will execute only when the terms are fulfilled.
The Smart Contract works by creating a storage where the both parties put values, which cannot withdrawn easily. Mr. A sends the rent and Mr. B sends the address of the apartment. Mr. B confirms payment and Mr. A receives the code for apartment. When Mr A goes to France and if the apartment is just as described, Mr. B receives the payment. If the apartment is not as descried, Mr. A gets the refund. If Mr. A never travels to France, Mr. B gets the liquidity damages and remaining funds go back to Mr. A. Then finally, the smart contract is considered fulfilled and stored on the blockchain.
Once Mr. B generates a contract to rent an apartment that automatically and transparently works, he might also consider creating a universal agreement for future renters that they do not have to generate contracts while renting an apartment for new guests. With this universal contract, anyone on the blockchain can rent the apartment by following the algorithm.
The smart contract created by Mr. B can be programmed even better so that anyone willing to rennet his apartment can use the same contract tht was originally created by Mr. B for Mr. A. The contracts can include automatically adjusted payment, discounts, partial payment, and all other options.
Where can you use Smart Contracts? How to use Smart Contracts?
The classic example explained above is just one implication of Smart Contracts. Smart Contracts can be applied to many different things, such as crowd funding, banks (automatic loan repayment), insurance companies (process claims), postal companies (payment on the delivery), etc.
There are some blockchains that support Smart Contracts, the most popular, and of course, the biggest one, is Ethereum. Ethereum was specifically designed to support Smart Contracts. Bitcoin also supports Smart Contracts but it is limited compared to Ethereum. Smart Contracts are programmed in a programming language called Solidity, which was created for Ethereum.
Why should you trust a Smart Contract?
Smarts Contracts are designed and implemented within the blockchain. Therefore, they inherit some blockchain properties like being immutable and distributable. Immutable means once the Smart Contracts are created, they cannot be changed. In other words, no one can tamper with the code of the contract. Distributable means out of the contract is validated by everyone on the network, which means a single person cannot force the contract to release the funds.