OST Loyalty 2.0 — Week 3: The wallet

TechupBusiness
3 min readJul 30, 2018
Photo by Julius Drost on Unsplash (partner of OST Simple Token)

OST Loyalty is an add-on for the e-commerce software cs-cart (online stores and marketplaces) that creates a customer loyalty program based on OST Simple Token, an easy-to-use side-blockchain for the crypto-currency Ethereum (ETH). It is the result of our participation in the first “hackathon” OST KIT Phase 2. This series will discover our progress for OST KIT Phase 3 to integrate the user wallet into OST Loyalty.

The past week was all about implementing the wallet feature with our custom PHP API Wrapper which you can find on Github here.

Balances

The wrapper implementation worked like a charm in the beginning. The balances endpoint did what it should do, except the fact, that it gives us back three different kinds of balances:

"available_balance": "14.243366506781137",          "airdropped_balance": "6.231683253390568746",          "token_balance": "8.011683253390568746"

The most relevant balance for us is the available_balance , but how are airdropped_balance and token_balance used? The answer was given in the supportive OST Developer gitter.im channel: the airdropped tokens will be used first for any transaction, then the “normal” tokens.

By default, the available_balance will be shown on each page in CS-Cart in a CS-Cart “block” (if the administrator placed it there, as we did).

In addition, we show up the detailed balance to the user on the transaction page and linked to OST View (store owner can enable/disable these links in the settings):

Wallet data receiving from Balances- and Ledger-API endpoint

Ledger

While implementing the transaction history by using the ledger endpoint, we struggled a bit because one of our requirements, custom meta data on the chain, does not exist (yet?) in OST KIT. So we had to enrich the transaction data from our centralized database to gather all the needed data and allow an easy and intuitive user experience.

In detail were missing and had to store together with the transaction id:

  • action identifier (which triggered the transaction)
  • exact exchange rate to the default currency (can be any) in CS-Cart in the moment of transaction execution (important because this is the fiat value, that the transaction was eventually used to pay or to earn based on sales volume)

If we would store the exchange rate on the blockchain, we would need to store also the exchange rate currency in addition.

Action identifier and exact exchange rate-based value in moment of transaction

This week we are going to update our live demo systems and create the instruction- and help material for setting up and use of OST Loyalty 2.0 with CS-Cart. Besides some small enhancements and bug fixing.

Read more:

--

--