Skip to content

erc7677Middleware

Middleware function for interacting with ERC-7677 enabled clients. It supports resolving paymaster and data fields for user operations. This middleware assumes that your RPC provider supports the ERC-7677 methods (pm_getPaymasterStubData and pm_getPaymasterData).

Import

import { erc7677Middleware } from "@aa-sdk/core";

Usage

import { createSmartAccountClient, erc7677Middleware } from "@aa-sdk/core";
import { http } from "viem";
import { sepolia } from "viem/chains";
 
const client = createSmartAccountClient({
  transport: http("rpc-url"),
  chain: sepolia,
  // this assumes that your RPC provider supports the ERC-7677 methods AND takes no context
  ...erc7677Middleware(),
});

Parameters

params

Erc7677MiddlewareParams<TContext> Middleware parameters including context function or object. Context can be resolved dynamically by passing in a function which takes in the context at the time of sending a user op

Returns

Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData"> An object containing middleware functions dummyPaymasterAndData and paymasterAndData for processing user operations with the paymaster data