{"id":13733949,"url":"https://github.com/bitshares/bitsharesjs","last_synced_at":"2025-06-21T12:33:39.075Z","repository":{"id":16167508,"uuid":"79460335","full_name":"bitshares/bitsharesjs","owner":"bitshares","description":"JavaScript tools for BitShares Encryption and Serialization","archived":false,"fork":false,"pushed_at":"2025-05-26T01:40:59.000Z","size":12582,"stargazers_count":95,"open_issues_count":9,"forks_count":148,"subscribers_count":18,"default_branch":"develop","last_synced_at":"2025-06-02T18:25:13.362Z","etag":null,"topics":["bitshares","blockchain","javascript","js-library","reactjs"],"latest_commit_sha":null,"homepage":"https://bitsharesjs.bitshares.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitshares.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-01-19T14:18:35.000Z","updated_at":"2025-05-26T01:41:03.000Z","dependencies_parsed_at":"2023-09-22T04:38:00.351Z","dependency_job_id":"2830363a-34fc-4b42-a7b8-4749e73a3fd9","html_url":"https://github.com/bitshares/bitsharesjs","commit_stats":{"total_commits":242,"total_committers":28,"mean_commits":8.642857142857142,"dds":0.6487603305785123,"last_synced_commit":"19073d674434e01f533670975ee2b837e24f3f99"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/bitshares/bitsharesjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitshares%2Fbitsharesjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitshares%2Fbitsharesjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitshares%2Fbitsharesjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitshares%2Fbitsharesjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitshares","download_url":"https://codeload.github.com/bitshares/bitsharesjs/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitshares%2Fbitsharesjs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260318645,"owners_count":22991116,"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":["bitshares","blockchain","javascript","js-library","reactjs"],"created_at":"2024-08-03T03:00:51.221Z","updated_at":"2025-06-21T12:33:34.055Z","avatar_url":"https://github.com/bitshares.png","language":"JavaScript","funding_links":[],"categories":["Libraries"],"sub_categories":["JavaScript Libraries"],"readme":"# BitsharesJS (bitsharesjs)\n\nPure JavaScript Bitshares library for node.js and browsers. Can be used to construct, sign and broadcast transactions in JavaScript, and to easily obtain data from the blockchain via public apis.\n\nMost of this code was written by [jcalfee](https://github.com/jcalfee), my work was mostly just repackaging to a discrete npm package.\n\n[![npm version](https://img.shields.io/npm/v/bitsharesjs.svg?style=flat-square)](https://www.npmjs.com/package/bitsharesjs)\n[![npm downloads](https://img.shields.io/npm/dm/bitsharesjs.svg?style=flat-square)](https://www.npmjs.com/package/bitsharesjs)\n\n## Setup\n\nThis library can be obtained through npm:\n\n```\nnpm install bitsharesjs\n```\n\n## Usage\n\nThree sub-libraries are included: `ECC`, `Chain` and `Serializer`. Generally only the `ECC` and `Chain` libraries need to be used directly.\n\n### Chain\n\nThis library provides utility functions to handle blockchain state as well as a login class that can be used for simple login functionality using a specific key seed.\n\n#### Login\n\nThe login class uses the following format for keys:\n\n```\nkeySeed = accountName + role + password\n```\n\nUsing this seed, private keys are generated for either the default roles `active, owner, memo`, or as specified. A minimum password length of 12 characters is enforced, but an even longer password is recommended. Three methods are provided:\n\n```\ngenerateKeys(account, password, [roles])\ncheckKeys(account, password, auths)\nsignTransaction(tr)\n```\n\nThe auths object should contain the auth arrays from the account object. An example is this:\n\n```\n{\n    active: [\n        [\"GPH5Abm5dCdy3hJ1C5ckXkqUH2Me7dXqi9Y7yjn9ACaiSJ9h8r8mL\", 1]\n    ]\n}\n```\n\nIf checkKeys is successful, you can use signTransaction to sign a TransactionBuilder transaction using the private keys for that account.\n\n#### State container\n\nThe Chain library contains a complete state container called the ChainStore. The ChainStore will automatically configure the `set_subscribe_callback` and handle any incoming state changes appropriately. It uses Immutable.js for storing the state, so all objects are return as immutable objects. It has its own `subscribe` method that can be used to register a callback that will be called whenever a state change happens.\n\nThe ChainStore has several useful methods to retrieve, among other things, objects, assets and accounts using either object ids or asset/account names. These methods are synchronous and will return `undefined` to indicate fetching in progress, and `null` to indicate that the object does not exist.\n\n```\nimport {Apis} from \"bitsharesjs-ws\";\nvar {ChainStore} = require(\"bitsharesjs\");\n\nApis.instance(\"wss://eu.nodes.bitshares.ws\", true).init_promise.then((res) =\u003e {\n    console.log(\"connected to:\", res[0].network);\n    ChainStore.init().then(() =\u003e {\n        ChainStore.subscribe(updateState);\n    });\n});\n\nlet dynamicGlobal = null;\nfunction updateState(object) {\n    dynamicGlobal = ChainStore.getObject(\"2.1.0\");\n    console.log(\"ChainStore object update\\n\", dynamicGlobal ? dynamicGlobal.toJS() : dynamicGlobal);\n}\n```\n\n### ECC\n\nThe ECC library contains all the crypto functions for private and public keys as well as transaction creation/signing.\n\n#### Private keys\n\nAs a quick example, here's how to generate a new private key from a seed (a brainkey for example):\n\n```\nvar {PrivateKey, key} = require(\"bitsharesjs\");\n\nlet seed = \"THIS IS A TERRIBLE BRAINKEY SEED WORD SEQUENCE\";\nlet pkey = PrivateKey.fromSeed( key.normalize_brainKey(seed) );\n\nconsole.log(\"\\nPrivate key:\", pkey.toWif());\nconsole.log(\"Public key :\", pkey.toPublicKey().toString(), \"\\n\");\n```\n\n#### Transactions\n\nTODO transaction signing example\n\n## ESDoc (beta)\n\n```bash\nnpm i -g esdoc esdoc-es7-plugin\nesdoc -c ./esdoc.json\nopen out/esdoc/index.html\n```\n\n## Binaries / Browserified bundles\n\nPlease have a [look here](https://github.com/bitshares/bitsharesjs/releases) to find your desired release.\nIf you want to build the binaries yourself you can clone this repository and run `npm install`. It will\ncreate\n\n-   Browserified version `build/bitsharesjs.js`\n-   Browserified and minified (babel) version `build/bitsharesjs.min.js`\n-   CommonJS version using webpack `build/bitsharesjs.cjs`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitshares%2Fbitsharesjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitshares%2Fbitsharesjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitshares%2Fbitsharesjs/lists"}