# @fireblocks/fireblocks-web3-provider 中文文档

规范地址：https://npmcn.com/package/%40fireblocks/fireblocks-web3-provider/

版本：1\.5\.1
npm 元数据更新时间：2026-11-12T15:11:47.607Z
中文译文更新时间：2026-11-14T19:28:07.827Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40fireblocks/fireblocks-web3-provider
原文对照：https://npmcn.com/package/%40fireblocks/fireblocks-web3-provider/?lang=original
项目主页：https://github.com/fireblocks/fireblocks-web3-provider#readme
源码仓库：https://github.com/fireblocks/fireblocks-web3-provider

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：150 kB，52 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：7 个
- 首次发布：2022-08-06T11:42:01.741Z
- 最新版本发布：2026-11-12T15:11:47.157Z
- 近 30 天下载量：90542（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：49（近 12 个月 4 个）

## 中文简介

EIP-1193 防火墙兼容Ethereum供应商

## 安装

```sh
npm install @fireblocks/fireblocks-web3-provider
```

也可以使用：`pnpm add @fireblocks/fireblocks-web3-provider`、`yarn add @fireblocks/fireblocks-web3-provider`、`bun add @fireblocks/fireblocks-web3-provider`

## README

![accessibility text](https://npmcn.com/package/%40fireblocks/fireblocks-web3-provider/logo.svg)

[![npm version](https://badge.fury.io/js/@fireblocks%2Ffireblocks-web3-provider.svg)](https://badge.fury.io/js/@fireblocks%2Ffireblocks-web3-provider)  
[Web3 提供者文档](https://developers.fireblocks.com/docs/ethereum-development)

# 网络3 提供方

防火墙 [EIP-1193 (英语)](https://eips.ethereum.org/EIPS/eip-1193) 兼容的 Ethereum Java 脚本提供者

## 安装

```bash
npm install @fireblocks/fireblocks-web3-provider
```

## 设置

```js
import { FireblocksWeb3Provider, ChainId, ApiBaseUrl } from "@fireblocks/fireblocks-web3-provider";

const eip1193Provider = new FireblocksWeb3Provider({
    // apiBaseUrl: ApiBaseUrl.Sandbox // If using a sandbox workspace
    privateKey: process.env.FIREBLOCKS_API_PRIVATE_KEY_PATH,
    apiKey: process.env.FIREBLOCKS_API_KEY,
    vaultAccountIds: process.env.FIREBLOCKS_VAULT_ACCOUNT_IDS,
    chainId: ChainId.GOERLI,

    logTransactionStatusChanges: true, // Verbose logging
})
```

### RPC 终点

仅当 `chainId` 被给出,提供者使用一个内置的公共 RPC 端点用于该链.

公共终点是受费率限制的,没有上下班的保证。 为了制作,通过自己的 `rpcUrl` 从一个节点提供者。 A 提供 `rpcUrl` 替换内置终点.

## 使用醚.js

```sh
npm install ethers
```

```js
import * as ethers from "ethers"

const provider = new ethers.BrowserProvider(eip1193Provider); 

// Or like this if you're using ethers v5:
// const provider = new ethers.providers.Web3Provider(eip1193Provider); 
```

## 使用网络3.js

```sh
npm install web3
```

```js
import Web3 from "web3";

const web3 = new Web3(eip1193Provider);
```

## API 文档

### 新建防火墙Web3 提供(配置)

-   `config` [防火墙](https://npmcn.com/package/%40fireblocks/fireblocks-web3-provider/#readme-FireblocksProviderConfig)

这个课是 [EIP-1193 (英语)](https://eips.ethereum.org/EIPS/eip-1193) 兼容的 Ethereum JavaScript 提供商 [防火墙 API](https://docs.fireblocks.com/api/)

### 防火墙

```ts
type FireblocksProviderConfig = {
  // ------------- Mandatory fields -------------
  /** 
   * Learn more about creating API users here: 
   * https://developers.fireblocks.com/docs/quickstart#api-user-creation
   */

  /** 
   * Fireblocks API key
   */
  apiKey: string,

  /** 
   * Fireblocks API private key for signing requests
   */
  privateKey: string,

  // Either chainId or rpcUrl must be provided
  /** 
   * If not provided, it is inferred from the rpcUrl 
   */
  chainId?: ChainId,
  /** 
   * If not provided, it is inferred from the chainId 
   */
  rpcUrl?: string,

  // ------------- Optional fields --------------

  /** 
   * By default, the first 20 vault accounts are dynamically loaded from the Fireblocks API
   * It is recommended to provide the vault account ids explicitly because it helps avoid unnecessary API calls
   */
  vaultAccountIds?: number | number[] | string | string[],
  /** 
   * By default, it uses the Fireblocks API production endpoint
   * When using a sandbox workspace, you should provide the ApiBaseUrl.Sandbox value
   */
  apiBaseUrl?: ApiBaseUrl | string,
  /**
   * By default, the fallback fee level is set to FeeLevel.MEDIUM
   */
  fallbackFeeLevel?: FeeLevel,
  /**
   * By default, the note is set to "Created by Fireblocks Web3 Provider"
   */
  note?: string,
  /**
   * By default, the polling interval is set to 1000ms (1 second)
   * It is the interval in which the Fireblocks API is queried to check the status of transactions
   */
  pollingInterval?: number,
  /**
   * By default, it is assumed that one time addresses are enabled in your workspace
   * If they're not, set this to false
   */
  oneTimeAddressesEnabled?: boolean,
  /**
   * By default, no externalTxId is associated with transactions
   * If you want to set one, you can either provide a function that returns a string, or provide a string directly
   */
  externalTxId?: (() => string) | string,
  /**
   * If you want to prepend an additional product string to the User-Agent header, you can provide it here
   */
  userAgent?: string,
  /**
   * If you are using a private/custom EVM chain, you can provide its Fireblocks assetId here
   */
  assetId?: string,
  /**
   * Default: false
   * By setting to true, every transaction status change will be logged to the console
   * Same as setting env var `DEBUG=fireblocks-web3-provider:status`
   */
  logTransactionStatusChanges?: boolean,
  /**
   * Default: false
   * By setting to true, every request and response processed by the provider will be logged to the console
   * Same as setting env var `DEBUG=fireblocks-web3-provider:req_res`
   */
  logRequestsAndResponses?: boolean,
  /**
   * Default: true
   * By setting to true, every failed transaction will print additional information
   * helpful for debugging, such as a link to simulate the transaction on Tenderly
   * Same as setting env var `DEBUG=fireblocks-web3-provider:error`
   */
  enhancedErrorHandling?: boolean,
  /**
   * Proxy path in the format of `http(s)://user:pass@server`
   */
  proxyPath?: string
}
```

## 常见问题

### @fireblocks/fireblocks-web3-provider 是什么？

EIP-1193 防火墙兼容Ethereum供应商

### 如何安装 @fireblocks/fireblocks-web3-provider？

在项目目录运行 npm install @fireblocks/fireblocks-web3-provider，或使用 pnpm add / yarn add / bun add。

### @fireblocks/fireblocks-web3-provider 支持 TypeScript 吗？

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

### @fireblocks/fireblocks-web3-provider 支持 ESM 还是 CommonJS？

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

### @fireblocks/fireblocks-web3-provider 可以商用吗？

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

### @fireblocks/fireblocks-web3-provider 的下载量有多少？

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

### @fireblocks/fireblocks-web3-provider 还在维护吗？

最新版本 1\.5\.1 发布于 2026/11/12（2 天前）；至今共发布 49 个版本，其中过去 12 个月发布了 4 个；首次发布于 2022/08/06。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

