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

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

Usage

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

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