Skip to content

useWaitForUserOperationTransaction

Custom hook to wait for a user operation transaction and manage its state (pending, error, result).

Import

import { useWaitForUserOperationTransaction } from "@account-kit/react";

Usage

import {
  useWaitForUserOperationTransaction,
  useSmartAccountClient,
} from "@account-kit/react";
 
const { client } = useSmartAccountClient({ type: "LightAccount" });
const {
  waitForUserOperationTransaction,
  waitForUserOperationTransactionResult,
  isWaitingForUserOperationTransaction,
  error,
} = useWaitForUserOperationTransaction({
  client,
  // these are optional
  onSuccess: (result) => {
    // do something on success
  },
  onError: (error) => console.error(error),
});

Parameters

config

UseWaitForUserOperationTransactionArgs Configuration object containing the client

Returns

UseWaitForUserOperationTransactionResult An object containing methods and state related to waiting for a user operation transaction