webauthnGasEstimator
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().
Example
import {
const webauthnGasEstimator: (gasEstimator?: ClientMiddlewareFn) => ClientMiddlewareFnA 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().
webauthnGasEstimator,
function createSmartAccountClient<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>): SmartAccountClient<TTransport, TChain, TAccount>createSmartAccountClient,
type type SmartAccountClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, actions extends Record<string, unknown> = Record<...>, rpcSchema extends RpcSchema = [...], context extends UserOperationContext | undefined = UserOperationContext | undefined> = { [K in keyof Client<transport, chain, account, rpcSchema, actions & {
buildUserOperation: (args: BuildUserOperationParameters<account, context>) => Promise<UserOperationStruct<GetEntryPointFromAccount<account, SmartContractAccount<string, keyof EntryPointRegistryBase<unknown>>>>>;
buildUserOperationFromTx: (args: SendTransactionParameters<chain, account>, overrides?: UserOperationOverrides<...> | undefined, context?: context | undefined) => Promise<...>;
... 10 more ...;
signTypedData: <const TTypedData extends {
...;
} | {
...;
}, TPrimaryType extends string = string>(args: SignTypedDataParameters<...>) => Promise<Hex>;
} & (IsUndefined<...> extends false ? {
...;
} : {
...;
}) & BundlerActions & PublicActions>]: Client<...>[K]; }SmartAccountClient,
} from "@aa-sdk/core";
import {
function createModularAccountV2<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner<any>>(config: CreateModularAccountV2Params<TTransport, TSigner>): Promise<ModularAccountV2<TSigner>> (+1 overload)createModularAccountV2,
type type CreateModularAccountV2ClientParams<TTransport extends Transport | AlchemyTransport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner<any>> = CreateModularAccountV2Params<TTransport, TSigner> & Omit<TTransport extends AlchemyTransport ? AlchemySmartAccountClientConfig<TChain> : {
type?: string | undefined | undefined;
cacheTime?: number | undefined | undefined;
chain?: Chain | TChain | undefined;
key?: string | undefined | undefined;
name?: string | undefined | undefined;
pollingInterval?: number | undefined | undefined;
transport: TTransport;
account?: SmartContractAccount | undefined;
... 8 more ...;
signUserOperation?: ClientMiddlewareFn<...> | undefined;
}, "chain" | ... 1 more ... | "account">CreateModularAccountV2ClientParams,
} from "@account-kit/smart-contracts";
const const credential: {
id: string;
publicKey: string;
}credential = {
id: stringid: "credential-id",
publicKey: stringpublicKey: "0x...",
};
async function function createWebauthnAccountClient(config: CreateModularAccountV2ClientParams): Promise<SmartAccountClient>createWebauthnAccountClient(
config: CreateModularAccountV2ClientParamsconfig: type CreateModularAccountV2ClientParams<TTransport extends Transport | AlchemyTransport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner<any>> = CreateModularAccountV2Params<TTransport, TSigner> & Omit<TTransport extends AlchemyTransport ? AlchemySmartAccountClientConfig<TChain> : {
type?: string | undefined | undefined;
cacheTime?: number | undefined | undefined;
chain?: Chain | TChain | undefined;
key?: string | undefined | undefined;
name?: string | undefined | undefined;
pollingInterval?: number | undefined | undefined;
transport: TTransport;
account?: SmartContractAccount | undefined;
... 8 more ...;
signUserOperation?: ClientMiddlewareFn<...> | undefined;
}, "chain" | ... 1 more ... | "account">CreateModularAccountV2ClientParams,
): interface Promise<T>Represents the completion of an asynchronous operation
Promise<type SmartAccountClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, actions extends Record<string, unknown> = Record<...>, rpcSchema extends RpcSchema = [...], context extends UserOperationContext | undefined = UserOperationContext | undefined> = { [K in keyof Client<transport, chain, account, rpcSchema, actions & {
buildUserOperation: (args: BuildUserOperationParameters<account, context>) => Promise<UserOperationStruct<GetEntryPointFromAccount<account, SmartContractAccount<string, keyof EntryPointRegistryBase<unknown>>>>>;
buildUserOperationFromTx: (args: SendTransactionParameters<chain, account>, overrides?: UserOperationOverrides<...> | undefined, context?: context | undefined) => Promise<...>;
... 10 more ...;
signTypedData: <const TTypedData extends {
...;
} | {
...;
}, TPrimaryType extends string = string>(args: SignTypedDataParameters<...>) => Promise<Hex>;
} & (IsUndefined<...> extends false ? {
...;
} : {
...;
}) & BundlerActions & PublicActions>]: Client<...>[K]; }SmartAccountClient> {
const const webauthnAccount: ModularAccountV2<SmartAccountSigner<any>>webauthnAccount = await createModularAccountV2<Transport, SmartAccountSigner<any>>(config: CreateModularAccountV2Params<Transport, SmartAccountSigner<any>>): Promise<ModularAccountV2<SmartAccountSigner<any>>> (+1 overload)createModularAccountV2({
...config: CreateModularAccountV2ClientParamsconfig,
mode: "webauthn"mode: "webauthn",
credential: {
id: string;
publicKey: string;
}credential,
});
return createSmartAccountClient<Transport, Chain, any, UserOperationContext | undefined>(config: {
type?: string | undefined | undefined;
cacheTime?: number | undefined | undefined;
chain?: Chain | undefined;
key?: string | undefined | undefined;
name?: string | undefined | undefined;
pollingInterval?: number | undefined | undefined;
transport: Transport;
account?: any;
opts?: input<typeof SmartAccountClientOptsSchema> | undefined;
addBreadCrumb?: (<T>(crumb: string) => T) | undefined;
dummyPaymasterAndData?: ClientMiddlewareFn<UserOperationContext | undefined> | undefined;
... 5 more ...;
signUserOperation?: ClientMiddlewareFn<...> | undefined;
}): {
...;
}createSmartAccountClient({
account?: anyaccount: anywebAuthnAccount,
gasEstimator?: ClientMiddlewareFn<UserOperationContext | undefined> | undefinedgasEstimator: function webauthnGasEstimator(gasEstimator?: ClientMiddlewareFn): ClientMiddlewareFnA 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().
webauthnGasEstimator(config: CreateModularAccountV2ClientParamsconfig.gasEstimator?: ClientMiddlewareFn<UserOperationContext | undefined> | undefinedgasEstimator),
...config: CreateModularAccountV2ClientParamsconfig,
});
}Parameters
Returns
ClientMiddlewareFn
A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.