Stellar PHP SDK API Documentation

TransactionPreconditions
in package

Transaction preconditions define validation rules for transaction execution.

Preconditions allow transactions to specify constraints that must be satisfied before they can be included in a ledger. This includes time bounds, ledger bounds, minimum sequence number requirements, sequence age and ledger gap constraints, and required additional signers.

V2 preconditions (Protocol 19+) support all constraint types, while earlier versions only support time bounds. The hasV2() method determines which format to use when converting to XDR.

Tags
see
Transaction
see
TimeBounds
see
LedgerBounds
link

Stellar developer docs

since

Protocol 19

Table of Contents

Methods

fromXdr()  : TransactionPreconditions
Creates a TransactionPreconditions instance from XDR.
getExtraSigners()  : array<string|int, XdrSignerKey>
Gets the list of extra signers required for authorization.
getLedgerBounds()  : LedgerBounds|null
Gets the ledger bounds constraint.
getMinSeqAge()  : int
Gets the minimum sequence age constraint in seconds.
getMinSeqLedgerGap()  : int
Gets the minimum sequence ledger gap constraint.
getMinSeqNumber()  : BigInteger|null
Gets the minimum sequence number constraint.
getTimeBounds()  : TimeBounds|null
Gets the time bounds constraint.
hasV2()  : bool
Determines if V2 preconditions are needed.
setExtraSigners()  : void
Sets the list of extra signers required for authorization.
setLedgerBounds()  : void
Sets the ledger bounds constraint.
setMinSeqAge()  : void
Sets the minimum sequence age constraint.
setMinSeqLedgerGap()  : void
Sets the minimum sequence ledger gap constraint.
setMinSeqNumber()  : void
Sets the minimum sequence number constraint.
setTimeBounds()  : void
Sets the time bounds constraint.
toXdr()  : XdrPreconditions
Converts the preconditions to XDR format.

Methods

getMinSeqAge()

Gets the minimum sequence age constraint in seconds.

public getMinSeqAge() : int
Return values
int

The minimum sequence age in seconds (0 if not set)

getMinSeqLedgerGap()

Gets the minimum sequence ledger gap constraint.

public getMinSeqLedgerGap() : int
Return values
int

The minimum ledger gap (0 if not set)

getMinSeqNumber()

Gets the minimum sequence number constraint.

public getMinSeqNumber() : BigInteger|null
Return values
BigInteger|null

The minimum sequence number, or null if not set

hasV2()

Determines if V2 preconditions are needed.

public hasV2() : bool

Returns true if any V2-only preconditions are set (ledger bounds, minimum sequence number, sequence age, ledger gap, or extra signers). When true, the preconditions must be encoded using the V2 XDR format.

Return values
bool

True if V2 preconditions are required, false otherwise

setExtraSigners()

Sets the list of extra signers required for authorization.

public setExtraSigners(array<string|int, XdrSignerKey$extraSigners) : void

Specifies additional signers that must sign the transaction beyond the normal signature requirements.

Parameters
$extraSigners : array<string|int, XdrSignerKey>

Array of required signer keys

setLedgerBounds()

Sets the ledger bounds constraint.

public setLedgerBounds(LedgerBounds|null $ledgerBounds) : void

Restricts the transaction to only be valid within a specific range of ledgers.

Parameters
$ledgerBounds : LedgerBounds|null

The ledger bounds to set, or null to clear

setMinSeqAge()

Sets the minimum sequence age constraint.

public setMinSeqAge(int $minSeqAge) : void

Transaction will only be valid if this many seconds have passed since the source account's sequence number last changed.

Parameters
$minSeqAge : int

The minimum age in seconds (0 to disable)

setMinSeqLedgerGap()

Sets the minimum sequence ledger gap constraint.

public setMinSeqLedgerGap(int $minSeqLedgerGap) : void

Transaction will only be valid if this many ledgers have closed since the source account's sequence number last changed.

Parameters
$minSeqLedgerGap : int

The minimum ledger gap (0 to disable)

setMinSeqNumber()

Sets the minimum sequence number constraint.

public setMinSeqNumber(BigInteger|null $minSeqNumber) : void

Transaction will only be valid if the source account's sequence number is at least this value.

Parameters
$minSeqNumber : BigInteger|null

The minimum sequence number to require, or null to clear

setTimeBounds()

Sets the time bounds constraint.

public setTimeBounds(TimeBounds|null $timeBounds) : void

Restricts the transaction to only be valid within a specific time range.

Parameters
$timeBounds : TimeBounds|null

The time bounds to set, or null to clear

toXdr()

Converts the preconditions to XDR format.

public toXdr() : XdrPreconditions

Creates an XDR representation of the preconditions. The format used depends on which constraints are set:

  • V2 format: If any V2-only preconditions are set
  • TIME format: If only time bounds are set
  • NONE format: If no preconditions are set
Return values
XdrPreconditions

The XDR representation of these preconditions


        
On this page

Search results