Connecting to Libra TestNet on Windows with WSL

0
37

We are all excited about Facebook announcement of Libra Blockchain. I know I am and you won’t be here if you not excited about the future of blockchain with this recent announcement. So I started digging in to know how it works and what programming language its built in stuffs like that. First order of business for me was to try and interact with the Libra TestNet with the provided command line interface client.

Checking the documentation, they assumed only Linux and macOS users will be using the system 🙄. I was like WHAT ABOUT WINDOWS USERS!!! Don’t worry Microsoft got us covered with Windows Subsystem for Linux.

If you haven’t Installed WSL follow this installation instruction to Install Windows Subsystem for Linux.

You should have a similar terminal to this on your windows system

Run the following command to update and upgrade your distro.

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade

Next lets Clone the Libra Core Repository with the following command

git clone https://github.com/libra/libra.git

To setup Libra Core, change to the libra directory and run the setup script to install the dependencies, as shown below

cd libra
./scripts/dev_setup.sh

The setup script installs rustup, CMake, protoc and Go.

At this point you may have issues with rustup and your version of protoc, it requires version 3.6.0 above of protoc.

run rustup update in terminal, if command is not found export $HOME/.cargo/bin to path in .bashrc

you can use source .bashrc to reload it so you won’t have to logout and login.

Now lets update protoc, copy each line below and paste it in your terminal to install protoc version 3.7.1
PROTOC_ZIP=protoc-3.7.1-linux-x86_64.zip
curl -OL https://github.com/google/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local include/*
rm -f $PROTOC_ZIP

Once you are done, rerun the setup script again ./scripts/dev_setup.sh At this point you shouldn't have any issues with setup again.

Build Libra Client and Connect to the TestNet.

To connect to a validator node running on the Libra testnet, run the client as shown below.

./scripts/cli/start_cli_testnet.sh

This command builds and runs the client utilizing cargo (Rust’s package manager) and connects the client to a validator node on the testnet.

Once the client Node connects you should see the following.

Feels so good!

Lets Submit Our First Transaction

Before submitting our transaction, lets create a couple of accounts we will be using. Thankfully there are CLI commands to create accounts easily. To see help information about account enter account as shown below.

Enter command account create to create an account.

Use the same command to create a second account.

Lets see the list of account created with account list command

The account index is a local CLI index that can be used in other CLI commands for users to conveniently refer to the accounts they have created. The index is meaningless to the blockchain.

The sequence number for an account indicates the number of transactions that have been sent from that account.

Lets Add Libra Coin to the account we created on TestNet

Mint Libra and add to out accounts with account mint 0 100

  • 0 is the index of first account created
  • 100 is the amount of Libra to be added to the account

for the second account account mint 1 20

  • 1 is the index of Second account created
  • 20 is the amount of Libra to be added to the account

Note that when the request is submitted, it means that it has been added to the mempool (of a validator node on testnet) successfully. It does not necessarily imply that it will be successfully completed. Later, we will query the account balance to confirm if minting was successful.

A successful account mint command will also create our accounts on the blockchain.

To check the balance in our accounts enter this command: query balance 0

Lets Transfer our money with the following command transfer 0 1 25

  • 0 is the index of first account created
  • 1 is the index of second account created
  • 25 is the number of Libra to transferred.

Lets check our account balance after the transfer has been completed.

Yah! We have successful submitted our first transaction on Libra TestNet.

If you have any problem doing this successfully lemme know in the comment section. I’m supper excited for what the future holds.

For more details checkout My First Transaction


Connecting to Libra TestNet on Windows with WSL was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.