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<{ type: "array"; data: ({ signatureRequest?: { type: "personal_sign"; data: string | { raw: `0x${string}`; }; rawPayload: `0x${string}`; } | { type: "eth_signTypedData_v4"; data: { domain?: { name?: string | undefined; chainId?: number | undefined; salt?: `0x${string}` | undefined; verifyingContract?: `0x${string}` | undefined; version?: string | undefined; } | undefined; types: { [x: string]: { type: string; name: string; }[]; }; primaryType: string; message: { [x: string]: unknown; }; }; rawPayload: `0x${string}`; } | undefined; type: "user-operation-v060"; chainId: `0x${string}`; data: { sender: `0x${string}`; nonce: `0x${string}`; ... 7 more ...; paymasterAndData: `0x${string}`; }; feePayment: { ...; }; } | { ...; } | { ...; })[]; } | { ...; } | { ...; } | { ...; }, Error, { ...; }, unknown>prepareCalls, const prepareCallsAsync: UseMutateAsyncFunction<{ type: "array"; data: ({ signatureRequest?: { type: "personal_sign"; data: string | { raw: `0x${string}`; }; rawPayload: `0x${string}`; } | { type: "eth_signTypedData_v4"; data: { domain?: { name?: string | undefined; chainId?: number | undefined; salt?: `0x${string}` | undefined; verifyingContract?: `0x${string}` | undefined; version?: string | undefined; } | undefined; types: { [x: string]: { type: string; name: string; }[]; }; primaryType: string; message: { [x: string]: unknown; }; }; rawPayload: `0x${string}`; } | undefined; type: "user-operation-v060"; chainId: `0x${string}`; data: { sender: `0x${string}`; nonce: `0x${string}`; ... 7 more ...; paymasterAndData: `0x${string}`; }; feePayment: { ...; }; } | { ...; } | { ...; })[]; } | { ...; } | { ...; } | { ...; }, 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: { calls: { data?: `0x${string}` | undefined; value?: `0x${string}` | undefined; to: `0x${string}`; }[]; capabilities?: { eip7702Auth?: true | { account?: `0x${string}` | undefined; delegation: "0x69007702764179f14F51cdce752f4f775d74E139" | "ModularAccountV2"; } | undefined; permissions?: { context: `0x${string}`; } | { sessionId: `0x${string}`; signature: `0x${string}`; } | undefined; paymasterService?: (({ policyId: string; } | { policyIds: string[]; }) & { onlyEstimation?: boolean | undefined; erc20?: ({ maxTokenAmount?: `0x${string}` | undefined; tokenAddress: `0x${string}`; } & ({} | { preOpSettings: { ...; } | { ...; }; } | { ...; })) | undefined; }) | undefined; gasParamsOverride?: { ...; } | undefined; nonceOverride?: { ...; } | undefined; } | undefined; paymasterPermitSignature?: { ...; } | ... 1 more ... | undefined; 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
useSendPreparedCalls
to complete the execution