gill

getTransferTokensInstructions

function getTransferTokensInstructions(args): IInstruction<string, readonly (IAccountLookupMeta<string, string> | IAccountMeta<string>)[]>[];

Create the instructions required to transfer tokens from one wallet to another, including creating the destination ATA if it does not exist

Example

const sourceAta = await getAssociatedTokenAccountAddress(mint, authority, tokenProgram);

const destination = address(...);
const destinationAta = await getAssociatedTokenAccountAddress(mint, destination, tokenProgram);

const instructions = getTransferTokensInstructions({
   feePayer: signer,
   mint,
   amount: 10,
   authority: signer, // the source wallet for the tokens to be transferred
   sourceAta, // normally derived from the `authority`
   destination,
   destinationAta, // derived from the `destination`
   tokenProgram,
});

Parameters

Returns

IInstruction<string, readonly (IAccountLookupMeta<string, string> | IAccountMeta<string>)[]>[]

On this page