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
import { default7702GasEstimator } from "@aa-sdk/core";
Usage
import {
default7702GasEstimator,
default7702UserOpSigner,
createSmartAccountClient,
type SmartAccountClient,
} from "@aa-sdk/core";
import {
createModularAccountV2,
type CreateModularAccountV2ClientParams,
} from "@account-kit/smart-contracts";
async function createSMA7702AccountClient(
config: CreateModularAccountV2ClientParams
): Promise<SmartAccountClient> {
const sma7702Account = await createModularAccountV2({
...config,
mode: "7702",
});
return createSmartAccountClient({
account: sma7702Account,
gasEstimator: default7702GasEstimator(config.gasEstimator),
signUserOperation: default7702UserOpSigner(config.signUserOperation),
...config,
});
}
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.