Skip to content

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

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

Usage

import {
  sepolia,
  alchemy,
  alchemyGasAndPaymasterAndDataMiddleware,
} from "@account-kit/infra";
import { createSmartAccountClient } from "@aa-sdk/core";
 
const client = createSmartAccountClient({
  transport: alchemy({ apiKey: "your-api-key" }),
  chain: sepolia,
  ...alchemyGasAndPaymasterAndDataMiddleware({
    policyId: "policyId",
    transport: alchemy({ apiKey: "your-api-key" }),
  }),
});

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" | "paymasterAndData"> partial client middleware configuration containing dummyPaymasterAndData and paymasterAndData