# @binance/w3w-multichain-connector 中文文档

规范地址：https://npmcn.com/package/%40binance/w3w-multichain-connector/

版本：1\.0\.22
npm 元数据更新时间：2026-11-03T13:44:47.786Z
中文译文更新时间：2026-11-08T03:02:36.088Z
软件包许可：ISC

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

原始 npm 页面：https://www.npmjs.com/package/%40binance/w3w-multichain-connector
原文对照：https://npmcn.com/package/%40binance/w3w-multichain-connector/?lang=original

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

- 包体积（解压后）：36.9 kB，10 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：1 个
- 首次发布：2025-09-01T06:53:45.657Z
- 最新版本发布：2026-11-03T13:44:47.564Z
- 近 30 天下载量：2083（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：21（近 12 个月 9 个）

## 中文简介

Binance 钱包的多链连接器

## 安装

```sh
npm install @binance/w3w-multichain-connector
```

也可以使用：`pnpm add @binance/w3w-multichain-connector`、`yarn add @binance/w3w-multichain-connector`、`bun add @binance/w3w-multichain-connector`

## README

# @ binance/w3w-多链连接器

这个 `@binance/w3w-multichain-connector` 软件包为 `Binance Wallet` 扩展多链连接器.

## 安装

```bash
pnpm add @binance/w3w-multichain-connector
# or
npm install @binance/w3w-multichain-connector
```

## 使用量

### 导入

```ts
import { getMultichainWallet } from '@binance/w3w-multichain-connector'
```

### 获取钱包实例

```ts
const wallet = getMultichainWallet()
if (!wallet) {
  console.log('Binance Wallet extension not installed')
}
```

### 检查扩展已安装

```ts
import { checkExtensionInstalled } from '@binance/w3w-multichain-connector'

const isInstalled = checkExtensionInstalled()
```

### 检查扩展特性支持

```ts
import { checkExtensionSupported, Features } from '@binance/w3w-multichain-connector'

const isSupported = checkExtensionSupported(Features.requestConnect)
```

### 连接钱包

```ts
const connectedWallets = await wallet.requestConnect(['56', 'CT_501'])
```

### 连接 SAS

```ts
// Single wallet SAS
const { wallet: connectedWallet, aggreeEnableSAS } = await wallet.requestConnectWithSAS({
  binanceChainIds: ['56'],
  userId: 'user-id',
  enabledWalletInfo: [
    { walletType: 'SEED_PHRASE', chain: 'evm', userPublicKeyHex: '0x...' }
  ]
})

// Multi wallet SAS
const { walletList, enabledWalletIds, connectId } = await wallet.requestConnectWithMultiWalletSAS({
  binanceChainIds: ['56'],
  userId: 'user-id'
})
```

### 检查已连接的钱包

```ts
const wallets = await wallet.checkConnectedWallet()
// The user's active wallet will be the first element in the array
```

### 获取钱包信息

```ts
const walletInfo = await wallet.getWalletInfo('0x...address', '56')
```

### 切换链

```ts
await wallet.switchChain('56')
```

### 断开连接

```ts
// Disconnect all wallets
await wallet.disconnect()

// Disconnect specific accounts
await wallet.disconnectWallets(['account-id-1', 'account-id-2'])
```

### 签名顺序

```ts
const signature = await wallet.signOrder({
  walletId: 'wallet-id',
  walletAddress: '0x...',
  binanceChainId: '56',
  txData: '...',
  feeAmount: '0.001',
  feeAmountLevel: 'Medium', // 'Low' | 'Medium' | 'High' | 'Custom'
  digest: '...',
  digestSign: '...'
})
```

### 自动签名

```ts
await wallet.requestAutoSign()
console.log('Auto sign enabled:', wallet.autoSignEnabled)
```

### SAS业务

```ts
// Enable SAS
const { aggreeEnableSAS } = await wallet.requestEnableSAS({
  walletId: 'wallet-id',
  userId: 'user-id',
  userEmail: 'user@example.com'
})

// Enable multi-wallet SAS
const { enabledWalletIds } = await wallet.requestEnableMultiWalletSAS({
  walletIds: ['wallet-1', 'wallet-2'],
  userId: 'user-id',
  userEmail: 'user@example.com'
})

// Get SAS Keyshare
const keyshares = await wallet.getSASKeyshare({
  walletIds: ['wallet-id'],
  userId: 'user-id',
  spsVersion: '1.0',
  isSilent: false // if true, won't prompt unlock when wallet is locked
})

// Sync SAS Status
await wallet.syncSASStatus({
  userId: 'user-id',
  statusList: [
    { walletId: 'wallet-id', enabled: true }
  ]
})

// Get ProofKey Signature (before placing order)
const { timeStamp, proofKeyPublicKey, timestampSignature } = await wallet.getSASProofKeySignature({
  walletId: 'wallet-id',
  userId: 'user-id'
})

// Get Connected Wallets with ProofKey
const walletsWithProofKey = await wallet.getConnectedWalletAndProofKey({
  userId: 'user-id'
})
```

