Skip to content

Transaction (Class)

A Kaspa transaction.

Represents a complete transaction with inputs, outputs, and metadata. Transactions are the fundamental unit of value transfer on the Kaspa network.

gas property writable

gas: int

The gas limit for smart contract execution.

RETURNS DESCRIPTION
int

The gas limit.

TYPE: int

id property

id: str

The transaction ID (hash).

RETURNS DESCRIPTION
str

The transaction ID as a hex string.

TYPE: str

inputs property writable

inputs: list[TransactionInput]

The list of transaction inputs.

RETURNS DESCRIPTION
list[TransactionInput]

list[TransactionInput]: List of inputs spending previous outputs.

lock_time property writable

lock_time: int

The transaction lock time. Represents a DAA score or Unix timestamp before which the transaction cannot be included.

RETURNS DESCRIPTION
int

The lock time value.

TYPE: int

mass property writable

mass: int

The transaction mass used for fee calculation.

RETURNS DESCRIPTION
int

The transaction mass.

TYPE: int

outputs property writable

outputs: list[TransactionOutput]

The list of transaction outputs.

RETURNS DESCRIPTION
list[TransactionOutput]

list[TransactionOutput]: List of outputs defining value destinations.

payload property writable

payload: str

The transaction payload data.

RETURNS DESCRIPTION
str

The payload as a hex string.

TYPE: str

subnetwork property

subnetwork: str

The subnetwork identifier.

RETURNS DESCRIPTION
str

The subnetwork ID as a hex string.

TYPE: str

version property writable

version: int

The transaction version number.

RETURNS DESCRIPTION
int

The version number.

TYPE: int

__eq__

__eq__(other: Transaction) -> bool

__new__

__new__(version: int, inputs: Sequence[TransactionInput], outputs: Sequence[TransactionOutput], lock_time: int, subnetwork_id: Binary, gas: int, payload: Binary, mass: int) -> Transaction

Create a new transaction.

PARAMETER DESCRIPTION
version

Transaction version number.

TYPE: int

inputs

List of transaction inputs.

TYPE: Sequence[TransactionInput]

outputs

List of transaction outputs.

TYPE: Sequence[TransactionOutput]

lock_time

Lock time (block DAA score or timestamp).

TYPE: int

subnetwork_id

Subnetwork identifier (hex string or bytes).

TYPE: Binary

gas

Gas limit for smart contract execution.

TYPE: int

payload

Optional transaction payload data.

TYPE: Binary

mass

Transaction mass (for fee calculation).

TYPE: int

RETURNS DESCRIPTION
Transaction

A new Transaction instance.

TYPE: Transaction

RAISES DESCRIPTION
Exception

If the subnetwork_id is invalid or transaction creation fails.

addresses

addresses(network_type: str | NetworkType) -> list[Address]

Extract unique addresses from transaction inputs.

PARAMETER DESCRIPTION
network_type

The network type to use for address encoding.

TYPE: str | NetworkType

RETURNS DESCRIPTION
list[Address]

list[Address]: List of unique addresses referenced by inputs.

finalize

finalize() -> Hash

Finalize the transaction and compute its ID.

RETURNS DESCRIPTION
Hash

The computed transaction ID.

TYPE: Hash

is_coinbase

is_coinbase() -> bool

Check if this is a coinbase transaction.

RETURNS DESCRIPTION
bool

True if this is a coinbase (mining reward) transaction.

TYPE: bool

subnetwork_id

subnetwork_id(value: str) -> None

Set the subnetwork identifier.

PARAMETER DESCRIPTION
value

The subnetwork ID as a hex string.

TYPE: str

RAISES DESCRIPTION
Exception

If the hex string is invalid or has incorrect length.