Do not miss this blog post if you are a smart contract and application developer, architect, or administrator.
Blockchain is a distributed ledger that allows collective guarantees on operations, transactions, and storage of data by a set of distinct entities rather than a single party. The transactions added to the ledger are immutable and verified by the nodes from various entities that are part of the network.
What are Smart Contracts in blockchain?
Smart contracts are automated agents that reside on the blockchain. They usually contain functions and data structures that ensure that transactions added to the blockchain ledger fulfil certain predefined conditions. In a typical business collaboration scenario, smart contracts can automate workflows by automatically initiating the following steps whenever some predefined conditions occur. This quality significantly reduces the time associated with business collaboration and agreement processes by eliminating the involvement of third-party intermediaries.
Smart Contract – Developer perspective
From the development perspective, smart contracts and the ledger form the main components of the blockchain system. The blockchain ledger contains the historical and current state of business objects, while smart contracts define the executable logic that generates or updates the things in the ledger.
Smart contracts read and write new transactions into the blockchain ledger by updating (i.e., put, delete) the blockchain’s world state and querying the history of transaction records from the immutable ledger. The blockchain’s world state is a database that holds the current value of a set of ledger states, making it programmatically easy to get their current value at any time. Smart contracts read, create, and update the state of a business object in the blockchain by executing the following operations on the blockchain’s world state:
- Read state gets information about the current state of a business object.
- Write state creates a new business object or updates the state of existing business objects with track changes.
How TIC BaaS Simplifies Smart Contract Development?
The relationship system of the TIC’s BaaS offers out‐of‐the‐box smart contracts and SDKs for rapid distributed application (DApp) development and integration. The relationship system has a set of core smart contract SDKs providing several services. The TIC BaaS provides a generic asset management smart contract SDK that offers core and flexible asset management functionalities adaptable to different scenarios.
The offered smart contracts address the basic functionalities of asset management, helpful in reducing the DApp smart contract development time. The developers use this SDK to set up an initial smart contract development environment and scaffold their business use case functionalities. The core embedded functionalities include:
- Create agnostic data assets and accept different asset types catering to different use case scenarios.
- Update assets based on their asset key.
- Delete assets based on the asset key.
- Get asset details based on the asset key.
- Get all assets by querying a list of all created assets.
- Get assets with pagination, which supports various filter criteria catering to improve the performance of different use case scenarios as the asset number increases.
- Get assets by range with pagination, querying a list of created assets between any two asset keys.
- Get asset history, which traces the timestamped updates of a particular asset based on an asset key.
- Indexing and query performance, instrumental in the case of paginated range queries in a vast dataset. The generic smart contract deploys a configurable CouchDB asset index. The predefined default indexes include asset key and transaction update time, configured according to the data fields of different use case scenarios during the deployment process.
Smart Contract Management Toolset
The smart contract management toolset comprises the Node SDK and the RESTful API to install, update, and remove smart contracts on the deployed network peers. The Node SDK offers client libraries to update smart contracts in the network. The DApp developers use the Node SDK to develop a smart contract management system for their network quickly. Besides, DApp developers can use the RESTful API service to perform management updates on the smart contract for their business use case. This RESTful API service configured and deployed along with the blockchain network through an Ansible playbook starts a Docker microservice on the configured machines. The network management system monitors and manages the deployed RESTful API service and provides an overview of the running microservices. The TIC management dashboard developer tools give access to the RESTful API service and the Node SDK. Besides, the TIC management dashboard offers support to install, update and delete chaincode on targeted peers, as shown in Figure 1
A Hypothetical Example: Car Dealership Service
We illustrate how TIC’s BaaS SDK simplifies the design and development of smart contracts in a car dealership business scenario. From the developers perspective, a typical car dealership application contains the following functionalities :
- Create, delete and update user details.
- Create, delete, and update a car with its owner details.
- Create, delete, and update the payment transaction details.
- Get the list of all users (with pagination support for optimised performance).
- Get the details of a specific user.
- Get the list of all cars (with pagination support for optimised performance).
- Get the list of all cars owned by a particular user.
- Get the details of a specific car.
- Buy a car through:
- a payment methodology to create/delete/update the transaction details
- updating the Sellers and Buyers wallet balance
- updating the car ownership details
- Get the list of all transactions (with pagination support for optimised performance).
- Get a list of all transactions of a specific user.
- Trace the history of user updates, including car and transaction details.
These functional requirements described above specify the conditions of tracking details of the three assets (users, cars and transactions), which led to the design of the three smart contracts shown in Figure 2.
What can you build with TIC?
The developers access the smart contract development toolkit offered by TIC BaaS shown in Figure 3 and update the smart contract and class names. Developers can quickly create smart contracts with all the core asset management functionalities available out-of-the-box, which allows them to focus on developing new functionalities specific to their use case. Furthermore, they can group the created smart contracts as chaincodes and deploy them to the blockchain network, as shown in Figure 1. They can test the deployed chaincode using the RESTful API services or interactively through the TIC’s dashboard service, significantly reducing the time and effort associated with smart contract development.
The TIC’s Baas SDK for simplified DApp design and development is available in the Git repository at http://articonf.eu/tic.
This blog post was written by the bitYoga team in June 2021.
< Thanks for reading. We are curious to hear from you. Get in touch with us and let us know what you think. >