{"id":13779863,"url":"https://github.com/perfectmak/libra-core","last_synced_at":"2025-04-09T21:15:51.194Z","repository":{"id":34977401,"uuid":"193560131","full_name":"perfectmak/libra-core","owner":"perfectmak","description":"A javascript client for libra built with typescript","archived":false,"fork":false,"pushed_at":"2023-01-04T00:59:50.000Z","size":1436,"stargazers_count":135,"open_issues_count":31,"forks_count":31,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-09T21:15:44.111Z","etag":null,"topics":["javascript","libra","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/libra-core","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/perfectmak.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-24T18:41:48.000Z","updated_at":"2025-02-19T06:29:06.000Z","dependencies_parsed_at":"2023-01-15T11:20:17.112Z","dependency_job_id":null,"html_url":"https://github.com/perfectmak/libra-core","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perfectmak%2Flibra-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perfectmak%2Flibra-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perfectmak%2Flibra-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perfectmak%2Flibra-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perfectmak","download_url":"https://codeload.github.com/perfectmak/libra-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248111973,"owners_count":21049578,"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":["javascript","libra","nodejs","typescript"],"created_at":"2024-08-03T18:01:10.005Z","updated_at":"2025-04-09T21:15:51.169Z","avatar_url":"https://github.com/perfectmak.png","language":"TypeScript","funding_links":[],"categories":["JavaScript","Testnet"],"sub_categories":["Libraries"],"readme":"[![Build Status](https://travis-ci.org/perfectmak/libra-core.svg?branch=master)](https://travis-ci.org/perfectmak/libra-core)\n\n\u003e NOTE: This library is currently not being maintained. This is because of my current busy schedule and Libra not being stable and having a lot of breaking changes occurring. I'll resume maintaining and updating it when Libra becomes more stable. In the meantime, you can use some of the other libraries like [Kulap libra](https://github.com/kulapio/libra-core#readme). Thank you ❣️\n\n# Libra Core \n\nLibra Core is a javascript library client that can be used to interact with libra nodes. It is built using typescript.\n\n\u003e This is still under heavy testing, so please report any issues that you might encounter using it.\n\nThe end goal is to make it usable both in node and on browser clients too, but currently it is mostly compatible with node.\n\n## Table of Content\n\n\u003c!-- toc --\u003e\n\n- [Prepare](#prepare)\n- [Installation](#installation)\n- [Usage](#usage)\n  * [Creating an Account](#creating-an-account)\n  * [Minting Amount](#minting-amount)\n  * [Checking an address balance](#checking-an-address-balance)\n  * [Transferring Libra Coins](#transferring-libra-coins)\n  * [Executing Transactions with Custom Program](#executing-transactions-with-custom-program)\n  * [Query Transaction with Sequence Number](#query-transaction-with-sequence-number)\n- [Development](#development)\n- [Contribution](#contribution)\n- [License](#license)\n\n\u003c!-- tocstop --\u003e\n\n## Prepare\n- Node ^v12.0.0 is required for sha3-256.\nYou can use nvm to download/use node v12 by following.\n```sh\nnvm install 12\nnvm use 12\n```\n\n## Installation\nTo install with npm run:\n\n```\nnpm install libra-core\n```\n\n## Usage\n\nYou would most likely interact with these two modules\n\n```javascript\nimport { LibraWallet, LibraClient } from 'libra-core';\n```\n\n### Creating an Account\n\nIn order to create a libra account, you would need to instantiate the `LibraWallet` like:\n\n```javascript\n// you may need to use require for node\nimport { LibraWallet, Account as LibraAccount } from 'libra-core';\n\n// please don't use this mnemonic outside of this sample code\n// also mnemonics are optional. If you don't specify one a random mnemonic is generated and used.\nconst wallet = new LibraWallet({\n        mnemonic: 'upgrade salt toy stable drop paddle'\n      });\n\n// generate a new account\nconst account = wallet.newAccount();\n\n// or if you have your secret key you can create an account from it\n// const secretKey = 'pub-hex-secret-key-here' \n// const account = LibraAccount.fromSecretKey(secretKey);\n\n\n// you can see your address by:\nconsole.log(account.getAddress().toHex());\n```\n\n### Minting Amount\n\u003e Currently minting only works for testnet and uses the faucet service.\n\nTo mint you need to create a `LibraClient` and use it to mint\n\n```javascript\nimport { LibraClient, LibraNetwork } from 'libra-core';\n\nasync function main() {\n  const client = new LibraClient({ network: LibraNetwork.Testnet });\n\n  const account = wallet.newAccount();\n\n  // mint 2 libracoins to users accounts\n  await client.mintWithFaucetService(account.getAddress(), 20e6);\n}\n\nawait main();\n\n```\n\n### Checking an address balance\n\n```javascript\nasync function main() {\n  const client = new LibraClient({ network: LibraNetwork.Testnet });\n\n  const accountAddress = '854563c50d20788fb6c11fac1010b553d722edb0c02f87c2edbdd3923726d13f';\n  const accountState = await client.getAccountState(accountAddress);\n\n  // log account balance\n  console.log(accountState.balance.toString());\n\n  // Account state has other information that you could be interested in such as `sequenceNumber`.\n}\n\nawait main();\n```\n\n### Transferring Libra Coins\n\n```javascript\nasync function main() {\n  const client = new LibraClient({ network: LibraNetwork.Testnet });\n  const wallet = new LibraWallet({\n    mnemonic:\n     'lend arm arm addict trust release grid unlock exhibit surround deliver front link bean night dry tuna pledge expect net ankle process mammal great',\n\n  });\n  const account = wallet.newAccount();\n  const account2Address = '854563c50d20788fb6c11fac1010b553d722edb0c02f87c2edbdd3923726d13f';\n  const response = await client.transferCoins(account, account2Address, 1e6);\n\n  // wait for transaction confirmation\n  await response.awaitConfirmation(client);\n}\n\nawait main();\n```\n\n### Executing Transactions with Custom Program\nYou can execute a program using `client.execute()` take a look at how `client.transferCoins()` uses it for transfer transactions.\nYou are welcome to help contribute to making this documentation better.\n\n### Query Transaction with Sequence Number\n```javascript\nasync function main() {\n  const client = new LibraClient({ network: LibraNetwork.Testnet });\n  const accountAddress = '7f58df27522872ecfac340c5c072427e6f8083ca3c79bb748cdd1ae073dacc42';\n  const sequenceNumber = 43; //can also use a string for really large sequence numbers;\n\n  const transaction = await client.getAccountTransaction(accountAddress, sequenceNumber);\n}\n\nawait main();\n```\n\n## Development\n- Clone the repository\n- Run `npm install` to install the dependency\n- Test with `npm test`\n- You might need to run `npm install -g grpc-tools` if you want to regenerate protobuffer classes\n\n## Contribution\n- If you notices a bug or anomaly, please open an issue to track it.\n- If you intend on working on a feature that doesn't have an issue yet. Please open an issue first so we can track its progress together.\n\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperfectmak%2Flibra-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperfectmak%2Flibra-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperfectmak%2Flibra-core/lists"}