Smart Contracts

What are contracts ?

What is a Smart Contract ?

Smart Contract Platforms

Sample Smart Contract code

Smart Contract use case

A contract is a legally binding document between at least two parties that defines and governs the rights and duties of the parties to an agreement. 

The concept of contracts is so prevalent today, that virtually everything we do is contract-driven, as contracts really are a set of conditions that two or more parties have committed to fulfilling in order to get some benefits to accrue to them. The generalized notion of contracts was invented by Columbus Langdell in 1871, which was brilliantly reformulated by Oliver Wendell Holmes, so we can see that the use of contracts to guide the behaviour of people in a transaction isn’t a concept that was just birthed yesterday. 

In more recent times, as the world becomes more technology-driven, the use of blockchain technology is helping us redefine and automate the contract process via the use of smart contracts. The concept of smart contracts was birthed by Nicholas Szabo, a computer scientist, legal scholar and cryptographer, who in 1994 realized that the distributed ledger could be used for smart contracts. This way, contracts could be converted into computer codes that are self-executing, cutting out the need for a middle man and could be replicated and supervised by the network of computers on the blockchain.

What is a Smart Contract?

A smart contract is a computer code that implements a contract or sets of contracts. All or part of the digital contract is executed based on the condition that is triggered in the blockchain embedded code.

Smart Contract Platforms

  1. Ethereum is the first smart contract platform in the world, and so far the most preferred by developers. It employs the use of a special-purpose programming language called solidity. The platform went live in 2015 by Vitalik Buterin
  1. Polkadot: Polkadot was invented in 2016 by Gavin Wood. It has several smart contracts projects deployed on its platform such as  Acala, Patract and Moonbeam 
  1. Solana: Solana is a high-performance blockchain supporting builders around the world creating crypto apps that scale today. It was created in 2017 by Anatoly Yakovenko. Some smart contract projects deployed on the network are Blaize and  Fantom,

Sample Smart contract code

A smart contract, like a vending machine, has logic programmed into it. Here’s a simple example of how this vending machine might look like as a smart contract:

pragma solidity 0.6.11;

contract VendingMachine {

    // Declare state variables of the contract

    address public owner;

    mapping (address => uint) public cupcakeBalances;

    // When ‘VendingMachine’ contract is deployed:

    // 1. set the deploying address as the owner of the contract

    // 2. set the deployed smart contract’s cupcake balance to 100

    constructor() public {

        owner = msg.sender;

        cupcakeBalances[address(this)] = 100;

    }

    // Allow the owner to increase the smart contract’s cupcake balance

    function refill(uint amount) public {

        require(msg.sender == owner, “Only the owner can refill.”);

        cupcakeBalances[address(this)] += amount;

    }

    // Allow anyone to purchase cupcakes

    function purchase(uint amount) public payable {

        require(msg.value >= amount * 1 ether, “You must pay at least 1 ETH per cupcake”);

        require(cupcakeBalances[address(this)] >= amount, “Not enough cupcakes in stock to complete this purchase”);

        cupcakeBalances[address(this)] -= amount;

        cupcakeBalances[msg.sender] += amount;

    }

}

 source: https://ethereum.org/en/developers/docs/smart-contracts/

Smart Contract use case

  1. Banking and FInancial services: The field of banking is one filled with a lot of contracts, and the deployment of smart contracts here can greatly enable automatic payments, stock splits, dividends, liability management
  1. Trade Finance: Smart contracts can greatly enable cross border payments and international trade.
  1. Insurance: Smart contracts can help automate claims and resolve disputes with proof.
  1. Digital Identity: Smart contracts enable individual identity in digital assets and it makes KYC process frictionless.
  1. Supply Chain Management: Smart contracts automate supply chain with visibility and transparency which leads to reduced frauds.

1 Comment

  • Deboskey

    July 29, 2021 - 7:55 pm

    There’s a lot learnt every day… Amazing

Leave A Comment