alchemyGasAndPaymasterAndDataMiddleware

Paymaster middleware factory that uses Alchemy’s Gas Manager for sponsoring transactions. Uses Alchemy’s custom alchemy_requestGasAndPaymasterAndData method instead of conforming to the standard ERC-7677 interface. Note that if you use createAlchemySmartAccountClient, this middleware is already used by default and you do not need to manually include it.

Import

1import { alchemyGasAndPaymasterAndDataMiddleware } from "@account-kit/infra";

Usage

1import {
2 sepolia,
3 alchemy,
4 alchemyGasAndPaymasterAndDataMiddleware,
5} from "@account-kit/infra";
6import { createSmartAccountClient } from "@aa-sdk/core";
7
8const client = createSmartAccountClient({
9 transport: alchemy({ apiKey: "your-api-key" }),
10 chain: sepolia,
11 ...alchemyGasAndPaymasterAndDataMiddleware({
12 policyId: "policyId",
13 transport: alchemy({ apiKey: "your-api-key" }),
14 }),
15});

Parameters

params

AlchemyGasAndPaymasterAndDataMiddlewareParams configuration params

params.policyId

AlchemyGasAndPaymasterAndDataMiddlewareParams.policyId the policyId for Alchemy’s gas manager

params.transport

AlchemyGasAndPaymasterAndDataMiddlewareParams.transport fallback transport to use for fee estimation when not using the paymaster

params.gasEstimatorOverride

AlchemyGasAndPaymasterAndDataMiddlewareParams.gasEstimatorOverride custom gas estimator middleware

params.feeEstimatorOverride

AlchemyGasAndPaymasterAndDataMiddlewareParams.feeEstimatorOverride custom fee estimator middleware

Returns

Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "feeEstimator" | "gasEstimator" | "paymasterAndData"> partial client middleware configuration containing dummyPaymasterAndData, feeEstimator, gasEstimator, and paymasterAndData