Nattapon Nimakul
Jun 23 · 5 min read

(28/06/2019) Now, we have users more than 3,000 with more than 21,000 transactions using our wallet.

Libra Wallet on Testnet

It’s been almost a week since Facebook announced Libra Blockchain which has Libra Coin run on it. Libra Coin is a Stable coin backed by a basket of fiat currencies. Libra Coin itself is created by Move language that Facebook announced alongside with its blockchain.

Libra is an open source project so we can look inside, play around with it or create a custom module (by Move language). So for Developers it just easy to get started with Libra-CLI to create an account, mint some coins and send it to your friends (of course Developers).

Just try this one, https://developers.libra.org/docs/my-first-transaction

And Thai version here.

What about normal users? who might interest Libra right now? do they have a chance to get some Libra coins? of course not because we no have a user interface for now (Yeah it just getting started 🎉).

Introduce Libra Wallet POC

You can try the first Libra wallet here => https://dev.kulap.io/libra/

Libra Wallet Proof of concept

At Kulap.io as we’re smart contract developers for Ethereum that building Dex (Decentralized Exchange). we see a lot of opportunities here, and we think mass users should have a chance to try it out so we create Libra Wallet POC that easy to use on hands of all users.

Libra Wallet POC is a web wallet that allows users to create their wallets (with 100 Libra Coins) as just open a web page, and send it to their friends with QR Code!

Quick walkthrough

1. Open this page https://dev.kulap.io/libra/

It will be creating your wallet with 100 Libra coins on it.

Libra Wallet Proof of concept

If don’t get 100 coins to please clear browser local storage and try again.

2. Send to your friends (or other browsers)

Select “Send” to scan QR or use “Manual” to provide target address yourself (you can use an account on Libra-CLI here), then “Confirm”.

Libra Wallet — Transfer with QR
Libra Wallet — Transfer with address

3. Done

Then, you should see now your wallet remain balance’s 90 Libra coins.

Libra Wallet — Balance

And the destination address received 10 Libra coins.

Libra Wallet — Balance on Libra-CLI

Libra wallet APIs

Right now Libra project hasn’t officially announced any APIs that we can use with frontend so we decide to make our own APIs that routing any requests to Libra-CLI and return the result from it.

1. Creating a wallet

[POST] https://libraservice3.kulap.io/createWallet

Request Params:
// not thing or {}

Return:

You will get the mnemonic phrase (secret) and public address.

Will call Libra-CLI as following below.

1. account create

2. account mint 0 100

3. query balance 0

4. account write (to get your mnemonic phrase)

curl --location --request POST "https://libraservice3.kulap.io/createWallet" \
--header "Content-Type: application/json" \
--data "{}"

2. Transfer

[POST] https://libraservice3.kulap.io/transfer

Request:

Return:

Will call Libra-CLI as following below.

1. account recover

2. transferb 0 31c70925…14144b 11 (suffix ‘b’ is for waiting transaction to be committed to the blockchain)

curl --location --request POST "https://libraservice3.kulap.io/transfer" \
--header "Content-Type: application/json" \
--data "{
\"fromAddress\": \"91f63f777d8fc5294a4a19a4631a1af4a7e3ae4829cf6b021275773b25782dc7\",
\"mnemonic\": \"burger trust skirt hotel duck recipe vivid token south hero illness memory entry way property caution auto cram quality aisle choose erosion crane army;1\",
\"toAddress\": \"31c7092554bb804a4e25bd24399859428404c28cbc3b44dea5dc2a9f2314144b\",
\"amount\": \"11\"
}"

3. Get balance

[POST] https://libraservice3.kulap.io/getBalance

Request:

Return:

Will call Libra-CLI as following below.

1. query balance 08c7bdf6…0e18c3

curl --location --request POST "https://libraservice3.kulap.io/getBalance" \
--header "Content-Type: application/json" \
--data "{
\"address\": \"91f63f777d8fc5294a4a19a4631a1af4a7e3ae4829cf6b021275773b25782dc7\"
}"

Postman

https://documenter.getpostman.com/view/1671913/S1a32SZ5?version=latest

Libra Wallet Service Architect

Libra Service API (stateless)

To build that APIs we need shell interactive that can send requests to Libra-cli so we use Node.js with child_process and rauschma/stringio libs to run a Libra-cli container every time when the user makes a request (stateless).

Libra shell interactive example 1

For example, createAccount() function will spawn a process of libra-cli container and pipe writableSteam and readableSteam to createAccountWriteToWritable and createAccountReadable accordingly to simulate shell command inout / output.

Inside “createAccountWriteToWritable”, will call each libra-cli commands step by step and use sleep() between each step to make sure that command from previous step has done.

Libra shell interactive example 2

Finally createAccountReadable we use to parse command output, record it to states, then return output to API caller (output return in createAccount() scope).

Libra shell interactive example 3

You can see all complete code here https://github.com/kulapio/libra-service.

The Frontend project

We use Vue.js and Axios for API calling so nothing fancy here if you interesting please have a look at https://github.com/kulapio/libra-wallet-poc.

Mnemonic phrase is saved on local storage, so you can just open another browser to have two wallets.

Conclusion

This POC Libra wallet focusses on users to show how it works by allowing them to play it on their smartphone, laptop or desktop. This’s not safe wallet so please don’t use this technique to your production wallet because sending mnemonic phrase around is not secure at all.

To building a production-grade wallet we should generate mnemonic phrase on the client and never sent it to anyone when the user needs to make a transaction wallet itself need to implement private key singing mechanism and use signed transaction to board cast to the network. Might implementing mnemonic phrase encryption with password as well.

Thank you

Thank you very much for your time reading. If you like this article feel free to share this article with your friends or someone who might be interested ^_^.

Thanks to Bitcoin-Addict Thailand for mentioning this Wallet as The first Libra Wallet in the world ^^.

Any questions please feel free to comments.

Feedback

After we launched our application until now (23 June) We have active users that create a wallet in our app > 1,000+ wallets. With 5,000+ transactions.

Welcome to contributing

Github

API Service: https://github.com/kulapio/libra-service

Frontend: https://github.com/kulapio/libra-wallet-poc

Ref

https://developers.libra.org/docs/my-first-transaction

KULAPofficial

The best rate protocol for everyone.

Nattapon Nimakul

Written by

Smart Contract Developer

KULAPofficial

The best rate protocol for everyone.

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