Skip to main content


Hook for preparing a UserOp to be sent via useSendUserOperation for smart accounts.

It automates the generation of calldata and fetches essential parameters like paymaster data and estimated gas fees for smart account transactions.

import { usePrepareUserOperation } from 'moonchute';


import { usePrepareUserOperation, useSendUserOperation } from 'moonchute';

function PrepareUserOperationComponent() {
const { config, error } = usePrepareUserOperation({
address: '0xContractAddress',
abi: contractAbi,
functionName: 'mint',
const { write } = useSendUserOperation(config);

return (
<button disabled={!write} onClick={() => write?.()}>
Send UserOp
{error && (
An error occurred preparing the user operation: {error.message}

Return Value

userOpHash: Hex,
userOp: PrepareUserOperationResult,
chainId: number,
accountType: number,


sender: Hex,
nonce: Hex,
initCode: Hex,
callData: Hex,
callGasLimit: number,
verificationGasLimit: number,
preVerificationGas: number,
maxFeePerGas: Hex,
maxPriorityFeePerGas: Hex,
paymasterAndData: Hex,
signature: Hex,


address (required)

The contract address to interact with.

abi (required)

The ABI of the contract.

functionName (required)

The function to call on the contract.

args (optional)

Arguments for the function call.

value (optional)

Value to send with the transaction (for payable functions).


This hook automatically integrates with wagmi's useAccount and useNetwork hooks to retrieve the user's account and network details, streamlining the process of preparing transactions in dApp development.