DEV Community

Cover image for Building a Smart Contract
Drayfocus
Drayfocus

Posted on • Originally published at drayfocus.hashnode.dev

Building a Smart Contract

There is a problem with how two entities, businesses or individuals, exchange value on the internet. This problem stems from the bureaucratic processes involved in validating and verifying the authenticity of each party and also how they abide by the rules of engagement. People have sort for the help of institutions to help with the validation/verification processes. For example, we seek the help of banks to keep records and settle disputes in case one arises. Over time, we have been seeking better ways of transacting value across the internet in a way that takes less time and is also authentic. Smart Contracts are one of the major innovations to establish trust between people and businesses.

What is a smart contract?

A smart contract is the trust layer in a blockchain application. It enables verification and validation of transactions of digital assets. A smart contract is an automated electronic trust enabler that aims to replace human intermediaries when exchanging value across the internet. It is a block of code that defines and enforces the rules and principles that guide transactions in a blockchain system. Let's take a look at a use-case scenario to fully understand how a smart contract works.

Usecase scenario

A logistics system consortium - an association of two or more logistics companies with the objective of participating in a common activity or pooling their resources for achieving a common goal. Here, their common goal is to give their customers the best experience by reducing their delivery time. They plan to do this by sharing excess delivery orders with other logistics companies within the system. They also want to achieve this without sharing their data or depending on an intermediary organization to enforce their agreements. Here's why they need a smart contract.

UseCase.jpg

The users of our smart contract are the logistic companies. The smart contract would be deployed into a blockchain network. Each of these logistic companies will join the blockchain network as a node to access and use the smart contract.

Each of these logistic companies can do the following once they become part of the blockchain network:

  • *Register * on the smart contract and become a member of the consortium.
  • In the condition of excess orders, a company requests for open deliveries from other members of the consortium.
  • Companies in the system would respond to open delivery requests

  • Companies can Unregister from the smart contract and leave the consortium

The transactions within this blockchain network can be either requests or responses to open deliveries, alongside price of each delivery. The price can be in cryptocurrency such as ether or an escrow payment id (Escrow is the use of a third party, which holds an asset or funds before they are transferred from one party to another).

All these transactions are carried out with the trust enabled by the smart contract in the blockchain network. The payment settlement is also executed by the smart contract in form of cryptocurrencies or escrow, once the delivery has been executed.

It is important to follow these steps before building a smart contract. Know the users and how they want to use it because once the smart contract is deployed, it is immutable (can not be changed). Therefore, it is safer to carefully plan the smart contract before developing, testing, and deploying.

Conclusion

I hope you now understand what a smart contract is and how to approach building one. In my next article, we will build, test, and deploy this Logistics system consortium using solidity and remix (Ethereum IDE).

You can connect to me on Twitter @drayfocus , and Linkedin Akinola Ayomide

Cheers!

Top comments (0)