Loyalty System Using Blockchain

Dec 17, 2021by, Arun Ravi

Block Chain

What is a loyalty system?

Customer loyalty is said to be achieved when a customer chooses the same service/goods provider again and again without looking for alternative providers. The customer is loyal if he consistently prefers the same provider for an extended period of time. A customer always likes a service/goods provider who is transparent and offers the best customer support throughout. With increasing competition to capture the market, commercial establishments are engaging in new methods to keep their customer base intact. One of the techniques employed is a customer loyalty program. A loyalty program is intended to keep a customer loyal/glued to the services provided by a brand. A loyalty program started as a simple point system that the customers can redeem for cost benefits.

Blockchain based Loyalty System

A simple point of redemption as a loyalty system gave a one-dimensional view of something which has an immense multi-dimensional possibility. In the entirety of this paper, I will be discussing a loyalty point system that has all the benefits and security of a cryptocurrency ( the circulation of which will be limited to a private network). In this loyalty system, the points are not just transacted directly between the vendor and the customer but also between customer and customer, i.e., you can exchange your reward points with your friends and family. The loyalty points are mined and are given to the customers based on their spending pattern. The points earned by the customer are transferable, making it similar to a virtual currency. The transactions are stored in a distributed ledger. These transactions are verified by a set of mining nodes. A transaction is considered valid only when the majority of the mining nodes agree that it is a legitimate transaction. Thereby ensuring the security and authenticity of each transaction. There are provisions to roll back transactions upon detecting a fraud. Many of you might be wondering what is blockchain, distributed ledgers, and miners/mining nodes. These are the buzzwords of this decade; a lot of hype is around these words and let’s check what each one of them is in the subsequent sections.

What is a blockchain?


The description that most of you have come across the web will be ‘A replicated immutable time-stamped database using cryptographic encryption that would facilitate consensus-driven collaboration and tracking of transactions and interactions. Wow, that’s too complex and got the better of you.

Let me explain it in simpler terms using day-to-day terminologies. Normally we used to keep our transaction/statistical information in a book or an excel sheet. In order to keep it secured we used to keep multiple copies of the same. Each copy is always in sync and can be owned by different companies or individuals. The structure in which we store information in a blockchain is similar to this distributed excel sheet or book, though it has some additional fields to keep it secure and verified. The multiple copies of the information at different locations make it a distributed database. Since this is distributed bookkeeping we call it a distributed ledger as well. Lets us start with an example. We have an excel sheet with the following information about a commodity exchange. The fields in the excel sheet are as follows Initiator, Receiver, Commodity, Quantity, Time.

  • Initiator: Person who initiates the transaction. Usually, this will be a unique identifier (call it signature)
  • Receiver: Person who is receiving the commodity. This will be also a signature just like the initiator
  • Commodity: The entity that is being transacted.
  • Quantity: The amount of commodity transacted
  • Time: The time (Date and Time) during which the transaction was conducted.

In Blockchain we have an additional field called ‘hash’. The hash value is generated based on the contents of the transactions and that of the last successful transaction.

Anybody who wants to make a transaction can add a new row to this sheet to record their transaction. When a contributor adds a row, it is time-stamped, and he also signs his name against the transaction so that others can verify, he was indeed the actual contributor. One of the columns in the row added is Hash. Hash is cryptographically encrypted stuff that is created using the editor’s signature, Hash of the previous row, and transaction details (Transaction Content) being added.

The hash of one row has a dependency on the hash of the previous row, every transaction is dependent on the previous transaction and iteratively across all transactions in the database and hence we have a chain of transactions.

When a row is added to the sheet, others who have a copy of this sheet validates the transaction by checking the hash of the transaction and by confirming the ownership of the entity transferred was with the transaction initiator. If everything is fine they will add this row to their copy of the excel sheet to maintain the universal truth. This is called collaboration.


If a fraudster tries to manipulate the previous transaction, then he will have to manipulate all the subsequent transactions which are never possible as the transactions keep on occurring. This is because the content of the transaction and the hash of the previous transaction are contributing factors in the hash of the new transaction. So, the fraudster has to calculate the hash from corrupted transactions to the latest. The multiple copies of the sheet and consensus-driven universal truth also add to the agony of the fraudster. The information in the majority of the copy is considered as the truth and hence the attacker will have to manipulate the data on the majority set of copies to effectively corrupt the information which is nearly impossible.


Suppose we have a lot of transactions happening simultaneously, let us extend the above logic of recording a single transaction to a set of records. Then these transactions are recorded temporarily on a log and after every fixed time interval the transactions that have happened are batch-processed as blocks of data. As explained for a row, the hash of a block of transactions is calculated and is dependent on the hash of the previous block, the contents of the block, and the signature of the person who is creating this hash from the block. Instead of recording transactions individually, we record them in blocks and we have a chain of blocks also called a blockchain.

The person who is creating this hash for the block is doing a service for the blockchain and needs to be compensated for his service (computing power, electricity, etc.). This person is called a Miner. A small transaction fee is charged on each transaction to compensate the miner and this fee is called the Gas Price. The Higher the gas price more the miners will be interested to process your transaction. Since there is an incentive for creating blocks, many miners will compete against each other to create blocks at the earliest.

Ethereum based Loyalty System

Now we have a basic understanding of the blockchain, let’s get our focus back on the loyalty point system which we were discussing earlier. The commodities exchanged in a loyalty system are loyalty points and these exchanges occur between customers and commercial establishments or between customers and customers or even between two commercial establishments. We used an Ethereum cluster for our blockchain requirements and this was provided by the Microsoft Azure cloud service. There should be a minimum of two working mining nodes for a transaction to be accepted by the blockchain. If the number of mining nodes is less than two then the above-discussed consensus-driven universal truth will be affected.

The communication with the Ethereum blockchain was done using the WEB3J library. WEB3J is a lightweight, reactive, type-safe Java library for integrating with nodes on the Ethereum blockchain.

We can deploy smart contracts controlling the various kinds of transactions on the loyalty system. Using smart contracts we can define how a commodity can be transacted, we can define the rules governing such transactions. The contracts are written in Solidity language. This is a Turing Complete language, giving us enough capabilities to write smart logic in the contract. The alternative to Ethereum blockchain is Steemit, Hyperledger, Counterparty, etc.

Have a project in mind that includes complex tech stacks? We can be just what you’re looking for! Connect with us here.

Disclaimer: The opinions expressed in this article are those of the author(s) and do not necessarily reflect the positions of Dexlock.

  • Share Facebook
  • Share Twitter
  • Share Linkedin