Libra Testnet on Google Cloud Platform
Deploying Facebook Libra testnet on Google Cloud Platform is a simple process that will take about an hour.
The steps are broken into the following quick steps. Follow the workflow for deploying on Google Cloud Platform Compute Engine with a simple IAM posture for training and testing.
For those interested in learning more about Libra and how to deploy on GCP and AWS join the Liveonline Pearson Oreilly class Facebook Libra.
https://learning.oreilly.com/live-training/courses/facebook-libra/0636920306610/
Note that this assumes you have a basic knowledge of Google Cloud Platform and is not a tutorial for Google Cloud Platform basics.
- Deploy Compute Engine
- Configure Firewall
- Configure IAM
- Connect to Instance
- Download and Install git
- Create Accounts
- Mint Coins
- Validate Coins
- Transfer Coins
- Validate State
- Optional Appendix (Install Stackdriver agents for additional Monitoring and logging metrics)
Deploy Compute Engine
Compute Engine is Google Cloud Platforms Infrastructure as a Service (IaaS) virtual machines.
1. Deploy a Compute Engine Instance. This can be deployed with Free Credits or with the Free Tier if needed. I would recommend you use a single core and not a shared core. Also, you may want to deploy this is a separate project.

2. Enable Firewall for Http and Https. Note that this is for web access. Not needed fully for initial demo. Also, you should determine you security posture and determine if you want to use VM based keys or project wide keys. This demo is using same keys for project.




3. Deploy instance by selecting Create.




Configure Firewall




4. Confirm Instance Creation in Compute Engine Dashboard which will show instance completed as a green checkmark.




5. Go back to GCP home dashboard.




Configure IAM
6. Select IAM & admin to Create Instance IAM posture and to add Permissions for Compute Engine user.




7. Select ADD to add user permissions.




8. Add Members by Entering your user name and then select Role of Compute Admin. Save to continue..
(To install git you will need to have admin access. This is the simplest way for a demo)




9. Validate you are the owner of Compute Engine
Connect to Instance
Now we need to go back to Compute Engine Dashboard.




10. Login into the VM you created by Selecting SSH Dropdown




11. For the purpose of this demo I will use the SDK and will copy the gcloud command.




Note.. You will receive a pop up like below if you have not logged into the VM before with the SDK




Select Yes to continue. You should see a putty or terminal show up.(depending on your config) Font will be changed to provide readability
We are logged in and ready to go. We now need to find git updates and download. Then we will install git since the Compute Engine image will not have git installed. (command : which git should be not found)




Download and Install Git




12.Find packages for git by running command : sudo apt-get update




Package will complete and should reflect Done.
sudo apt-get install git




13. Install git.. 1. Run command: sudo apt-get install git and 2. also select Y which will run the install of git




Download and install complete. Now lets validate our install of git




14. Validate git by running command: which git




Now we need to initialize
15. Initialize git by running command: git init




Now we need to add to directory.
16. Add to directory tree. Run command: git add .




Note. It generally a good practice to commit, add origins and push to a master repository in a real development environment you git repositories. For time purposes and not being totally needed I will skip for this demo.
Clone the Facebook Libra Repository. We have our Compute Engine Instance ready and now can following the Libra page instructions are correct and would work. Following this link if you choose. https://developers.libra.org/docs/my-first-transaction#the-transfer-command




17. Clone the Facebook Libra repository by running command: git clone https://github.com/libra/libra.git
Setup Libra testnet




18. Setup Libra Core blockchain testnet by changing directory to libra and running the setup script. Select Y
cd libra
./scripts/dev_setup.sh
Kick off by selecting Yes




19. Kick off by selecting Yes
The process will continue for a minute until you see the next screen.




We are done with dependencies.
We now need to run the setup script.




20. Setup the Libra Blockchain testnet by running the script.. ./scripts/cli/start_cli_testnet.sh
Note: This is the longest part of the process. This could take up to 10 minutes since it will compile and build our local testnet.




Your install and script run has completed
Lets create accounts
Create Accounts
We will create two accounts. I am using Joe and Frida as an example.




21. Create first account by typing command : create account joe




22. Create second account by typing command : create account frida
Now lets validate the accounts.




23. List account by running command: account list
Now we need to mint coins for these users.
Joe is user 0
Frida is user 1
For example:
- 1 is the index of Joes account.
- 1000 is the amount of Libra to be added to account.
- A successful account mint command will also create Joe’s account on the blockchain. Another way to create Bob’s account on the blockchain is to transfer money from Frida’s account to Joe’s account.




24. Mint coins. Run command for each user account mint 0 1000 and then again account mint 1 1000
Now we need to validate our accounts are created.




25. Validate accounts by running commands query balance 0 and query balance 1
Next lets validate we were at in sequence




26. Validate sequence by running command




We now will validate the account state.




27. Validate the account state by running command: query account_state 0
This concludes the demo.
The appendix provides instruction on how to setup Stackdriver Monitoring and Logging (Optional)
There are also other activities you can perform on the Libra testnet page.
https://developers.libra.org/docs/my-first-transaction#the-transfer-command
END OF DEMO.
Appendix – Stackdriver




Install Stackdriver Monitoring and Logging Agents (Optional)
This is optional if you want the Stackdriver agents to give you deeper insight into your infrastructure and application data. Install both agents onto all the infrastructure you want deeper insight into.
Skip if your not planning on monitoring or logging significantly.
Refer to appendix if your looking for this insight.
Monitoring can access some instance metrics without the Monitoring agent, including CPU utilization, some disk traffic metrics, network traffic, and uptime information. Monitoring uses the Monitoring agent to access additional system resources and application services in virtual machine (VM) instances. If you want these additional capabilities, you should install the Monitoring agent.
Stackdriver is under “Stackdriver” in the Cloud Console




Select Monitoring from the Stackdriver menu. This will bring you to following interface. (Note if your project has not been imported into Stackdriver then you will be prompted to confirm)




Install the Agent. Select Install Stackdriver Agents




Copy the commands for monitoring and run the commands in the VM CLI(You will need to SSH in or use Cloud Shell to access VM you created )
Install Stackdriver Monitoring Agents
Run the commands to install the Stackdriver Monitoring Agents by copying
Run Commands : curl -sSO https://dl.google.com/cloudagents/install-monitoring-agent.sh
sudo bash install-monitoring-agent.sh
Repeat for Logging as well
Run Commands: curl -sSO https://dl.google.com/cloudagents/install-logging-agent.sh
sudo bash install-logging-agent.sh
After a few hours you VM should have activity. You can view under resources in Stackdriver Interface.




For more info on the Monitoring and Logging agents please refer to
https://cloud.google.com/monitoring/agent/
https://cloud.google.com/logging/docs/agent/
Thank you and happy Blockchaining.
Joe Holbrook, MyBlockchainExperts
Want to learn how to install Hyperledger Fabric on AWS? Check out this post.



