@binance/w3w-multichain-connector

中文文档
1.0.22发布于 2026/11/03ISCTypeScriptES Module近 30 天下载 2083

Binance 钱包的多链连接器

中文使用文档
文档目录21 节
  1. 安装
  2. 使用量
  3. 导入
  4. 获取钱包实例
  5. 检查扩展已安装
  6. 检查扩展特性支持
  7. 连接钱包
  8. 连接 SAS
  9. 检查已连接的钱包
  10. 获取钱包信息
  11. 切换链
  12. 断开连接
  13. 签名顺序
  14. 自动签名
  15. SAS业务
  16. 处理事件
  17. 属性
  18. 类型
  19. IConnectedWallet
  20. WalletType
  21. Features

@ binance/w3w-多链连接器

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

安装

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

使用量

导入

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

获取钱包实例

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

检查扩展已安装

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

const isInstalled = checkExtensionInstalled()

检查扩展特性支持

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

const isSupported = checkExtensionSupported(Features.requestConnect)

连接钱包

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

连接 SAS

// 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'
})

检查已连接的钱包

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

获取钱包信息

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

切换链

await wallet.switchChain('56')

断开连接

// Disconnect all wallets
await wallet.disconnect()

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

签名顺序

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

自动签名

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

SAS业务

// Enable SAS
const { aggreeEnableSAS } = await wallet.requestEnableSAS({
  walletId: 'wallet-id',
  userId: 'user-id',
  userEmail: '[email protected]'
})

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

// 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'
})

处理事件

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)
})

属性

财产类型说明
versionstring当前扩展版本
autoSignEnabledboolean是否启用自动标志
walletLockedboolean钱包是否锁定
extensionIdstring扩展独有标识符

类型

IConnectedWallet

外地类型说明
walletIconstring钱包图标 (Base64)
walletNamestring钱包名称
walletIdstring钱包独有的标识符
walletTypeWalletType钱包类型( 私人 Key / 种子词组)
addressListArray<{ 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 共发布 21 个版本,首次发布于 2025/09/01;过去 12 个月发布了 9 个版本。

版本发布日期距今
1.0.22latest2026/11/034 天前
1.0.212026/11/035 天前
1.0.202026/10/309 天前
1.0.192026/03/207 个月前
1.0.182026/03/137 个月前
1.0.172026/03/127 个月前

关于 @binance/w3w-multichain-connector 的常见问题

@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 和提交记录判断。