### 处理事件

```ts
const wallet = getMultichainWallet()

// Wallet lock status changed
wallet.on('walletLockedChanged', (isLocked) => {
  console.log('Wallet locked:', isLocked)
})

// Auto sign status changed
wallet.on('autoSignEnabledChanged', (isEnabled) => {
  console.log('Auto sign enabled:', isEnabled)
})

// Connected wallets changed
wallet.on('connectedWalletsChanged', (connectedWallets) => {
  console.log('Connected wallets:', connectedWallets)
})

// Connected chain changed
wallet.on('connectedChainIdChanged', (binanceChainId) => {
  console.log('Chain changed:', binanceChainId)
})
```

### 属性

| 财产 | 类型 | 说明 |
| --- | --- | --- |
| `version` | `string` | 当前扩展版本 |
| `autoSignEnabled` | `boolean` | 是否启用自动标志 |
| `walletLocked` | `boolean` | 钱包是否锁定 |
| `extensionId` | `string` | 扩展独有标识符 |

## 类型

### `IConnectedWallet`

| 外地 | 类型 | 说明 |
| --- | --- | --- |
| `walletIcon` | `string` | 钱包图标 (Base64) |
| `walletName` | `string` | 钱包名称 |
| `walletId` | `string` | 钱包独有的标识符 |
| `walletType` | `WalletType` | 钱包类型( 私人 Key / 种子词组) |
| `addressList` | `Array<{ address, binanceChainId, publicKeyHex }>` | 钱包地址列表 |
| `groupID?` | `string` | 钱包组 ID |
| `groupName?` | `string` | 钱包组名 |

### `WalletType`

| 数值 | 说明 |
| --- | --- |
| `privateKey` | 私钥钱包 |
| `seedPhrase` (单位:千美元)`hd`(中文(简体) ) | 种子词组( mnemonic) 钱包 |

### `Features`

| 数值 | 说明 |
| --- | --- |
| **连接** |  |
| `requestConnect` | 连接钱包 |
| `requestConnectWithSAS` | 用单钱包连接钱包 SAS |
| `requestConnectWithMultiWalletSAS` | 用多钱包 SAS 连接钱包 |
| `checkConnectedWallet` | 检查连接的钱包 |
| `getWalletInfo` | 通过地址和链条获取钱包信息 |
| `disconnect` | 断开所有钱包 |
| `disconnectWallets` | 断开特定钱包 |
| `switchChain` | 切换链 |
| **萨斯** |  |
| `requestEnableSAS` | 请求启用 SAS( 单个钱包) |
| `requestEnableMultiWalletSAS` | 请求启用 SAS( 多钱包) |
| `getSASKeyshare` | 获取 SAS 密钥共享 |
| `syncSASStatus` | 同步 SAS 状态 |
| `getConnectedWalletAndProofKey` | 与 ProofKey 连接钱包 |
| `getSASProofKeySignature` | 在放置命令前获取 ProfKey 签名 |
| **签名** |  |
| `requestAutoSign` | 请求自动签名 |
| `signOrder` | 签署交易命令 |
| **活动** |  |
| `eventWalletLockedChanged` | 钱包锁状态已更改 |
| `eventAutoSignEnabledChanged` | 自动签名状态已更改 |
| `eventConnectedWalletsChanged` | 已连接的钱包已更改事件 |
| `eventConnectedChainIdChanged` | 连接链已更改事件 |

## 常见问题

### @binance/w3w-multichain-connector 是什么？

Binance 钱包的多链连接器

### 如何安装 @binance/w3w-multichain-connector？

在项目目录运行 npm install @binance/w3w-multichain-connector，或使用 pnpm add / yarn add / bun add。

### @binance/w3w-multichain-connector 支持 TypeScript 吗？

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

### @binance/w3w-multichain-connector 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @binance/w3w-multichain-connector 可以商用吗？

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

### @binance/w3w-multichain-connector 的下载量有多少？

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

### @binance/w3w-multichain-connector 还在维护吗？

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

