Flea market using Libra and Ethereum (CAN’T deal with real items)

Yosuke Aramaki
Dec 25, 2019 · 6 min read

Introduction about FLibra (Flea market x Libra)

On June 18th 2019, Facebook announced a stable coin pegged by some of fiat currencies called Libra.
We are thinking that blockchain is a technology to enhance sharing economy, so that it is meaningful to research and develop an application.
We want the users to have a cryptocurrency payment experience by using Libra currency.

You can try FLIBRA here >> https://flibra.gaiax-blockchain.com/
* This is a demo website. You cannot trade real items.

Github : https://github.com/gaiax/fLibra

Application Instruction

1. Create Libra wallet

Click Create Libra Wallet, and you will get your Libra wallet with 100 Libra coins. Please remember your mnemonic phrase (25 words password).

Libra coin is minted from test-net, so those coins have no value.

2. Sign in

Please enter your mnemonic phrase (25 words password) which was shown in step 1. If you already have a Libra wallet, you can use your mnemonic phrase.

3. Register your user information

On /myPage, please click “Register your user info”, then set your “User Icon” and “User Name”.

Before
After

4. Open secret browser

Please open a secret browser by shift + command + n, and “repeat step 1 to 3”. To have a better experience with this demo website, use one browser for seller side and other browser for purchaser side.

5. Sell the item

On the seller side browser, please click “Sell” button on right bottom corner.

Fill out the form of all items and click Sell Item button. If you receive the notification, your item is successfully posted.

6. Purchase the item

On the purchaser side browser, click an item that you posted in step 5.

Please click “Buy now” button on item detail page. In this step, Libra coin will be sent to the escrow account which is a third party account.

*(This is temporal auto escrow. We will continue developing the auto escrow function on Move language.)

7. Notify the purchaser that you prepared to deliver the item

On the seller side browser, please click “Change status” button to notify the purchaser that you(seller) have prepared to deliver the item. After you click the button, the item status will change to “On delivery”.

Seller side — — — — — — — — — — — — — — — — — — — Purchaser side

8. Notify the seller that you received the item

On the purchaser side browser , please click “Change status” button to notify the seller that you(purchaser) received the item. After you click the button, the item status will change to “Write review”, and Libra coin will be sent to the seller Libra account.

Seller side — — — — — — — — — — — — — — — — — — — Purchaser side

9. Write Review

After finishing the transaction, you can write a review to both the seller and the purchaser.

Seller side — — — — — — — — — — — — — — — — — — — Purchaser side

After both the seller and the purchaser wrote a review, review list looks like this.

Seller side — — — — — — — — — — — — — — — — — — — Purchaser side

* Posted item workflow

On sale
・On sale
: When you post an item.

In progress
・Waiting for delivery : When someone purchased your item, an item status show Waiting for delivery in progress item list. Once you prepared for delivery, please click this button.
・On Delivery : When you prepared for delivery and send the item to the purchaser, an item status shows On Delivery in progress item list.
・Write Review : When the purchaser received the item, an item status shows Write Review in progress item list.

Completed
Completed:After you finished to write review to purchaser, the item move on to completed section.

* Purchased item workflow

In progress
Waiting for delivery
: When you purchased an item, the item move on to in progress section and shows “Waiting for delivery”.
On Delivery : When the seller prepared to deliver and send the item to the purchaser, an item status shows “On Delivery” in progress item list. Once you received the item, please click this button.
・Write Review : When you received the item, an item status shows “Write Review” in progress item list.

Completed
CompletedAfter you finished to write review to the seller, the item move on to completed section.

FLIBRA architect

We use the Ethereum PoA private blockchain for faster transaction speed and zoro gas cost.
When we send transaction to Blockchain, the event data in transaction receipts will be stored in Firestore, and this is the only way to update firestore data.However, Blockchain and Forestore are partially synchronized because there is a possibility of failure to store data in Firestore even if the transaction to blockchain was successful.Thus, we have to research more about how to synchronize database to blockchain.

Item and review data are stored both in Firestore and blockchain, while user info is only stored in the Blockchain because it does not take much time to load user info.

To talk about search function, Node.js(GAE) is watching Firestore collention to synchronize firastore to elasticsearch. When Firestore is updated, an item data will be sent to Elasticsearch. A search query will be sent to firestore, then elasticsearch will rearch based on the querry and send a result to firestore.

Conclusion

Libra is under developing, so we couldn’t develop the application by taking advantage of Libra characteristic such as Move language. Currently, it is an application that is mainly using ethereum private chain, However, as Libra develops, we will replace functions based on Libra.

Future works

Escrow

At this moment, we couldn’t use custom Move modules on Libra test-net. Therefore, we will continue to research about Libra to deploy custom Move on test-net and build escrow function on Move language.

Synchronize across Libra , ethereum and database

There are several possibilities of synchronized failure. One example is failure in sending transaction on blockchain after successfully transferring Libra coin, and another is failure in storing data in database after successfully sending transaction on blockchain. We need to develop how safely synchronize those data.

Key management

In the application, ethereum private key will be generated by Libra mnimonic phrase. Both key and mnimonic are stored in localStorage. This key management is not yet secure, so eventually we will replace this key management with those applications in secure way since Libra community is currently developing Libra wallet.

Thank you

Thank you so much for taking your time to read the article. If you have any question, please feel free to contact me.

Contribute

Welcome to contributing!

Github : https://github.com/gaiax/fLibra

Ref

The First Libra Wallet POC — Building your own Wallet and APIs
https://medium.com/kulapofficial/the-first-libra-wallet-poc-building-your-own-wallet-and-apis-3cb578c0bd52

kulap-libra https://www.npmjs.com/package/kulap-libra

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade