estimateUserOperationGas
Estimate user operation gas for the user operation without building the full user operation request given the user operation calldata.
Usage
import { smartAccountClient } from "./smartAccountClient";
// build single
const gasEstimate = await smartAccountClient.estimateUserOperationGas({
uo: {
target: TO_ADDRESS,
data: ENCODED_DATA,
value: VALUE, // optional
},
});
console.log(gasEstimate);
/**
* {
* preVerificationGas: BigNumberish;
* verificationGasLimit: BigNumberish;
* callGasLimit: BigNumberish;
* }
*/
Returns
Promise<UserOperationEstimateGasResponse<EntryPointVersion>
The result of the estimate including the callGasLimit
, verificationGasLimit
, preVerificationGas
, and additionally, paymasterVerificationGasLimit
for EntryPointVersion v0.7.0
user operations.
Parameters
SendUserOperationParameters
SendUserOperationParameters
export type SendUserOperationParameters<
TAccount extends SmartContractAccount | undefined,
TContext extends UserOperationContext | undefined =
| UserOperationContext
| undefined,
TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>
> = {
uo: UserOperationCallData | BatchUserOperationCallData;
} & GetAccountParameter<TAccount> &
GetContextParameter<TContext> &
UserOperationOverridesParameter<TEntryPointVersion>;
-
uo:
UserOperationCallData
|BatchUserOperationCallData
UserOperationCallData
export type UserOperationCallData = | { /* the target of the call */ target: Address; /* the data passed to the target */ data: Hex; /* the amount of native token to send to the target (default: 0) */ value?: bigint; } | Hex;
target: Address
- the target of the call (equivalent toto
in a transaction)data: Hex
- can be either0x
or a call data stringvalue?: bigint
- optionally, set the value in wei you want to send to the target
-
overrides?:
UserOperationOverrides
Optional parameter where you can specify override values for maxFeePerGas
, maxPriorityFeePerGas
, callGasLimit
, preVerificationGas
, verificationGasLimit
, paymasterAndData
, or nonceKey
for the user operation request. You can also specify a stateOverride
to be passed into eth_estimateUserOperationGas
during gas estimation.
account?: TAccount extends SmartContractAccount | undefined
When using this action, if the SmartContractAccount
has not been connected to the SmartAccountClient
(e.g. SmartAccountClient
not instantiated with your SmartContractAccount
during createSmartAccountClient
). You can check if the account is connected to the client by checking the account
field of SmartAccountClient
. If the account is not connected, you can specify the SmartContractAccount
instance to use for the function call.