Create your first 100 LibraCoins tutorial for developers

Andy Octavian
Jun 18 · 4 min read

In this tutorial I’m going to show you step by step how you can create 100 LibraCoins

Step #1 — Prerequisites

Spin up a new Linux VM… let’s say Ubuntu 18.04 should do it

Make sure you have CMake, protoc, Go & rust installed on your machine

Fortunately you don’t have to search how to install each because a bootstrap script is included.

cd /your_favorite_location

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

cd libra/scripts

./dev_setup.sh

wait 1–2 minutes, enter your password couple of times and you’re done

Step #2 — Connect to a testnet (or host your own)

under libra/scripts/cli

./start_cli_testnet.sh

Time to go grab a beer because it will take some time.

After downloading and compiling a bunch of dependencies
it will connect to ac.testnet.libra.org having configured the trusted peers

[peers.9102bd7b1ad7e8f31023c500371cc7d2971758b450cfa89c003efb3ab192a4b8]
network_signing_pubkey = “20000000000000005f5ecda9576edd942ed22aa4735939092161445177cd456fd087c7bc1d6de403”
network_identity_pubkey = “2000000000000000b5eb9a2e5814c66df6c01a1dc94252a4ae6733e93a58187c5eb48d1f53be0b28”
consensus_pubkey = “2000000000000000576e91b04632683a11c3be3dc47a19f9f0a31ae947211f59c5fe02dfa2d07d68”

[peers.dfb9c683d1788857e961160f28d4c9c79b23f042c80f770f37f0f93ee5fa6a96]
network_signing_pubkey = “2000000000000000246ca919a3b39c95110e3bee891136ab087a9b3b9e84fa90cbf8f19c8abe62e3”
network_identity_pubkey = “20000000000000008aa297d686dd2444de86ea3a68353d74af74b9659990d06ccaf4344e2b629b33”
consensus_pubkey = “20000000000000003ca1400fb865befa8a21c58e90fc636ef2f84993a8396cb0e10008f876a00afd”

.. and so on

if all went good you’ll see:

Connected to validator at: ac.testnet.libra.org:80
usage: <command> <args>

Use the following commands:

