AbstractTransaction

abstract class AbstractTransaction(val network: Network)

Abstract base class for transaction classes.

Stellar supports two types of transactions:

  • Transaction - Standard transaction containing operations

  • FeeBumpTransaction - Transaction that wraps another transaction to bump its fee

This abstract class provides common functionality for signing, hashing, and serializing transactions.

Transaction Lifecycle

  1. Build - Create transaction using TransactionBuilder

  2. Sign - Add signatures using sign() methods

  3. Serialize - Convert to XDR for network submission

  4. Submit - Send to Horizon or RPC server

Signing

Transactions must be signed by the source account and any other required signers. Signatures are added using the sign() methods:

val transaction = TransactionBuilder(...)
.build()

// Sign with keypair
transaction.sign(keypair)

// Sign with hash(x) preimage
transaction.signHashX(preimage)

Network Passphrase

Each transaction is tied to a specific network (PUBLIC, TESTNET, etc.) through its network passphrase. The network ID (SHA-256 hash of passphrase) is included in the transaction hash to prevent replay attacks across different networks.

See also

Inheritors

Constructors

Link copied to clipboard
constructor(network: Network)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The network this transaction is for

Link copied to clipboard

List of signatures attached to this transaction.

Functions

Link copied to clipboard
suspend fun hash(): ByteArray

Returns the transaction hash (SHA-256 of signature base).

Link copied to clipboard
suspend fun hashHex(): String

Returns the transaction hash as a lowercase hexadecimal string.

Link copied to clipboard
suspend fun sign(signer: KeyPair)

Adds a signature by signing the transaction hash with the provided keypair.

Link copied to clipboard
abstract suspend fun signatureBase(): ByteArray

Returns the signature base - the data that must be signed.

Link copied to clipboard
suspend fun signHashX(preimage: ByteArray)

Adds a hash(x) signature by revealing the preimage.

Link copied to clipboard

Converts this transaction to its XDR envelope representation.

Link copied to clipboard

Returns base64-encoded TransactionEnvelope XDR.