Transaction

Class representing a transaction model. This object is passed in send_transaction method

class Transaction(self, **config)
copy

A completely empty transaction can be initialized without any config, the table below shows the available config options

ConfigDescription
recent_blockhashOptional, latest on is fetched if not provided
nonce_infoAlternative to recent_blockhash
fee_payerFirst signer's public key is used if this is not provided
signersList of keypairs who will sign the transaction.
instructionsList of Instructions which the transaction will execute
signaturesInitialize with externally created signatures

Methods

Attributes

Methods

.compile_transaction

Compiles all the transaction data.

def compile_transaction()
copy

.serialize_message

This method runs the [#compile_transaction] method and serializes the message returned from it.

def serialize_message()
copy

.sign

Signs the transaction by the sender.

def sign()
copy

.add_signature

Adds an externally created signature to the transaction object. Public key and signature (in bytes) are required arguments.

def add_signature(pubkey: PublicKey | str, signature: bytes)
copy
⚠️

This method is not stable right now.

.add_signer

Add a signer to the transaction object. The signer should be a keypair object.

def add_signer(keypair: Keypair)
copy
⚠️

This method is not stable right now.

.verify_signatures

Verify if the signatures are correct in a complete signed transaction object.

def verify_signatures()
copy

.serialize

This method serializes the message to bytes.

def serialize()
copy

Attributes

.instructions

Returns all transaction instructions.

.signatures

Returns all the signatures of the transaction object.

.recent_blockhash

Returns the recent blockhash of the transaction object.