{"id":18558029,"url":"https://github.com/zh/bcp-ext-js","last_synced_at":"2025-05-15T14:30:55.150Z","repository":{"id":66384489,"uuid":"353650429","full_name":"zh/bcp-ext-js","owner":"zh","description":"BlockChain Payloads (BCP) extensions (classes, NFT etc.) library","archived":false,"fork":false,"pushed_at":"2021-04-14T15:29:50.000Z","size":97,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-17T11:44:36.947Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/zh.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-01T09:46:25.000Z","updated_at":"2023-02-06T18:23:01.000Z","dependencies_parsed_at":"2023-02-24T22:45:54.099Z","dependency_job_id":null,"html_url":"https://github.com/zh/bcp-ext-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh%2Fbcp-ext-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh%2Fbcp-ext-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh%2Fbcp-ext-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zh%2Fbcp-ext-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zh","download_url":"https://codeload.github.com/zh/bcp-ext-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254358551,"owners_count":22057940,"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":[],"created_at":"2024-11-06T21:38:42.866Z","updated_at":"2025-05-15T14:30:55.126Z","avatar_url":"https://github.com/zh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BlockChain Payloads (BCP) Extension Library\n\nBCPs are immutable pointers to digital data, saved on the BCH blockchain.\nThis library is extending the [basic BCP library](https://github.com/zh/bcp-js)\nwith different classes, as:\n - `Parser` class - wrapper around `bcp.js`, adding some transaction parsing\n     methods etc.\n - `API` class for access to SLPDB and BITDB for BCP or NFT tokens info\n - `NFT` - getting information for NFT tokens with attached BCP\n\n## Used libraries and services\n\n* [bignumber.js](https://mikemcl.github.io/bignumber.js/) - A JavaScript library for arbitrary-precision arithmetic\n* [axios](https://github.com/axios/axios) - Promise based HTTP client for the browser and node.js\n* [bcp.js](https://github.com/zh/bcp-js) - Basic BCP protocol and JS library\n\n## Installation\n\n* for *node.js*\n\n```sh\nnpm install bcp-ext-js\n```\n\n* for browser\n\n```html\n\u003cscript src=\"https://unpkg.com/bcp-ext-js\"\u003e\u003c/script\u003e\n```\n\nfor a specific version:\n\n```html\n\u003cscript src=\"https://unpkg.com/bcp-ext-js@1.0.1/dist/bcp-ext.min.js\"\u003e\u003c/script\u003e\n```\n\n## Development\n\nThe easiest way is to download the library sources from the GitHub repository and rebuild them for your project:\n\n```sh\ngit clone https://github.com/zh/bcp-ext-js.git\ncd bcp-ext-js\nnpm install\nnpm run build\n```\n\n## Testing\n\nTODO\n\n```sh\nnpm test\n```\n\n## Usage\n\n### Library instantiation\n\n```js\nconst BCPEXT = require('bcp-ext-js')\nconst bcpjs = new BCPEXT()\n```\n\n### Get BCP from Transaction ID\n\n```js\nconst txid = 'bddb26bb00ef94a8a43361622dd3c4743386b9da01d702ed921fdf9bd4be4860'\nconst bcp = await bcpjs.API.getBCP(txid)\nconsole.log(`bcp: ${JSON.stringify(bcp, null, 2)}`)\nconsole.log(`type: ${bcpjs.Parser.typeStr(bcp)}`)\nconsole.log(`source: ${bcpjs.Parser.dataStr(bcp)}`)\n\n...\ntype: audio\nsource: QmZmqLskJmghru919cvU4qSy3L5vc1S2JdzsUXrM17ZqT9\n```\n\n### Get info for NFT token with attached BCP\n\n```js\nconst tokenId = 'adb0fbd80404c5fcb5495e676fb16f71dc290554787f9baf5b87aa3831a3259b'\nconst token = await bcpjs.NFT.getTokenInfo(tokenId)\n\nconsole.log(`token: ${JSON.stringify(token, null, 2)}`)\n\n...\ntoken: {\n  \"id\": \"adb0fbd80404c5fcb5495e676fb16f71dc290554787f9baf5b87aa3831a3259b\",\n  \"type\": 65,\n  \"name\": \"Audio NFT\",\n  \"symbol\": \"BCP.AUDIO.RAIN\",\n  ...\n  \"bcp\": {\n    \"id\": \"bddb26bb00ef94a8a43361622dd3c4743386b9da01d702ed921fdf9bd4be4860\",\n    \"type\": \"audio\",\n    \"source\": \"QmZmqLskJmghru919cvU4qSy3L5vc1S2JdzsUXrM17ZqT9\",\n    \"ipfs\": true\n  }\n...\n```\n\nYou can see more usage examples in the [examples directory](examples/).\n\n## Donations\n\nEvery amount of BCH will help the future development\n\n* BCH: `bitcoincash:qq3t709lskk7tpg5nl8xdfvu8rx4v66ys5cwlxw3ac`\n\n![BCH address](https://gateway.pinata.cloud/ipfs/QmPz1Knaxj5UhJ4jrQjpr6LK9uA5em26NVmC2eX7W4D29D)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzh%2Fbcp-ext-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzh%2Fbcp-ext-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzh%2Fbcp-ext-js/lists"}