default7702GasEstimator

A middleware function to estimate the gas usage of a user operation when using an EIP-7702 delegated account. Has an optional custom gas estimator. This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in getImplementationAddress().

Import

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

Usage

1import {
2 default7702GasEstimator,
3 default7702UserOpSigner,
4 createSmartAccountClient,
5 type SmartAccountClient,
6} from "@aa-sdk/core";
7import {
8 createModularAccountV2,
9 type CreateModularAccountV2ClientParams,
10} from "@account-kit/smart-contracts";
11
12async function createSMA7702AccountClient(
13 config: CreateModularAccountV2ClientParams
14): Promise<SmartAccountClient> {
15 const sma7702Account = await createModularAccountV2({
16 ...config,
17 mode: "7702",
18 });
19
20 return createSmartAccountClient({
21 account: sma7702Account,
22 gasEstimator: default7702GasEstimator(config.gasEstimator),
23 signUserOperation: default7702UserOpSigner(config.signUserOperation),
24 ...config,
25 });
26}

Parameters

gasEstimator

ClientMiddlewareFn Optional custom gas estimator function

Returns

Function A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.