How We Built a Smart Inventory on a Blockchain

Written by lisk | Published 2021/06/03
Tech Story Tags: lisk | blockchain | decentralized-internet | blockchain-technology | javascript | decentralized | api | good-company

TLDR Smart Inventory is a decentralized application that tracks the history and life path of valuable items. Users can claim ownership of an item or transfer their owned items to another user. Smart Inventory makes use of the custom lisk-extended-api module (created by Moosty), to be able to effectively query the database. Each item on the network is basically an account with a custom asset object. The properties of this asset can be seen in the code snippet below: The properties are used to let the frontend know what type of item it actually is. The network of choice for this proof of concept is vintage synthesizers.via the TL;DR App

Smart Inventory is a decentralized application that tracks the history and life path of valuable items. Users can claim ownership of an item or transfer their owned items to another user. With each action certain metadata is supplied that populates the dataset of an item. This enables users to analyse its history.

Why blockchain?

Secondhand markets for valuable items are often fraudulent and it can be challenging to obtain a true and verifiable history. Substantial sums of money can be both made and lost, by manipulating historical data of certain goods.
Smart Inventory tries to solve this problem by tracking the complete history of an item. This data is then stored in a decentralized manner, making it difficult to tamper with. By avoiding the dangers of a centralized database, an item’s history can now be proven and therefore its value can be more easily guaranteed.

Use Cases

For this proof of concept, I decided to go with a smaller type of network that focuses on one particular type of item. This is not a technical limitation, but rather is done to increase the probability that the existing data is populated more sufficiently.
In other words, if more of the same identical items are registered, it is easier to generate comparison data. On the other hand, if you spread the types of items too sparsely, there won't be much to compare with.
Some use cases for a network are listed below:
  • Vintage synthesizers
  • Watches
  • Art (of any kind)
  • All kinds of rare or luxury goods
These are all valuable items that have their own “community” and “enthusiasts”. Each community can run their own network, focusing only on the goods that they are excited about. 
However, as mentioned above, nothing is technically stopping you from listing everything, if that’s what you prefer.
As you can see in the front end, the network of choice for this proof of concept is vintage synthesizers.

How does it work?

Each item on the network is basically an
account
with a custom asset object. The properties of this object can be seen in the code snippet below:
Please note that the
identifier
is used to let the frontend know what type of item it actually is. These identifiers are assigned beforehand in the client.
By sending a
RegisterItemTransaction
to an address, the custom properties of the asset object are added to the account, and the account is then transformed to an
ItemAccount
.
The properties of this asset can then be modified by sending a
TransferItemTransaction
to the account.
As you can see only the owner of an asset can transfer an item.
By going through the transaction history of the account, specifically by filtering on these custom transaction types, you can analyze the history of the account (item), and in turn generate data from it.

Custom Modules

Smart Inventory makes use of the custom lisk-extended-api module (created by Moosty), to be able to effectively query the database. This addition makes it possible to search for values in the custom asset fields, something that is not yet supported natively.
For example, here it is being used to search the
owner
field:

Smart Inventory In Action

Item registration
Item transfer
Item view
You can try the proof of concept here.

Conclusion

I had great fun making this proof of concept and I hope this blog gave you some valuable insight as to how it was created. I encourage everyone to take a look at the source code and play around with the app. The relevant links are provided below.
If you have any questions, feel free to reach out on Discord (user `lemii#0001`).

Resources

If you feel inspired and want to build your own proof of concept blockchain application, check out the Lisk Builders program. More information about the program and the application procedure can be found on the Lisk webpage for the Lisk Builders program.
Disclaimer: This blog post was written by our community members, Lemii (Lisk.chat username: Lemii) as part of his participation in the Lisk Builders program. 

Written by lisk | We empower developers with a software development kit for blockchain applications written in JavaScript.
Published by HackerNoon on 2021/06/03