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
¶
The gas limit for smart contract execution.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The gas limit.
TYPE:
|
id
property
¶
The transaction ID (hash).
| RETURNS | DESCRIPTION |
|---|---|
str
|
The transaction ID as a hex string.
TYPE:
|
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
¶
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:
|
mass
property
writable
¶
The transaction mass used for fee calculation.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The transaction mass.
TYPE:
|
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
¶
The transaction payload data.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The payload as a hex string.
TYPE:
|
subnetwork
property
¶
The subnetwork identifier.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The subnetwork ID as a hex string.
TYPE:
|
version
property
writable
¶
The transaction version number.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The version number.
TYPE:
|
__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:
|
inputs
|
List of transaction inputs.
TYPE:
|
outputs
|
List of transaction outputs.
TYPE:
|
lock_time
|
Lock time (block DAA score or timestamp).
TYPE:
|
subnetwork_id
|
Subnetwork identifier (hex string or bytes).
TYPE:
|
gas
|
Gas limit for smart contract execution.
TYPE:
|
payload
|
Optional transaction payload data.
TYPE:
|
mass
|
Transaction mass (for fee calculation).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Transaction
|
A new Transaction instance.
TYPE:
|
| 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:
|
| 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:
|
is_coinbase
¶
Check if this is a coinbase transaction.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if this is a coinbase (mining reward) transaction.
TYPE:
|
subnetwork_id
¶
Set the subnetwork identifier.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The subnetwork ID as a hex string.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If the hex string is invalid or has incorrect length. |