I'm working with python and have a versioned transaction where the instructions are compiled. To that versioned transaction I need to add a NON compiled instruction somehow. If the transaction is still versioned at the end or not doesn't really matter. I tried just appending the instruction to the compiled instructions but when creating a new transaction with those instructions it obviously didn't work because I had mixed compiled instructions with non compiled instructions


solana = 0.30.1

solders = 0.17.0

from solders.instruction import CompiledInstruction, Instruction
from solders.transaction import Transaction, VersionedTransaction
from solders.system_program import TransferParams, transfer

# Getting compiled instructions
raw_transaction = VersionedTransaction.from_bytes(base64.b64decode(data))
raw_instructions = raw_transaction.message.instructions

# Creating NON compiled instructions which I'm trying to merge into the compiled ones:
tip_inst = transfer(TransferParams(from_pubkey=payer_kp.pubkey(),

2 Answers 2


Hey so I did this with TS but I'm sure it can translate just fine. What you want to do is decompile the message of the transaction like so

const message = TransactionMessage.decompile(transaction.message, {

and then you want to push the new instruction into the instructions field of that decompiled message


and then just replace the original transaction's message field with your new message (remember to compile it)

transaction.message = message.compileToV0Message(addressLookupTableAccounts);

Best of luck!


I need to do the same as Milan. However, i'm not finding how to decompile the message in Python. Any ideas how? Also, why do you mention 'addressLookupTableAccounts' when decompiling and then mention it again when compiling (last step)?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.