Skip to main content

useSendTokens

Mutation hook to send tokens and returns @cosmjs/stargate's DeliverTxResponse Note: if senderAddress undefined, it will use current connected account address

Usage

import { useSendTokens, useStargateSigningClient } from "graz";

// basic example
const { data: signingClient } = useStargateSigningClient()
const { sendTokens } = useSendTokens();

sendTokens({
signingClient,
recipientAddress: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430";
// ...
})

Types

  • SendTokensArgs
    {
    signingClient?: SigningStargateClient | SigningCosmWasmClient;
    senderAddress?: string;
    recipientAddress: string;
    amount: Coin[];
    fee: number | StdFee | "auto";
    memo?: string;
    }

Params

Object params

  • onError?: (error: unknown, args: SendTokensArgs) => void
  • onMutate?: (data: SendTokensArgs) => void
  • onSuccess?: (data: DeliverTxResponse) => void

Return Value

{
error: unknown;
isLoading: boolean;
isSuccess: boolean;
sendTokens: (args: SendTokensArgs) => void;
sendTokensAsync: (args: SendTokensArgs) => Promise<DeliverTxResponse>;
status: "error" | "idle" | "loading" | "success";
}