account | a
Account operations
query | q
Query operations
transfer | transferb | t | tb
<sender_account_address>|<sender_account_ref_id> <receiver_account_address>|<receiver_account_ref_id> <number_of_coins> [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:

libra%

Step #3— Create some accounts

Type “account c” couple of times (“c” is from create, but we’re cool and we don’t like to type extra)

libra% account c
>> Creating/retrieving next account from wallet
Created/retrieved account #1 address 6f6a2ddf62b423b1d0df7662006d68ae90903d65e8d4d90c2f0cf43799c1718f
libra% account c
>> Creating/retrieving next account from wallet
Created/retrieved account #2 address 5cb60a2a9dca32a057139f37a4b16ed74cff19d2e0d174a16b66a64759dad523
libra% account c
>> Creating/retrieving next account from wallet
Created/retrieved account #3 address 7925e72cad9c6e2b367c6afdc49d861314a009b9426f5abd67ea5b25425dc2c2
libra% account c
>> Creating/retrieving next account from wallet
Created/retrieved account #4 address 0918d1563eb137921cb71da2d4e6791420de73d1b2a9d6b493d60fbc6a38c336
libra%

Type
libra% account list

libra% account list
User account index: 0, address: 5fc38b07e5ac0c2d8871f7789fd93a9437bade24207eef555e042a2f8fcaefba, sequence number: 0, status: Local
User account index: 1, address: 6f6a2ddf62b423b1d0df7662006d68ae90903d65e8d4d90c2f0cf43799c1718f, sequence number: 0, status: Local
User account index: 2, address: 5cb60a2a9dca32a057139f37a4b16ed74cff19d2e0d174a16b66a64759dad523, sequence number: 0, status: Local
User account index: 3, address: 7925e72cad9c6e2b367c6afdc49d861314a009b9426f5abd67ea5b25425dc2c2, sequence number: 0, status: Local
User account index: 4, address: 0918d1563eb137921cb71da2d4e6791420de73d1b2a9d6b493d60fbc6a38c336, sequence number: 0, status: Local

and now the most important part of this post

Please subscribe to this blog for more LibraCoin development tutorials!

Step #4 — Give me the $… sorry Libras

libra% account mint 0 100

it will create 100 libras into account 0

What if you want 1000000000000000000000 test libra coins ?

It’s limited (but not clear at the moment). You’ll have to do with smaller numbers

What if I spam mint 999 time ?

Calm down, they already though of people like you so you’ll get a 429 Too Many Requests status code

libra% account mint 0 99900
>> Minting coins
[ERROR] Error minting coins: Failed to query remote faucet server[status=429 Too Many Requests]: “<html><body><h1>429 Too Many Requests</h1>\nYou have sent too many requests in a given amount of time.\n</body></html>\n”

How to query for the balance ?

libra% query balance 0 (so query balance #account_index)

Step #5 — Transfer your $

each account has a sequence number. Everytime you made a transaction the sequence number increases. It’s used as a protection so bad people don’t do bad things.

we need to get the sequence number first so…

libra% query sequence 0

You’ll get 0 returned since you didn’t do any transaction from that account

now run

libra% transfer 0 2 10

  • 0 is the index of #0 index account.
  • 2 is the index of #2 index account.
  • 10 is the number of Libra to transfer from #0 account to #1 account.

now the money from account #0 goes to the validator and into it’s transactions pools, then when it’s his turn to propose a new block your transaction will get written in the blockchain. In our case this should take couple of seconds.

Query the transaction status

libra% query txn_acc_seq 0 0 true

  • the first 0 indicates account index (in our case #0).
  • the second 0 indicates the sequence number (in our case 0)

>> Getting committed transaction by account and sequence number
Committed transaction: SignedTransaction {
raw_txn: RawTransaction {
sender: 5fc38b07e5ac0c2d8871f7789fd93a9437bade24207eef555e042a2f8fcaefba,
sequence_number: 0,
payload: {,
transaction: peer_to_peer_transaction,
args: [
{ADDRESS: 5cb60a2a9dca32a057139f37a4b16ed74cff19d2e0d174a16b66a64759dad523},
{U64: 10000000},
]
},
max_gas_amount: 10000,
gas_unit_price: 0,
expiration_time: 1560871320s,
},
public_key: dc7ba96f6ed65082fe3b3ea7ec3f4113c43969ff3079e1757f1f884493c484ca,
signature: Signature( R: CompressedEdwardsY: [111, 168, 86, 201, 219, 223, 116, 244, 80, 101, 232, 1, 2, 96, 218, 177, 119, 134, 216, 241, 233, 85, 67, 226, 252, 44, 13, 244, 232, 231, 85, 8], s: Scalar{
bytes: [253, 240, 143, 203, 178, 215, 189, 56, 85, 81, 133, 174, 9, 164, 80, 125, 91, 77, 75, 178, 178, 123, 76, 80, 98, 77, 164, 252, 208, 58, 15, 4],
} ),
}
Events:
ContractEvent { access_path: AccessPath { address: 5fc38b07e5ac0c2d8871f7789fd93a9437bade24207eef555e042a2f8fcaefba, type: Resource, hash: “217da6c6b3e19f1825cfb2676daecce3bf3de03cf26647c78df00b371b25cc97”, suffix: “/sent_events_count/” } , index: 0, event_data: AccountEvent { account: 5cb60a2a9dca32a057139f37a4b16ed74cff19d2e0d174a16b66a64759dad523, amount: 10000000 } }
ContractEvent { access_path: AccessPath { address: 5cb60a2a9dca32a057139f37a4b16ed74cff19d2e0d174a16b66a64759dad523, type: Resource, hash: “217da6c6b3e19f1825cfb2676daecce3bf3de03cf26647c78df00b371b25cc97”, suffix: “/received_events_count/” } , index: 0, event_data: AccountEvent { account: 5fc38b07e5ac0c2d8871f7789fd93a9437bade24207eef555e042a2f8fcaefba, amount: 10000000 } }
libra%

you can query the balance now for each account

%libra query balance #account_number

Congratulations you did it!

You can continue to read more about the Lifecycle of a transaction in Libra here https://developers.libra.org/docs/life-of-a-transaction

Remember to click the Clap button! For more Libra tutorials, please subscribe to my blog!

Andy Octavian

Written by

Crypto / Security… mostly