{"id":18733143,"url":"https://github.com/bioforestchain/bfmeta-node-sdk","last_synced_at":"2025-04-12T18:31:32.581Z","repository":{"id":52030265,"uuid":"327272823","full_name":"BioforestChain/BFMeta-Node-SDK","owner":"BioforestChain","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-29T08:00:40.000Z","size":234,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-10T04:22:13.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/BioforestChain.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-06T10:11:53.000Z","updated_at":"2024-10-14T10:56:49.000Z","dependencies_parsed_at":"2023-02-19T14:45:20.792Z","dependency_job_id":"c9683432-be7b-4b4b-94ec-e6a6966d05cb","html_url":"https://github.com/BioforestChain/BFMeta-Node-SDK","commit_stats":null,"previous_names":["bioforestchain/bfchainpc-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FBFMeta-Node-SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FBFMeta-Node-SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FBFMeta-Node-SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FBFMeta-Node-SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BioforestChain","download_url":"https://codeload.github.com/BioforestChain/BFMeta-Node-SDK/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248613460,"owners_count":21133519,"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-07T15:08:51.807Z","updated_at":"2025-04-12T18:31:31.760Z","avatar_url":"https://github.com/BioforestChain.png","language":"TypeScript","readme":"# BFMeta-SDK\n\n## 工具介绍\n\n- 本工具支持BFMeta链节点端的接口访问。提供BFMeta链的公私钥对、地址及签名生成工具。\n- 交易buffer数据由连接的节点生成，再由本sdk进行签名后发往节点。\n- 建议自行部署节点达到更好的效果。 https://developer.bfmeta.org/download/\n## Installation - 安装\n\n `$ npm install @bfmeta/node-sdk`\n\n### Requrements - 必要条件\n\n*   npm\n\n*   typescript\n\n## Docs \u0026 Community - 文档 \u0026 社区\n\n- 接口文档参考 https://developer.bfmeta.org/336/overview/\n\n\n## Usage - 用法\n\n```ts\nimport { BFMetaSDK, REQUEST_PROTOCOL} from \"@bfmeta/node-sdk\";\n\n// 也可以再运行目录下建 config/config.json 填入以下内容，new 的时候就不用传参\n\nconst config: BFMetaNodeSDK.ApiConfig = {\n    node: {\n        /**节点 ip, 默认值 [127.0.0.1] */\n        ip: \"127.0.0.1\",\n        /**节点端口号, 默认值 9003 */\n        port: 9003,\n    },\n    //  \"请求超时时间, 单位 ms, 默认 10000\",\n    requestTimeOut: 10000,\n    // \"请求协议, http || websocket, 默认值 websocket\",\n    requestProtocol: REQUEST_PROTOCOL.WEBSOCKET,\n};\n\n// 这里根据本地环境去实现，可参考以下\nimport { CryptoHelper } from \"@bfmeta/node-sdk/build/test/helpers/cryptoHelper\";\nconst cryptoHelper = new CryptoHelper();\nimport { FecthDemo } from \"@bfmeta/node-sdk/build/test/helpers/FecthDemo\";\nconst fecthDemo = new FecthDemo();\nconst bfmetaSDK = new BFMetaSDK(config, { netType: \"testnet\", cryptoHelper }, fecthDemo);\n\n // 根据助记词生成公私钥对\nlet keypair = await bfmetaSDK.bfchainSignUtil.createKeypair(\"your secret\");\n\n// 这是该账户的地址\nconst address = await bfmetaSDK.bfchainSignUtil.getAddressFromPublicKey(keypair.publicKey);\n// 这是该账户的公钥(string)\nconst publicKey = keypair.publicKey.toString(\"hex\");\n// 获取节点最新高度\nconst lastblockResult = await bfmetaSDK.api.basic.getLastBlock();\n// 根据条件获取区块\nconst blockResult = await bfmetaSDK.api.basic.getBlock({});\n// 根据条件获取交易\nconst transactionResult = await bfmetaSDK.api.basic.getTransactions({});\n\nconst createResult = await bfmetaSDK.api.transaction.createTransferAsset({\n    // 转账金额 1 代表最小单位。100000000 = 1 BFMTEST\n    amount: \"100000000000\",\n    // 转移的资产类型，可为空，默认为当前链的主权益\n    assetType: \"BFMTEST\",\n    // 接收地址\n    recipientId: address,\n    // 发起地址的公钥\n    publicKey,\n    // 手续费\n    fee: \"2000\",\n    // 发起高度，需要根据连接节点的高度设置。节点只能处理合法高度内的交易\n    applyBlockHeight: 1,\n    // 失效高度，同发起高度一起使用。 若发起高度为1000，失效高度为10.那么这笔交易只能在 1000~1010的高度内被确认。这两个字段能够约束本笔交易的有效高度区间。此字段的最大值为创世块内共识决定。\n    numberOfEffectiveBlocks: 10\n});\nif (!createResult.success) {\n    throw createResult;\n}\nconst buffer = createResult.result.buffer;\nconst bytes = Buffer.from(buffer, \"base64\");\n// 生成签名\nconst signature = (await bfmetaSDK.bfchainSignUtil.detachedSign(bytes, keypair.secretKey)).toString(\"hex\");\n// 广播交易\nconst broadcastResult = await bfmetaSDK.api.transaction.broadcastTransferAsset({\n    buffer,\n    signature,\n});\nif (!broadcastResult.success) {\n    throw broadcastResult;\n}\n// 将返回交易体，交易体的格式见实际返回类型。\nconsole.log(broadcastResult);\n// 广播交易到节点成功\n```\n\n## Changelog - 更新日志\n-   3.0.21\n    - 优化节点连接池\n-   3.0.14\n    - 修改初始化格式，http模块由外部传入\n-   3.0.13\n    - 完善 README 使用说明\n-   3.0.7\n    - 完善 multiNodes 参数的使用 \n-   3.0.6\n    - 新增支持升级服务的接口\n-   3.0.5\n    - 修改初始化时传入节点的参数格式\n-   3.0.4\n    - 添加 setSignUtil 函数\n-   3.0.2\n    - sdk 初始化参数调整\n-   3.0.1\n    - sdk中提供了 bfchainSignUtil 工具\n-   3.0.0\n    - 重构了本sdk。\n\n## License- 许可\n\n\u003ca rel=\"license\" href=\"https://creativecommons.org/licenses/by-nc-sa/4.0/\"\u003e\u003cimg alt=\"知识共享许可协议\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png\" /\u003e\u003c/a\u003e\u003cbr /\u003e本作品采用 \u003ca rel=\"license\" href=\"https://creativecommons.org/licenses/by-nc-sa/4.0/\"\u003e知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议\u003c/a\u003e 进行许可。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbioforestchain%2Fbfmeta-node-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbioforestchain%2Fbfmeta-node-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbioforestchain%2Fbfmeta-node-sdk/lists"}