@binance-chain/javascript-sdk

中文文档
4.2.2发布于 2023/12/01Apache-2.0TypeScriptCommonJS近 30 天下载 8319

The BNB Beacon Chain JavaScript SDK allows browsers and Node.js clients to interact with BNB Beacon Chain. It includes the following core components.

原始使用文档
文档目录5 节
  1. Installation
  2. Prerequisites
  3. Use with Webpack
  4. Testing
  5. Contributing

The BNB Beacon Chain JavaScript SDK allows browsers and Node.js clients to interact with BNB Beacon Chain. It includes the following core components.

  • crypto - core cryptographic functions.
  • amino - amino (protobuf-like) encoding and decoding of transactions.
  • client - implementations of BNB Beacon Chain transaction types, such as for transfers and trading.
  • accounts - management of "accounts" and wallets, including seed and encrypted mnemonic generation.
  • ledger - Ledger Nano S/X support via HID, U2F and Web BLE (Bluetooth).
  • rpc - Node RPC client.
  • transaction - Transaction Class, build and sign.

You can find more detailed documentation and examples in our Documentation pages.

Installation

If you do not need Ledger support with Node.js:

$ npm i @binance-chain/javascript-sdk --no-optional
# Or:
$ yarn add @binance-chain/javascript-sdk --no-optional

If you need Ledger support with Node.js:

$ npm i @binance-chain/javascript-sdk
# Or:
$ yarn add @binance-chain/javascript-sdk

Prerequisites

  • Windows users: Please install windows-build-tools first.

  • Mac users: Make sure XCode Command Line Tools are installed: xcode-select --install.

  • Linux users: Note that Ubuntu Xenial and newer distributions are recommended, especially when using Travis or other CI systems. You may need some dev packages to be installed on your system for USB support. On Debian-based distributions (like Ubuntu) you should install them with this command:

    $ sudo apt-get install libudev-dev libusb-dev usbutils
    

Use with Webpack

We often see Webpack builds failing with the SDK due to the usb dependency, but adding this to your Webpack config should fix that:

module.exports = {
  plugins: [new webpack.IgnorePlugin(/^usb$/)],
}

Testing

All new code changes should be covered with unit tests. You can run the tests with the following command:

$ yarn test

Tests for the Ledger hardware wallet integration have their own suite that runs in both node and in the browser:

$ yarn test:ledger
$ yarn test:ledger:browser

Contributing

Contributions to the BNB Beacon Chain JavaScript SDK are welcome. Please ensure that you have tested the changes with a local client and have added unit test coverage for your code.

版本与发布记录

@binance-chain/javascript-sdk 共发布 63 个版本,首次发布于 2019/02/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
4.2.2latest2023/12/012 年前
4.2.12023/07/053 年前
4.2.02021/08/285 年前
4.1.12020/08/266 年前
4.1.02020/08/056 年前
4.0.52020/07/156 年前

其他发布通道:alpha → 3.0.2-alpha.11。

关于 @binance-chain/javascript-sdk 的常见问题

@binance-chain/javascript-sdk 是什么?

The BNB Beacon Chain JavaScript SDK allows browsers and Node.js clients to interact with BNB Beacon Chain. It includes the following core components.

如何安装 @binance-chain/javascript-sdk?

在项目目录运行 npm install @binance-chain/javascript-sdk,或使用 pnpm add / yarn add / bun add。

@binance-chain/javascript-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@binance-chain/javascript-sdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@binance-chain/javascript-sdk 可以商用吗?

@binance-chain/javascript-sdk 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@binance-chain/javascript-sdk 的下载量有多少?

根据 npm 官方下载统计,@binance-chain/javascript-sdk 在 2026/10/08 – 2026/11/06 这 30 天内被下载 8,319 次,日均约 277 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@binance-chain/javascript-sdk 还在维护吗?

最新版本 4.2.2 发布于 2023/12/01(2 年前);至今共发布 63 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/02/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。