React Query mutation options (optional)
React Query mutation result with:
mutate(args, options?) - Trigger transaction (fire-and-forget)mutateAsync(args) - Trigger transaction (returns PromiseisPending - True while the transaction is in progressisError - True if the last mutation failederror - Error from the last failed mutationdata - Last successful result (SponsoredTransactionOutput)If assembly ID is missing or invalid (neither assembly.item_id nor itemId query param is a valid non-negative integer)
import { useSponsoredTransaction, SponsoredTransactionActions, useSmartObject } from "@evefrontier/dapp-kit";
const BringOnlineButton = () => {
const { assembly } = useSmartObject();
const { mutateAsync: sendTx, isPending } = useSponsoredTransaction();
const handleBringOnline = async () => {
if (!assembly) return;
try {
const result = await sendTx({
txAction: SponsoredTransactionActions.BRING_ONLINE,
assembly,
chain: "sui:testnet",
});
console.log("Transaction digest:", result.digest);
} catch (error) {
console.error("Transaction failed:", error);
}
};
return (
<button onClick={handleBringOnline} disabled={isPending || !assembly}>
{isPending ? "Processing..." : "Bring Online"}
</button>
);
};
const { assembly } = useSmartObject();
const { mutate: sendTx } = useSponsoredTransaction();
sendTx(
{
txAction: SponsoredTransactionActions.BRING_ONLINE,
assembly,
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.BRING_ONLINE,
assembly, // full AssemblyType from useSmartObject() or similar
chain: "sui:testnet",
account: "0x...", // optional; defaults to connected wallet account
});
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).Transient server errors (e.g. 502 Bad Gateway) are retried automatically with the same payload a limited number of times with a delay between attempts.
The hook automatically uses the currently connected wallet and account (unless overridden) and handles wallet feature detection and validation.
Input (passed to
mutate/mutateAsync):txAction(required) – The sponsored action to run (e.g. BRING_ONLINE, BRING_OFFLINE).chain(required) – Sui chain id, e.g."sui:testnet"or"sui:mainnet".assembly(required) – Full assembly object (AssemblyType<Assemblies>). Must includetypeanditem_id(number). Ifitem_idis missing or invalid, the hook falls back to the URL query paramitemId(parsed as a non-negative integer). Fails with AssemblyIdRequiredError if neither source provides a valid id.tenant(optional) – Tenant ID. When omitted, the hook resolves it from the URL query param (e.g.tenant) with fallback toTenantId.UTOPIA. Pass explicitly to override.account(optional) – Signer address. If omitted, the currently connected wallet account is used.Output (on success, in
dataor resolved frommutateAsync):digest(required) – Transaction digest.effects(optional) – Transaction effects, BCS encoded.rawEffects(optional) – Raw effects bytes.