Skip to content

useMultiTokenTransfer

Send multiple fungible token transfers in a single transaction.

Import

ts
import { useMultiTokenTransfer } from "hierokit";

Parameters

  • options?: TransactionFlowOptions

Execute arguments

ts
type MultiTokenTransferItem = {
  tokenId: string | TokenId;
  from?: string | AccountId;
  to: string | AccountId;
  amount: number;
};

type MultiTokenTransferArgs = {
  items: MultiTokenTransferItem[];
  memo?: string;
};
  • If from is omitted for an item, the operator account is used.

Returns

ts
{
  flow: FlowHandle<TransactionReceipt>;
  execute: (args: MultiTokenTransferArgs) => Promise<void>;
}

Usage

tsx
import { useMultiTokenTransfer } from "hierokit";

function AirdropButton() {
  const { flow, execute } = useMultiTokenTransfer();

  return (
    <div>
      <button
        onClick={() =>
          execute({
            items: [
              { tokenId: "0.0.tokenA", to: "0.0.alice", amount: 10 },
              { tokenId: "0.0.tokenB", to: "0.0.bob", amount: 20 },
            ],
            memo: "Promo drop",
          })
        }
      >
        Run airdrop
      </button>
      <p>Status: {flow.status}</p>
    </div>
  );
}