React Query mutation options (optional)
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 progressisError - Boolean indicating if transaction failederror - Error object if transaction faileddata - Transaction result with digest if successfulimport { 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
});
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:sponsoredTransactionfeature (currently only EVE Vault).The hook automatically:
useSmartObject