Configuration including the gasless payment function and callbacks.
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>
);
}
Hook for gasless ERC-4337 payments via WDK.