T402 API Reference - v2.8.0
    Preparing search index...

    Function useGaslessPayment

    • Hook for gasless ERC-4337 payments via WDK.

      Parameters

      • options: GaslessPaymentOptions

        Configuration including the gasless payment function and callbacks.

      Returns GaslessPaymentResult

      State and methods for managing gasless payments.

      import { useGaslessPayment } from "@t402/react";

      function GaslessPayButton({ client }) {
      const { pay, isLoading, isSuccess, txHash, sponsored, error } = useGaslessPayment({
      payFn: (params) => client.pay(params),
      onSuccess: (receipt) => console.log("Confirmed:", receipt.txHash),
      autoWait: true,
      });

      return (
      <button onClick={() => pay({ to: "0x...", amount: 1000000n })} disabled={isLoading}>
      {isLoading ? "Processing..." : "Pay Gasless"}
      </button>
      );
      }