@alchemy/aa-alchemy

中文文档
3.19.0发布于 2024/08/03MITTypeScriptES Module近 30 天下载 6238

adapters for @alchemy/aa-core for interacting with alchemy services

原始使用文档

@alchemy/aa-alchemy

This package contains AlchemySmartAccountClient, an implementation of SmartAccountClient interface defined in aa-core. It also contains middleware for accessing the Alchemy Gas Manager (an ERC-4337 Paymaster) for doing Fee Estimates according to the expectations of the Alchemy Rundler (an ERC-4337 Bundler). You may also find the util methods helpful. This repo is community-maintained and we welcome contributions!

Getting started

If you are already using the @alchemy/aa-core package, you can simply install this package and start using the AlchemySmartAccountClient. If you are not using @alchemy/aa-core yet, you can install it and follow the instructions in the "Getting started" docs to get started.

yarn add @alchemy/aa-alchemy
npm i -s @alchemy/aa-alchemy
pnpm i @alchemy/aa-alchemy

Usage

You can create AlchemySmartAccountClient like so:

import {
  LightSmartContractAccount,
  getDefaultLightAccountFactoryAddress,
} from "@alchemy/aa-accounts";
import { AlchemyProvider } from "@alchemy/aa-alchemy";
import { LocalAccountSigner, type SmartAccountSigner } from "@alchemy/aa-core";
import { sepolia } from "@alchemy/aa-core";

const chain = sepolia;
const PRIVATE_KEY = "0xYourEOAPrivateKey";
const eoaSigner: SmartAccountSigner =
  LocalAccountSigner.privateKeyToAccountSigner(`0x${PRIVATE_KEY}`);

export const provider = new AlchemyProvider({
  apiKey: "ALCHEMY_API_KEY", // replace with your alchemy api key of the Alchemy app associated with the Gas Manager, get yours at https://dashboard.alchemy.com/
  chain,
}).connect(
  (rpcClient) =>
    new LightSmartContractAccount({
      chain,
      signer: eoaSigner,
      factoryAddress: getDefaultLightAccountFactoryAddress(chain),
      rpcClient,
    })
);

版本与发布记录

@alchemy/aa-alchemy 共发布 110 个版本,首次发布于 2023/06/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.19.0latest2024/08/032 年前
3.18.22024/06/052 年前
3.18.12024/06/052 年前
3.18.02024/06/042 年前
3.17.22024/06/012 年前
3.17.12024/06/012 年前

其他发布通道:next → 3.0.0-alpha.13。

关于 @alchemy/aa-alchemy 的常见问题

@alchemy/aa-alchemy 是什么?

adapters for @alchemy/aa-core for interacting with alchemy services

如何安装 @alchemy/aa-alchemy?

在项目目录运行 npm install @alchemy/aa-alchemy,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:viem(2.8.6)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@alchemy/aa-alchemy 支持 TypeScript 吗?

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

@alchemy/aa-alchemy 支持 ESM 还是 CommonJS?

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

@alchemy/aa-alchemy 可以商用吗?

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

@alchemy/aa-alchemy 的下载量有多少?

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

@alchemy/aa-alchemy 还在维护吗?

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