@account-abstraction/sdk

中文文档
0.6.0发布于 2023/05/08MITTypeScriptCommonJS近 30 天下载 4281

This package provides 2 APIs for using UserOperations:

原始使用文档
文档目录4 节
  1. LowLevel API:
  2. BaseWalletAPI
  3. SimpleAccountAPI
  4. High-Level Provider API

SDK to create and send UserOperation

This package provides 2 APIs for using UserOperations:

  • Low-level "walletAPI"
  • High-level Provider

LowLevel API:

BaseWalletAPI

An abstract base-class to create UserOperation for a contract wallet.

SimpleAccountAPI

An implementation of the BaseWalletAPI, for the SimpleWallet sample of account-abstraction.

owner = provider.getSigner()
const walletAPI = new SimpleAccountAPI({
    provider, 
    entryPointAddress,
    owner,
    factoryAddress
})
const op = await walletAPI.createSignedUserOp({
  target: recipient.address,
  data: recipient.interface.encodeFunctionData('something', ['hello'])
})

High-Level Provider API

A simplified mode that doesn't require a different wallet extension. Instead, the current provider's account is used as wallet owner by calling its "Sign Message" operation.

This can only work for wallets that use an EIP-191 ("Ethereum Signed Message") signature (like our sample SimpleWallet) Also, the UX is not great (the user is asked to sign a hash, and even the wallet address is not mentioned, only the signer)

import { wrapProvider } from '@account-abstraction/sdk'

//use this account as wallet-owner (which will be used to sign the requests)
const aaSigner = provider.getSigner()
const config = {
  chainId: await provider.getNetwork().then(net => net.chainId),
  entryPointAddress,
  bundlerUrl: 'http://localhost:3000/rpc'
} 
const aaProvider = await wrapProvider(provider, config, aaSigner)
const walletAddress = await aaProvider.getSigner().getAddress()

// send some eth to the wallet Address: wallet should have some balance to pay for its own creation, and for calling methods.

const myContract = new Contract(abi, aaProvider)

// this method will get called from the wallet address, through account-abstraction EntryPoint
await myContract.someMethod()

版本与发布记录

@account-abstraction/sdk 共发布 8 个版本,首次发布于 2022/10/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.6.0latest2023/05/083 年前
0.5.02023/02/243 年前
0.4.02022/12/283 年前
0.3.02022/11/283 年前
0.2.32022/10/094 年前
0.2.22022/10/094 年前

关于 @account-abstraction/sdk 的常见问题

@account-abstraction/sdk 是什么?

This package provides 2 APIs for using UserOperations:

如何安装 @account-abstraction/sdk?

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

@account-abstraction/sdk 支持 TypeScript 吗?

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

@account-abstraction/sdk 支持 ESM 还是 CommonJS?

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

@account-abstraction/sdk 可以商用吗?

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

@account-abstraction/sdk 的下载量有多少?

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

@account-abstraction/sdk 还在维护吗?

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