insertTransferInstruction

open fun insertTransferInstruction(encodedTx: String, insertAt: Int, from: String, to: String, lamports: String): String

Inserts a SOL transfer instruction to the given transaction at the specified position, returning the updated transaction. Please note that compute price and limit instructions should always be the first instructions if they are present in the transaction.

Return

base64 encoded Solana transaction. Null if an error occurred.

Parameters

encoded_tx

base64 encoded Solana transaction.

insert_at

index where the instruction should be inserted. If you don't care about the position, use -1.

from

sender account from which the lamports will be debited.

to

receiver account to which the lamports will be transferred.

lamports

amount of lamports to transfer, as a decimal string.