I am certain that you are on this page because you have heard about Facebook’s cryptocurrency Libra. Facebook has released ‘Libra’ and is all set to revolutionize the blockchain market. Yes, the social media site has also ventured into one of the world of digital currencies. Facebook launched the currency on Tuesday, May 18, 2019. One of the selling points of this digital currency is that users can send money or buy products and services at almost zero fees.
Both Bitcoin and Libra are based on blockchain technology, created by complicated mathematical functions to keep them incorruptible. Apart from this there is only a very tiny thing common between Libra and Bitcoin .
What is Libra?
According to Facebook, Libra is a global digital currency that is powered by a blockchain created by Facebook as well as the encrypted technology used by cryptocurrencies such as bitcoin.
The currency will be managed by a group called the Libra Association. Facebook explained that this group is an independent one based in Switzerland. Although Libra is only a few days old, it has gained the attention of many people already. If you are also interested in this currency, you may want to know how it works.
We have compiled a file that will talk about what to do when you finally want to perform your first Libra Blockchain transaction.
A command line interface (CLI) is provided to interact with the Blockchain. Now just this but it also provides basic commands for creating accounts, mint coins, performing transfers, and querying the blockchain. Now, the important thing is that the commands run on the assumptions listed below.
Here is What to Do to Submit a Transaction
Here is an example that will explain you how to download Libra’s essential components and complete a transaction between two users. Let’s assume the names, Esther and Adam.
Below discussed are the steps that you need to perform for submitting a validator node on the Libra testnet.
Now, let’s take a deep look at how we perform these steps for a successful transaction.
Do This First
This is How You Clone the Libra Core repository
git clone https://github.com/libra/libra.git
Now Is The Time For Setting Up The Libra Core
You can set up Libra Core by changing to the Libra directory and then running the setup script. This will install the dependencies as indicated below.
cd libra ./scripts/dev_setup.sh
What actions the setup script performs? Let’s take a look
It is Now Time to Build Libra CLI Client and Connect to the Testnet
You can run the client below to connect to a validator node that runs on a Libra testnet.
This command builds and runs Rust’s pack manager; client utilizing cargo and then proceed to connect the client to a validator node on the testnet.
When the connection between a client and a node on the testnet is successful, the output below will be displayed. You can use the quit command to quit the client whenever you want to.
Use the following commands:
account | a Account operations query | q Query operations transfer | transferb | t | tb | | [gas_unit_price (default=0)] [max_gas_amount (default 10000)] Suffix 'b' is for blocking. Transfer coins from account to another. help | h Prints this help quit | q! Exit this client
Please, input commands:
All is Set for the Creation of Esther’s and Adam’s Accounts
When you succeed in connecting your client to the testnet, you can create new accounts by running CLI commands. Let’s try creating accounts for two people. For the sake of the example, let’s name them Esther and Adam.
Step 1: Confirm if the CLI Client is running on your system.
Use the command below to check if the Libra CLI Client is running.
libra% account usage: account
Use the following args for this command:
create | c Create an account. Returns reference ID to use in other operations list | la Print all accounts that were created or loaded recover | r Recover Libra wallet from the file path write | w Save Libra wallet mnemonic recovery seed to disk mint | mintb | m | mb Mint coins to the account. Suffix 'b' is for blocking
Step 2: Create Esther’s Account
It is vital to note that creating an account using the CLI only creates a local key-pair, it does not update the Blockchain.
The command below will create Esther’s account
libra% account create
You should get a response like this is the account creation is successful.
>> Creating/retrieving next account from wallet Created/retrieved account #0 address 3ed8e5fafae4147b2a105a0be2f81972883441cfaaadf93fc0868e7a0253c4a8
The index of Esther’s account is #0 and the address is the hex string. The index is just another way to identify Esther’s account. The index can be used in other CLI commands since it is a local CLI index. However, the index is not important to the Blockchain. Up to this point, Esther’s Blockchain has not been created. It will only be if money is added to the account. They can add money via account to account transfer or minting. The hex address can also be used in CLI commands but the index is more convenient.
Step 3: Create Adam’s Account
Use the command you used in creating Esther’s account.
libra% account create
You should still get an output like the one below if the account creation is successful.
>> Creating/retrieving next account from wallet Created/retrieved account #1 address 8337aac709a41fe6be03cad8878a0d4209740b1608f8a81566c9a7d4b95a2ec7
Adam’s account index is #1 and the address is the hex string. You will more details under step 2.
Step 4: List Accounts
Use the command below to execute this step.
libra% account list
Your success output notice should read like this:
User account index: 0, address: 3ed8e5fafae4147b2a105a0be2f81972883441cfaaadf93fc0868e7a0253c4a8, sequence number: 0 User account index: 1, address: 8337aac709a41fe6be03cad8878a0d4209740b1608f8a81566c9a7d4b95a2ec7, sequence number: 0
The sequence number attached to an account shows the number of transactions that have been sent to that account. In this case, no transaction has been sent to both accounts since the sequence number is zero.
Add Libra Coins to Esther’s and Adam’s Accounts
Testnet allows you to mint and add coins to accounts via Faucet. Faucet exists to facilitate the minting of coins for testnet. Faucet creates Libra that has no real-world value. Since you have already created Esther’s and Adam’s accounts, you can follow the steps to add Libra to them.
Step 1: Add 120 Libra to Esther’s Account
To add a mint Libra to Esther’s account,
libra% account mint 0 120
• Esther’s index is 0
• The amount of Libra for Esther’s account is 120.
If the account mint command is successful, it will create Esther’s account on the Blockchain.
You should get a notification like this if it is successful
>> Minting coins Mint request submitted
Submitting a request successfully does not mean that the minting was successful. You need to query the account to check. We will do that later.
Step 2: Add 72 Libra to Adam’s Account
Use this command
libra% account mint 1 72
• The 1 is Adam’s index
• 72 is the Libra amount to be added.
• If the command is successful, it will create Adam’s account on the Blockchain. You can also transfer Libra from Esther’s account to Adam’s account.
This is a sample success notice:
>> Minting coins Mint request submitted
Step 3: Check the Balance
Use the command below to check the balance in Esther’s account.
libra% query balance 0
If it is successful, you should get an output message like this:
Balance is: 120
Use this command to check the balance in Adam’s account.
libra% query balance 1
You should get a message like the one below if it is a success.
Balance is: 72
You Are Almost There: Submit a Transaction
To transfer Libra from Esther’s account to Adam’s account, we need to query the sequence number of each account. This will show completing a transaction successfully changes the sequence number of each account.
Querying the Accounts’ Sequence Numbers
libra% query sequence 0 >> Getting current sequence number Sequence number is: 0 libra% query sequence 1 >> Getting current sequence number Sequence number is: 0
The sequence numbers for both accounts are 0 which means no indicates that no transaction has been executed.
Now we want to transfer 10 Libra from Esther’s account to Adam’s account. We will use the command below:
libra% transfer 0 1 10
• 0 is Esther’s account index.
• 1 is Adam’s account index.
• 10 is the Libra amount to be transferred from Esther’s account to Adam’s account.
You should get an output message like this if it is successful.
>> Transferring Transaction submitted to validator To query for transaction status, run: query txn_acc_seq 0 0 <fetch_events=true|false>
If you want to retrieve the information about the transaction you just submitted, use this command: txn_acc_seq 0 0 true
The first parameter shows the local index of the sender’s account and the second is the account’s sequence number.
Query Sequence Number After Transfer
libra% query sequence 0 >>Getting current sequence number Sequence number is: 1 libra% query sequence 1 >> Getting current sequence number Sequence number is: 0
Esther’s sequence number has been increased to 1 which means that one transaction has been sent from her account. Adam’s sequence number is still zero which indicates that no transaction has been sent from his account.
Check the Balance in Both Accounts After Transfer
To check the balance in both accounts, use the commands used in step 3.
If the transaction is successful, Esther’s balance will be 110 and Adam’s balance will be 82.
The commands and output results are below.
libra% query sequence 0 >> Getting current sequence number Sequence number is: 1 libra% query sequence 1 >> Getting current sequence number Sequence number is: 0
Your 10 Libra transfer from Esther’s account to Adam’s account has been successful.
What to Do When You Encounter Problems
Try this When Encounter Issues During Setup
To update Rust: Go to your Libra directory and run rustup update. To rerun script: ./scripts/dev_setup.sh
Try This When Encounter Issues During Client Build and Run
If you encounter build failures, remove cargo lock file
If you are unable to connect to testnet: Check internet connection
Check if you are using the latest version of Libra Core and then rerun the client below.
Try this When Encounter Issues During Minting and Adding Money to Account
You will get a server unavailable notice if the validator node you connected to the testnet is unavailable. The message should look like this:
libra% account mint 0 110 >> Minting coins [ERROR] Error minting coins: Server unavailable, please retry and/or check **if** host passed to the client is running
Sometimes, high transaction volumes can cause a delay in the update of accounts. If the account is not updated, wait for a while and then query the account again.
Use the command below to check if an account exists. We will be using an account with index 0.
libra% query account_state 0
You will see this error note if the testnet validator node is unavailable or the testnet connection has timed out.
libra% transfer 0 1 10 >> Transferring [ERROR] Failed to perform transaction: Server unavailable, please retry and/or check if host passed to the client is running
• Check the testnet connection.
• Check if the sender account exists by sending a query using the command: query account_state 0
• You can also quit the Client using the command: quit or q!
Then rerun the command below to connect to testnet.
This command should be run from the Libra directory.
The Bottom Line
Now you know how to start your first Libra transaction, from cloning and building the Libra Core to submitting a transaction. This article gives you all the information you need on Libra and its transactions. We will give you more information in another post.