@evefrontier/dapp-kit - v0.0.1
    Preparing search index...

    Function useSponsoredTransaction

    • Hook for executing gas-sponsored transactions via EVE Frontier.

      This mutation hook enables dApps to send transactions where gas fees are paid by the EVE Frontier backend service, eliminating the need for users to have SUI tokens for gas. The wallet must support the evefrontier:sponsoredTransaction feature (currently only EVE Vault).

      The hook automatically:

      • Uses the currently connected wallet and account
      • Includes the current assembly ID from useSmartObject
      • Handles wallet feature detection and validation

      Parameters

      • options: UseSponsoredTransactionMutationOptions = {}

        React Query mutation options (optional)

      Returns UseMutationResult<
          SponsoredTransactionOutput,
          UseSponsoredTransactionError,
          UseSponsoredTransactionArgs,
      >

      React Query mutation result with:

      • mutate - Function to trigger transaction (fire-and-forget)
      • mutateAsync - Async function to trigger transaction (returns Promise)
      • isPending - Boolean indicating if transaction is in progress
      • isError - Boolean indicating if transaction failed
      • error - Error object if transaction failed
      • data - Transaction result with digest if successful

      If no wallet is connected

      If no account is selected

      If wallet doesn't support sponsored transactions

      import { useSponsoredTransaction, SponsoredTransactionActions } from "@evefrontier/dapp-kit";

      const BringOnlineButton = () => {
      const { mutateAsync: sendTx, isPending } = useSponsoredTransaction();

      const handleBringOnline = async () => {
      try {
      const result = await sendTx({
      txAction: SponsoredTransactionActions.BRING_ONLINE,
      chain: "sui:testnet",
      });
      console.log("Transaction digest:", result.digest);
      } catch (error) {
      console.error("Transaction failed:", error);
      }
      };

      return (
      <button onClick={handleBringOnline} disabled={isPending}>
      {isPending ? "Processing..." : "Bring Online"}
      </button>
      );
      };
      const { mutate: sendTx } = useSponsoredTransaction();

      sendTx(
      { txAction: SponsoredTransactionActions.BRING_OFFLINE, chain: "sui:testnet" },
      {
      onSuccess: (result) => {
      notify({ type: Severity.Success, txHash: result.digest });
      },
      onError: (error) => {
      notify({ type: Severity.Error, message: error.message });
      },
      }
      );
      const result = await sendTx({
      txAction: SponsoredTransactionActions.EDIT_UNIT,
      chain: "sui:testnet",
      assembly: "0x123...", // Override the default assembly
      });