Transaction Lifecycle: Complete Transaction Journey
Introduction
Understanding the complete lifecycle of a transaction—from the moment it's created to its final inclusion in a validated ledger—is crucial for developing applications on the XRP Ledger, debugging transaction issues, and optimizing transaction processing. Every transaction follows a well-defined path through multiple validation stages, consensus rounds, and finalization steps.
This deep dive traces the entire journey of a transaction, explaining each phase, the checks performed, the state transitions, and how to monitor and query transaction status at every step. Whether you're building a wallet, an exchange integration, or contributing to the core protocol, mastering the transaction lifecycle is essential.
Transaction Lifecycle Overview
Complete Journey Diagram
Typical Timeline
Fast Path (ideal conditions):
Slow Path (transaction arrives late in open phase):
Phase 1: Transaction Creation
Transaction Structure
Before submission, a transaction must be properly constructed:
Required Fields
Universal Fields (all transaction types):
TransactionType- Type of transaction (Payment, OfferCreate, etc.)Account- Source account (sender)Fee- Transaction fee in drops (1 XRP = 1,000,000 drops)Sequence- Account sequence number (nonce)SigningPubKey- Public key used for signingTxnSignature- Cryptographic signature (or multi-signatures)
Optional but Recommended:
LastLedgerSequence- Expiration ledger (transaction invalid after this)SourceTag/DestinationTag- Integer tags for routing/identificationMemos- Arbitrary data attached to transaction
Transaction Signing
Single Signature:
Multi-Signature:
Transaction Hash
The transaction hash (ID) is calculated from the signed transaction:
Important: The hash is deterministic—the same signed transaction always produces the same hash.
Phase 2: Transaction Submission
Submission Methods
Method 1: RPC Submit
Submit via JSON-RPC:
Response:
Method 2: WebSocket Submit
Real-time submission with streaming updates:
Method 3: Peer Network Submission
Transactions submitted to one node propagate to all nodes:
Even if submitted to a non-validator, the transaction reaches validators through peer-to-peer propagation.
Submission Response
Immediate response indicates initial validation result:
Success Codes:
tesSUCCESS- Transaction applied to open ledgerterQUEUED- Transaction queued (network busy)
Temporary Failure (can retry):
terPRE_SEQ- Sequence too high, earlier tx neededtefPAST_SEQ- Sequence too low (already used)
Permanent Failure (don't retry):
temMALFORMED- Malformed transactiontemBAD_FEE- Invalid feetemBAD_SIGNATURE- Invalid signature
Phase 3: Initial Validation
Preflight Checks
Before accessing ledger state, static validation occurs:
Checks Performed:
✓ Cryptographic signature valid
✓ Transaction format correct
✓ Required fields present
✓ Fee sufficient
✓ Amounts positive and properly formatted
✓ No contradictory fields
Why Preflight Matters: Catches obvious errors before expensive ledger state access.
Phase 4: Preclaim Validation
Ledger State Checks
Read-only validation against current ledger state:
Checks Performed:
✓ Source account exists
✓ Sequence number correct
✓ Sufficient balance (including fee)
✓ Destination account requirements met
✓ Trust lines exist (for issued currencies)
✓ Account flags permit operation
Phase 5: Open Ledger Application
Tentative Application
Transaction is tentatively applied to provide immediate feedback:
Open Ledger Characteristics:
Not Final: Open ledger is tentative, changes frequently
No Consensus: Local view only, other nodes may differ
Immediate Feedback: Clients get instant response
Can Change: Transaction may be removed or re-ordered
Why It Matters:
Users get immediate confirmation
Wallets can show pending transactions
Applications can provide real-time updates
Phase 6: Network Propagation
Transaction Broadcasting
Once applied to open ledger, transaction broadcasts to peers:
Propagation Speed:
Local network: < 100ms
Global network: 200-500ms
All nodes receive transaction within 1 second
Deduplication:
Nodes track recently seen transactions
Duplicate transactions not re-processed
Prevents network flooding
Phase 7: Consensus Round
Transaction Set Building
As ledger close approaches, validators build transaction sets:
Consensus Process
Validators exchange proposals and converge:
Round 1: Initial proposals
Round 2: Converge on high-agreement transactions
Transaction Inclusion Criteria:
80% of UNL must agree to include
Transaction must still be valid
Must not have expired (LastLedgerSequence)
Phase 8: Canonical Application
Deterministic Execution
After consensus, transactions are applied in canonical order:
DoApply Execution:
Result Codes:
tesSUCCESS- Transaction succeededtecUNFUNDED- Failed but fee chargedtecNO_TARGET- Failed but fee charged
Important: Even failed transactions (tec codes) consume the fee and advance the sequence number.
Phase 9: Ledger Closure
Closing the Ledger
After all transactions are applied:
Ledger Hash Calculation:
Phase 10: Validation Phase
Creating Validations
Validators sign the closed ledger:
Broadcasting Validations
Collecting Validations
Phase 11: Fully Validated
Finalization
When quorum is reached, ledger becomes fully validated:
Characteristics of Validated Ledger:
Immutable: Cannot be changed
Permanent: Part of ledger history forever
Canonical: All nodes have identical copy
Final: Transactions cannot be reversed
Transaction Status Querying
Methods to Check Transaction Status
Method 1: tx RPC
Query by transaction hash:
Response:
Key Fields:
validated: true = in validated ledger, false = pendingmeta.TransactionResult: Final result codeledger_index: Which ledger contains transaction
Method 2: account_tx RPC
Query all transactions for an account:
Lists transactions in reverse chronological order.
Method 3: WebSocket Subscriptions
Real-time transaction monitoring:
Subscription Types:
accounts- Transactions affecting specific accountstransactions- All transactions network-wideledger- Ledger close events
Transaction Metadata
Metadata Structure
Metadata records the effects of a transaction:
AffectedNodes Types:
CreatedNode- New ledger object createdModifiedNode- Existing object modifiedDeletedNode- Object deleted
Key Metadata Fields:
TransactionIndex- Position in ledgerTransactionResult- Final result codedelivered_amount- Actual amount delivered (for partial payments)
Transaction Expiration
LastLedgerSequence
Transactions can specify an expiration:
Behavior:
If not included by ledger 75234567, transaction becomes invalid
Prevents transactions from being stuck indefinitely
Recommended: Set to current ledger + 4
Checking Expiration:
Hands-On Exercise
Exercise: Track a Transaction Through Its Complete Lifecycle
Objective: Submit a transaction and observe it at each phase of the lifecycle.
Part 1: Prepare and Submit
Step 1: Create and fund test accounts
Step 2: Prepare transaction with monitoring
Step 3: Submit and record time
Part 2: Monitor Progress
Step 4: Subscribe to transaction
Step 5: Poll for status
Part 3: Analyze Results
Step 6: Examine metadata
Analysis Questions
Answer these based on your observations:
How long did each phase take?
Submission to initial result: ___ ms
Initial result to validated: ___ ms
Total time: ___ ms
What was the initial result?
Did it apply to open ledger?
Which ledger included the transaction?
Ledger index?
How many ledgers closed between submission and inclusion?
What was the metadata?
Which nodes were affected?
What balances changed?
Did the transaction expire?
Was LastLedgerSequence set?
How close to expiration was it?
Key Takeaways
Core Concepts
✅ 11-Phase Journey: Transactions go through creation, submission, validation, consensus, application, and finalization
✅ Multiple Validation Stages: Preflight (static), Preclaim (state-based), DoApply (execution)
✅ Open Ledger Preview: Tentative application provides immediate feedback before consensus
✅ Consensus Inclusion: Validators must agree (>80%) to include transaction
✅ Canonical Order: Deterministic ordering ensures all nodes reach identical state
✅ Immutable Finality: Once validated, transactions cannot be reversed
✅ Metadata Records Effects: Complete record of all ledger modifications
Timing Expectations
✅ Fast Path: ~7 seconds submission to validation
✅ Slow Path: ~30 seconds if submitted late in open phase
✅ Network Propagation: <1 second to reach all nodes
✅ Consensus Round: 3-5 seconds
Development Skills
✅ Transaction Construction: Proper signing and field selection
✅ Status Monitoring: Using tx, account_tx, and subscriptions
✅ Error Handling: Understanding result codes (tem/tef/ter/tec/tes)
✅ Expiration Management: Setting LastLedgerSequence appropriately
✅ Metadata Analysis: Understanding transaction effects
Common Issues and Solutions
Issue 1: Transaction Stuck Pending
Symptoms: Transaction not validating after 30+ seconds
Possible Causes:
Insufficient fee (transaction queued)
Network congestion
Sequence gap (earlier transaction missing)
Solutions:
Issue 2: tefPAST_SEQ Error
Symptoms: Sequence number already used
Cause: Sequence out of sync or transaction already processed
Solution:
Issue 3: Transaction Not Found
Symptoms: tx command returns "txnNotFound"
Possible Causes:
Transaction not yet in validated ledger
Transaction expired (LastLedgerSequence)
Transaction rejected during validation
Solution:
Issue 4: tecUNFUNDED_PAYMENT
Symptoms: Transaction failed with fee charged
Cause: Insufficient balance between submission and execution
Prevention:
Additional Resources
Official Documentation
XRP Ledger Dev Portal: xrpl.org/docs
Transaction Types: xrpl.org/transaction-types
Transaction Results: xrpl.org/transaction-results
Codebase References
src/ripple/app/tx/impl/Transactor.cpp- Transaction processingsrc/ripple/app/misc/NetworkOPs.cpp- Network operations and transaction handlingsrc/ripple/app/ledger/OpenLedger.cpp- Open ledger management
Related Topics
Transactors - How transactions are validated and executed
Consensus Engine - How transactions are included in consensus
Protocols - How transactions are propagated across the network
Last updated

