Announcing libra-client: A CLI inteface Libra client and Python API for Libra blockchain

Hi everyone,

We have just published libra-client, an unofficial client for Libra blockchain written in python language. The project has a cli interface client allows you interact whith Libra Network easily. For Python programmers, you can also call the client side api to interact with Libra Network.


The client is compatible with original rust written libra client.

For python programmers, Please see Client side Libra API for python programmer for more API details.

3 Likes

Very nice, great job, it works well on latest Libra testnet and LCS.

1 Like

Libra-client is updated from version 0.3.x to version 0.4, with following major updates:

  1. add ledger_info and validator_verifier support. We verify the signature in ledger_info_with_sig structure against the validator’s public key.
  2. The get_transactions api now return deserialized SignedTransaction object instead of raw ptoto object.
  3. check connectivity on startup of libra_shell and check port number to be NonZeroU16.
  4. Update canoser library to support pretty print and update the api document.

During the development of libra-client, we found and fixed a few bugs in the libra core. For example, following input will raise an error:

libra% q tr 1 0 true

Getting committed transaction by range
[ERROR] Error getting committed transactions by range: Bad GetTransactions response. Events requested: true, events returned: false.

Here is the fix code:
Fix verify_get_txns_resp when zero txns returned

Other merged commits:

1 Like

Hi,

Just finished to install it after installing python3.6m, pip3. I cannot use the command libra_shell

root@vps8279:~# libra_shell
libra_shell: command not found

EDIT: solved :wink:

1 Like

Hm,

I facing a little connection trouble while attemting to use libra_shell :

Not able to connect to validator at ac.testnet.libra.org:8000

1 Like

Maybe a temporal network problem.

1 Like

Running ./start_cli_testnet.sh works but not libra_shell

1 Like

I see. It’s weird :innocent:

1 Like

Is this exception came from line 33 ?

1 Like

Yes. This line send a blank request message to libra ac to test validate network.

    grpc_client.get_latest_transaction_version()

Add “-v” option, you can see detail message if there are errors.

$ libra_shell -v
1 Like

Still the same error message I inspect libra code source to see what can be the trouble :wink:

1 Like

After reading your code I found you use :

NETWORKS = {
‘testnet’:{
‘host’: “ac.testnet.libra.org”,
‘port’: 8000,
‘faucet_host’: “faucet.testnet.libra.org
}
}

I tried to ping the faucet network but it’s still down do you think it’s the problem ?

1 Like

Only mint coin will use the ‘faucet_host’, try connect ac.testnet.libra.org, for example:

telnet ac.testnet.libra.org 8000
Trying 3.220.97.74…
Connected to ac.testnet.libra.org.
Escape character is ‘^]’.

1 Like

I got the same result as you writte
root@vps8279:~/.local/bin# telnet ac.testnet.libra.org 8000
Trying 3.94.73.110…
Connected to ac.testnet.libra.org.
Escape character is ‘^]’.

1 Like

@ alexandre_jaquet
AFAIK, it seems fine.
image

1 Like

I think I found the reason. Uninstall and then reinstall with following command:

python3 -m pip install --user --no-binary libra-client libra-client

Let me know if it works.:grinning:

1 Like

Well done it work thanks a lot’s ! :slight_smile:

1 Like

Hi,

I’m playing within your client and everything works well,

#!/usr/bin/perl
use warnings;
use MyDB;

my $db = MyDB->new();

main();

sub get_balance {
my $account = shift || ‘’;
system(“libra account balance $account”);
}
sub main {

my ($userID,$acheteurEmail,$compte_libra) = $db->sqlSelect("id_personne,email,compte_libra", "personne", "nom_utilisateur = 'alexandre'");
print "Compte libra Alexandre : $compte_libra\n";
get_balance($compte_libra);

}

2 Likes

Libra-client is updated from version 0.5 to version 0.6, compatible with latest testnet update:

  1. Add Transaction and BlockMetadata class, parse message TransactionListWithProof to Transaction instead of SignedTransaction.
  2. Change epoch_num to epoch of LedgerInfo message.
  3. Disable proof verification Temporarily. There’s a lot of change to libra’s proof code, such as bitmap is remove.
2 Likes

Hi I update libra-client within the following line of code python3.6 -m pip install --user --no-binary libra-client libra-client but now when I call account balance I got :

root@vps8279:/usr/lib/cgi-bin# libra account balance f270b16e2fec7a10937d0c32eec34a9b2280a7ab8a64e75aa8c84e3583158349
{
“balance”: 0
}

but within the same adress within libra explorer https://libexplorer.com/address/f270b16e2fec7a10937d0c32eec34a9b2280a7ab8a64e75aa8c84e3583158349