const webauthnGasEstimator: (gasEstimator?) => ClientMiddlewareFn;Defined in: aa-sdk/core/src/middleware/defaults/webauthnGasEstimator.ts:46
A middleware function to estimate the gas usage of a user operation when using a Modular Account V2 WebAuthn 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 {
webauthnGasEstimator,
createSmartAccountClient,
type SmartAccountClient,
} from "@aa-sdk/core";
import {
createModularAccountV2,
type CreateModularAccountV2ClientParams,
} from "@account-kit/smart-contracts";
const credential = {
id: "credential-id",
publicKey: "0x...",
};
async function createWebauthnAccountClient(
config: CreateModularAccountV2ClientParams,
): Promise<SmartAccountClient> {
const webauthnAccount = await createModularAccountV2({
...config,
mode: "webauthn",
credential,
});
return createSmartAccountClient({
account: webAuthnAccount,
gasEstimator: webauthnGasEstimator(config.gasEstimator),
...config,
});
}| Parameter | Type | Description |
|---|---|---|
|
| Optional custom gas estimator function |
ClientMiddlewareFn
A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.