@aptos-labs/ts-sdk
Version:
Aptos TypeScript SDK
36 lines • 1.56 kB
JavaScript
import { APTOS_COIN } from "../utils/const.js";
import { generateTransaction } from "./transactionSubmission.js";
import { TypeTagAddress, TypeTagU64 } from "../transactions/index.js";
const coinTransferAbi = {
typeParameters: [{ constraints: [] }],
parameters: [new TypeTagAddress(), new TypeTagU64()],
};
/**
* Generates a transaction to transfer coins from one account to another.
* This function allows you to specify the sender, recipient, amount, and coin type for the transaction.
*
* @param args - The parameters for the transaction.
* @param args.aptosConfig - The Aptos configuration object.
* @param args.sender - The address of the account sending the coins.
* @param args.recipient - The address of the account receiving the coins.
* @param args.amount - The amount of coins to transfer.
* @param args.coinType - (Optional) The type of coin to transfer, defaults to Aptos Coin if not specified.
* @param args.options - (Optional) Options for generating the transaction.
* @group Implementation
*/
export async function transferCoinTransaction(args) {
const { aptosConfig, sender, recipient, amount, coinType, options } = args;
const coinStructType = coinType ?? APTOS_COIN;
return generateTransaction({
aptosConfig,
sender,
data: {
function: "0x1::aptos_account::transfer_coins",
typeArguments: [coinStructType],
functionArguments: [recipient, amount],
abi: coinTransferAbi,
},
options,
});
}
//# sourceMappingURL=coin.js.map