usePrepareCalls
Defined in: account-kit/react/src/hooks/usePrepareCalls.ts:88
Hook for preparing calls to a smart account.
This hook provides functionality to prepare calls for execution on a smart account. It handles the preparation step of the Account Abstraction flow, but does not support EOA wallets.
Example
import { function usePrepareCalls(params: UsePrepareCallsParams): UsePrepareCallsResultHook for preparing calls to a smart account.
This hook provides functionality to prepare calls for execution on a smart account. It handles the preparation step of the Account Abstraction flow, but does not support EOA wallets.
usePrepareCalls } from "@account-kit/react";
const { const prepareCalls: UseMutateFunction<{
signatureRequest?: {
data: string | {
raw: `0x${string}`;
};
type: "personal_sign";
rawPayload: `0x${string}`;
} | {
data: {
domain?: {
chainId?: number | undefined;
salt?: `0x${string}` | undefined;
name?: string | undefined;
verifyingContract?: `0x${string}` | undefined;
version?: string | undefined;
} | undefined;
types: Record<string, {
type: string;
name: string;
}[]>;
primaryType: string;
message: Record<string, unknown>;
};
type: "eth_signTypedData_v4";
rawPayload: `0x${string}`;
} | undefined;
data: {
sender: `0x${string}`;
nonce: `0x${string}`;
initCode: `0x${string}`;
callData: `0x${string}`;
callGasLimit: `0x${string}`;
verificationGasLimit: `0x${string}`;
preVerificationGas: `0x${string}`;
maxFeePerGas: `0x${string}`;
maxPriorityFeePerGas: `0x${string}`;
paymasterAndData: `0x${string}`;
};
type: "user-operation-v060";
chainId: `0x${string}`;
feePayment: {
sponsored: boolean;
tokenAddress: `0x${string}`;
maxAmount: `0x${string}`;
};
} | {
...;
} | {
...;
} | {
...;
}, Error, {
...;
}, unknown>prepareCalls, const prepareCallsAsync: UseMutateAsyncFunction<{
signatureRequest?: {
data: string | {
raw: `0x${string}`;
};
type: "personal_sign";
rawPayload: `0x${string}`;
} | {
data: {
domain?: {
chainId?: number | undefined;
salt?: `0x${string}` | undefined;
name?: string | undefined;
verifyingContract?: `0x${string}` | undefined;
version?: string | undefined;
} | undefined;
types: Record<string, {
type: string;
name: string;
}[]>;
primaryType: string;
message: Record<string, unknown>;
};
type: "eth_signTypedData_v4";
rawPayload: `0x${string}`;
} | undefined;
data: {
sender: `0x${string}`;
nonce: `0x${string}`;
initCode: `0x${string}`;
callData: `0x${string}`;
callGasLimit: `0x${string}`;
verificationGasLimit: `0x${string}`;
preVerificationGas: `0x${string}`;
maxFeePerGas: `0x${string}`;
maxPriorityFeePerGas: `0x${string}`;
paymasterAndData: `0x${string}`;
};
type: "user-operation-v060";
chainId: `0x${string}`;
feePayment: {
sponsored: boolean;
tokenAddress: `0x${string}`;
maxAmount: `0x${string}`;
};
} | {
...;
} | {
...;
} | {
...;
}, Error, {
...;
}, unknown>prepareCallsAsync, const isPreparingCalls: booleanisPreparingCalls, const error: Error | nullerror } =
function usePrepareCalls(params: UsePrepareCallsParams): UsePrepareCallsResultHook for preparing calls to a smart account.
This hook provides functionality to prepare calls for execution on a smart account. It handles the preparation step of the Account Abstraction flow, but does not support EOA wallets.
usePrepareCalls();
// Prepare calls
await const prepareCallsAsync: (variables: {
capabilities?: {
eip7702Auth?: true | {
account?: `0x${string}` | undefined;
delegation: "ModularAccountV2" | "0x69007702764179f14F51cdce752f4f775d74E139";
} | undefined;
permissions?: {
context: `0x${string}`;
} | {
signature: `0x${string}`;
sessionId: `0x${string}`;
} | undefined;
paymasterService?: (({
policyId: string;
} | {
policyIds: string[];
}) & {
onlyEstimation?: boolean | undefined;
erc20?: {
maxTokenAmount?: `0x${string}` | undefined;
tokenAddress: `0x${string}`;
preOpSettings: {
autoPermit: {
durationSeconds?: `0x${string}` | undefined;
below: `0x${string}`;
amount: `0x${string}`;
};
};
} | {
maxTokenAmount?: `0x${string}` | undefined;
tokenAddress: `0x${string}`;
preOpSettings: {
permitDetails: {
deadline: `0x${string}`;
value: `0x${string}`;
};
};
} | {
maxTokenAmount?: `0x${string}` | undefined;
tokenAddress: `0x${string}`;
postOpSettings: {
autoApprove?: {
below: `0x${string}`;
amount: `0x${string}`;
} | undefined;
};
} | {
maxTokenAmount?: `0x${string}` | undefined;
tokenAddress: `0x${string}`;
} | undefined;
webhookData?: string | undefined;
}) | undefined;
gasParamsOverride?: {
callGasLimit?: `0x${string}` | {
multiplier: number;
} | undefined;
verificationGasLimit?: `0x${string}` | {
multiplier: number;
} | undefined;
preVerificationGas?: `0x${string}` | {
multiplier: number;
} | undefined;
maxFeePerGas?: `0x${string}` | {
multiplier: number;
} | undefined;
maxPriorityFeePerGas?: `0x${string}` | {
multiplier: number;
} | undefined;
paymasterVerificationGasLimit?: `0x${string}` | {
multiplier: number;
} | undefined;
paymasterPostOpGasLimit?: `0x${string}` | {
multiplier: number;
} | undefined;
} | undefined;
nonceOverride?: {
nonceKey: `0x${string}`;
} | undefined;
} | undefined | undefined;
paymasterPermitSignature?: {
data: `0x${string}` | {
s: `0x${string}`;
r: `0x${string}`;
yParity: `0x${string}`;
} | {
s: `0x${string}`;
r: `0x${string}`;
v: `0x${string}`;
};
type: "secp256k1";
} | {
data: `0x${string}` | {
s: `0x${string}`;
r: `0x${string}`;
yParity: `0x${string}`;
} | {
s: `0x${string}`;
r: `0x${string}`;
v: `0x${string}`;
};
type: "ecdsa";
} | undefined | undefined;
calls: {
data?: `0x${string}` | undefined;
value?: `0x${string}` | undefined;
to: `0x${string}`;
}[];
from?: never | undefined;
}, options?: MutateOptions<...> | undefined) => Promise<...>prepareCallsAsync({
calls: {
data?: `0x${string}` | undefined;
value?: `0x${string}` | undefined;
to: `0x${string}`;
}[]calls: [
{
to: `0x${string}`to: "0x...",
data?: `0x${string}` | undefineddata: "0x...",
value?: `0x${string}` | undefinedvalue: "0x0",
},
],
});Parameters
Returns
An object containing:
prepareCalls: Function to prepare calls synchronously (returns void)prepareCallsAsync: Async function to prepare calls (returns Promise)preparedCalls: The result of the last successful call preparationisPreparingCalls: Boolean indicating if calls are currently being preparederror: Error from the last failed call preparation, if any
Description
- This hook only works with smart accounts and does not support EOA wallets
- The hook handles the preparation step of the Account Abstraction flow
- Prepared calls must be signed, then can be used with
useSendPreparedCallsto complete the execution