insertInstruction

open fun insertInstruction(encodedTx: String, insertAt: Int, instruction: String): String

Inserts an instruction to the given transaction at the specified position, returning the updated 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.

instruction

json encoded instruction. Here is an example: {"programId":"11111111111111111111111111111111","accounts":[{"pubkey":"YUz1AupPEy1vttBeDS7sXYZFhQJppcXMzjDiDx18Srf","isSigner":true,"isWritable":true},{"pubkey":"d8DiHEeHKdXkM2ZupT86mrvavhmJwUZjHPCzMiB5Lqb","isSigner":false,"isWritable":true}],"data":"3Bxs4Z6oyhaczjLK"}