@bitgo/account-lib

中文文档
27.25.11发布于 2026/11/06ISCTypeScriptCommonJS构建来源已验证近 30 天下载 1.2万

BitGo's account library functions

原始使用文档
文档目录10 节
  1. Supported Coins
  2. Core Concepts
  3. TransactionBuilder
  4. Transaction
  5. Offline Availability
  6. Installation
  7. Usage
  8. Instantiation
  9. Transaction Construction and Signing
  10. Developers

BitGo Account Lib

This library is responsible for building and signing transactions for account-based coins (for example, Ethereum, Algorand, EOS, Tron, etc.). Account Lib was developed for BitGo and BitGo's multi-sig wallets, but it can also be used independently, outside of our wallet ecosystem.

Account Lib can be used in an offline environment.

Supported Coins

Below is the list of coins supported by this library -- as well as those that are on the roadmap.

CoinMainnet TickerTestnet TickerSupported In Library
AlograndalgotalgoYes
CELOcelotceloYes
EthereumethtethYes
Ethereum ClassicetctetcYes
RSKrbtctrbtcYes
StellarxlmtxlmNot yet...
TezosxtztxtzYes
TrontrxttrxYes

Core Concepts

TransactionBuilder

The TranssactionBuilder class guides a user through the construction of a transaction. The purpose of the TransactionBuilder is to yield a Transaction object that can broadcast to the network.

Transaction

Transaction objects are JavaScript representations of blockchain transactions that implement protocol specific validation rules. Transactions provide encoding mechanisms that allow them to be validly broadcast to their respective network.

Transaction Types

TransactionBuilder supports the following transaction types:

  • Send: Transfers funds from a wallet.

  • Wallet Initialization: Initializes a wallet's account on the network (e.g., multi-sig contract deployment).

  • Address Initialization: Initializes a wallet's address on the network (e.g., forwarder contract deployment).

  • Account Update: Updates an account on the network (e.g., public key revelation operation for Tezos).

Offline Availability

Account Lib was designed to be used for offline signings in an offline environment.


Installation

Install the library with npm. If you plan on contributing to the project, you may wish to follow different installation instructions outlined in this doc.

$ cd <your_project>
$ npm install @bitgo/account-lib

Usage

Below is an example that demonstrates how the library can be used to build and sign a Tron testnet transaction.

Instantiation

Instantiate the TransactionBuilder for the coin you want to work with:

// Import the package (javascript import)
const accountLib = require('@bitgo/account-lib');
// or import the pacakage using typescript
import * as accountLib from '@bitgo/account-lib';

// Instantiate the Transaction Builder for Tron (testnet)
const txBuilder = accountLib.getBuilder('ttrx');

Transaction Construction and Signing

Use the transaction builder instance (created in the previous step) to sign a transaction:

// Define an unsigned Tron transaction object
const unsignedBuildTransaction = {
  visible: false,
  txID: '80b8b9eaed51c8bba3b49f7f0e7cc5f21ac99a6f3e2893c663b544bf2c695b1d',
  raw_data: {
    contract: [
      {
        parameter: {
          value: {
            amount: 1718,
            owner_address: '41c4530f6bfa902b7398ac773da56106a15af15f92',
            to_address: '4189ffaf9da8c6fae32189b2e6dce228249b1129aa',
          },
          type_url: 'type.googleapis.com/protocol.TransferContract',
        },
        type: 'TransferContract',
      },
    ],
    ref_block_bytes: '90e4',
    ref_block_hash: 'a018bf9892ddb138',
    expiration: 1571811468000,
    timestamp: 1571811410819,
  },
  raw_data_hex:
    '0a0290e42208a018bf9892ddb13840e0c58ebadf2d5a66080112620a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412310a1541c4530f6bfa902b7398ac773da56106a15af15f9212154189ffaf9da8c6fae32189b2e6dce228249b1129aa18b60d7083878bbadf2d',
};

// Use that object to build and sign a transaction
txBuilder.from(unsignedBuildTransaction);
txBuilder.sign({
  key: 'A81B2E0C55A7E2B2E837ZZC437A6397B316536196989A6F09EE49C19AD33590W',
});
const tx = await txBuilder.build();

More examples:

Developers

If you'd like to contribute to this project, see the developer guide for contribution norms and expectations.

There is a near-term goal to move this library toward a plugin-based architecture for coin registration. Until then, PRs adding support for new coins will be put on hold.

版本与发布记录

@bitgo/account-lib 共发布 611 个版本,首次发布于 2019/10/25;过去 12 个月发布了 81 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
27.25.11latest2026/11/062 天前
27.25.102026/11/044 天前
27.25.92026/10/309 天前
27.25.82026/10/2711 天前
27.25.72026/10/2316 天前
27.25.62026/10/2217 天前

其他发布通道:alpha → 2.1.1-alpha.0,hbar → 2.1.1-hbar.0,cspr-testing → 2.10.0-cspr-testing.0,stx-fix → 2.15.1-stx-fix.0,node12 → 2.17.2-node12.2,cr406-hf → 3.0.0-hotfix.0。

关于 @bitgo/account-lib 的常见问题

@bitgo/account-lib 是什么?

BitGo's account library functions

如何安装 @bitgo/account-lib?

在项目目录运行 npm install @bitgo/account-lib,或使用 pnpm add / yarn add / bun add。

@bitgo/account-lib 支持 TypeScript 吗?

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

@bitgo/account-lib 支持 ESM 还是 CommonJS?

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

@bitgo/account-lib 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bitgo/account-lib 可以商用吗?

@bitgo/account-lib 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bitgo/account-lib 的下载量有多少?

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

@bitgo/account-lib 还在维护吗?

最新版本 27.25.11 发布于 2026/11/06(2 天前);至今共发布 611 个版本,其中过去 12 个月发布了 81 个;首次发布于 2019/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。