useTransfer
Send XLM, issued assets, or SEP-41 tokens from React.
useTransfer wraps transfer in a TanStack
mutation. It exposes transfer for fire-and-forget calls and transferAsync
when you need to await the submitted transaction.
import { useTransfer } from "@bluxcc/react";
function SendButton() {
const { transfer, isPending, error } = useTransfer();
return (
<>
<button
disabled={isPending}
onClick={() => transfer({ to: "alice.xlm", amount: "10" })}
>
Send 10 XLM
</button>
{error && <p>{error.message}</p>}
</>
);
}For classic assets, to accepts G…, M…, SEP-2 federation, or .xlm. On
the SEP-41 token path it accepts G…, C…, SEP-2, or .xlm; muxed M…
addresses are not Soroban addresses. The token field accepts a C… id or
name resolving to one:
const { transferAsync } = useTransfer();
const transaction = await transferAsync({
token: "token.xlm",
to: "alice.xlm",
amount: "10000000", // integer token base units
});Invalid or unregistered names are returned through the mutation's error or
reject transferAsync. See address resolution
for mainnet/testnet behavior and SEP-2 memos.
All classic-asset, claimable-balance, memo, and network options are identical to
the core TransferOptions.