{"id":13779923,"url":"https://github.com/the729/go-libra","last_synced_at":"2025-10-07T23:31:00.220Z","repository":{"id":57252494,"uuid":"195512023","full_name":"the729/go-libra","owner":"the729","description":"Libra go client library with crypto verifications","archived":false,"fork":false,"pushed_at":"2023-02-25T05:48:24.000Z","size":8110,"stargazers_count":44,"open_issues_count":5,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-17T15:47:22.605Z","etag":null,"topics":["blockchain","cryptography","go","golang","javascript","libra"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/the729.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-07-06T07:38:30.000Z","updated_at":"2024-01-05T15:05:53.000Z","dependencies_parsed_at":"2024-01-15T05:09:51.689Z","dependency_job_id":"ac649e06-dde1-48d6-be0f-75c8a841d7c8","html_url":"https://github.com/the729/go-libra","commit_stats":{"total_commits":154,"total_committers":1,"mean_commits":154.0,"dds":0.0,"last_synced_commit":"30b2b69674b6348ed19888060020beb635e7e6e1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the729%2Fgo-libra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the729%2Fgo-libra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the729%2Fgo-libra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the729%2Fgo-libra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/the729","download_url":"https://codeload.github.com/the729/go-libra/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235661856,"owners_count":19025610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","cryptography","go","golang","javascript","libra"],"created_at":"2024-08-03T18:01:10.598Z","updated_at":"2025-10-07T23:30:54.691Z","avatar_url":"https://github.com/the729.png","language":"Go","funding_links":[],"categories":["Testnet","Go"],"sub_categories":["Libraries"],"readme":"# go-libra\n\n[![Build Status](https://travis-ci.org/the729/go-libra.svg?branch=master)](https://travis-ci.org/the729/go-libra)\n[![codecov](https://codecov.io/gh/the729/go-libra/branch/master/graph/badge.svg)](https://codecov.io/gh/the729/go-libra)\n[![Go Report Card](https://goreportcard.com/badge/github.com/the729/go-libra)](https://goreportcard.com/report/github.com/the729/go-libra)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/15abfbbb81354b7fae9656baa6204002)](https://www.codacy.com/app/the729/go-libra?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=the729/go-libra\u0026amp;utm_campaign=Badge_Grade)\n\nA golang client library for [Libra blockchain](https://github.com/libra/libra). \n\nThanks to [gopherjs](https://gopherjs.github.io/), go-libra is also available as a Javascript client library: [gopherjs-libra](https://www.npmjs.com/package/gopherjs-libra). It works for both NodeJS and browsers. \n\nIt has all cryptographic verification algorithms, including validator-signature-based consensus verification, ledger history accumulator proof, and account state sparse Merkle tree proof, etc. \n\n## Features\n\nCompatible with testnet 2020/4/8 (commit hash [718ace82](https://github.com/libra/libra/commit/718ace82250e7bd64e08d7d61951bfaa8cee9ea4)).\n\n- Data models with all necessary cryptographic verification algorithms\n  - Ledger state: signature-based consensus verification\n  - Ledger consistency verification: detects reset or hard-forks\n  - Transaction info and event: Merkle tree accumulator proof\n  - Transaction list: Merkle tree accumulator proof on a range of transactions\n  - Transaction signature: ed25519 signature\n  - Account state: sparse Merkle tree proof\n  - Events: event list hash based on Merkle tree accumulator\n- RPC functions\n  - Query account states\n  - Make P2P transaction, and wait for ledger inclusion\n  - Query transaction list by ledger version\n  - Query account transaction by sequence number\n  - Query sent or received event list by account\n\n## Installation\n\n```bash\n$ # download the code\n$ go get -u github.com/the729/go-libra\n\n$ # build example client\n$ cd example/cli_client \u0026\u0026 go build\n\n$ # see example/cli_client/README.md\n$ ./cli_client a ls\n```\n\n## Usage\n\nGodoc reference to [client package](https://godoc.org/github.com/the729/go-libra/client) and  [types package](https://godoc.org/github.com/the729/go-libra/types).\n\n### Get account balance, cryptographically proven\n\n```golang\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/the729/go-libra/client\"\n)\n\nconst (\n\tdefaultServer = \"ac.testnet.libra.org:8000\"\n\twaypoint      = \"0:4d4d0feaa9378069f8fcee71980e142273837e108702d8d7f93a8419e2736f3f\"\n)\n\nfunc main() {\n\tc, err := client.New(defaultServer, waypoint)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer c.Close()\n\n\taddrStr := \"42f5745128c05452a0c68272de8042b1\"\n\taddr := client.MustToAddress(addrStr)\n\n\t// provenState is cryptographically proven state of account\n\tprovenState, err := c.QueryAccountState(context.TODO(), addr)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tif provenState.IsNil() {\n\t\tlog.Printf(\"Account %s does not exist at version %d.\", addrStr, provenState.GetVersion())\n\t\treturn\n\t}\n\n\tar, br, err := provenState.GetAccountBlob().GetLibraResources()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Printf(\"Balance: %d\", br.Coin)\n\tlog.Printf(\"Sequence Number: %d\", ar.SequenceNumber)\n\tlog.Printf(\"Authentication key: %v\", hex.EncodeToString(ar.AuthenticationKey))\n}\n```\n\n### Make peer-to-peer transaction\n\n```golang\nlog.Printf(\"Get current account sequence of sender...\")\nseq, err := c.QueryAccountSequenceNumber(context.TODO(), senderAddr)\nif err != nil {\n\tlog.Fatal(err)\n}\nlog.Printf(\"... is %d\", seq)\n\nrawTxn, err := client.NewRawP2PTransaction(\n\tsenderAddr, recvAddr, recvAuthKeyPrefix, seq,\n\tamountMicro, maxGasAmount, gasUnitPrice, expiration,\n)\nif err != nil {\n\tlog.Fatal(err)\n}\n\nlog.Printf(\"Submit transaction...\")\nexpectedSeq, err := c.SubmitRawTransaction(context.TODO(), rawTxn, priKey)\nif err != nil {\n\tlog.Fatal(err)\n}\n\nlog.Printf(\"Waiting until transaction is included in ledger...\")\nerr = c.PollSequenceUntil(context.TODO(), senderAddr, expectedSeq, expiration)\nif err != nil {\n\tlog.Fatal(err)\n}\nlog.Printf(\"done.\")\n```\n\n### Other examples\n\nSeveral examples are included in `example` folder.\n- [cli_client](example/cli_client): A fully functional Libra CLI client\n- [query_account](example/query_account): Query specific account states\n- [query_txn_range](example/query_txn_range): Query a range of transactions\n- [query_txn_by_seq](example/query_txn_by_seq): Query a transaction by specific account and sequence number\n- [p2p_transaction](example/p2p_transaction): Make P2P transaction\n- [NodeJS examples](example/nodejs) based on gopherjs-libra\n- [web_client](example/web_client): a pure front-end libra explorer based on gopherjs-libra. [See it in action](http://pg.wutj.info/web_client/)\n\n## Contributions are welcome\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe729%2Fgo-libra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe729%2Fgo-libra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe729%2Fgo-libra/lists"}