Skip to content

Add transaction polling method to RPC client #5875

Description

@leighmcculloch

Summary

Add a method to the RPC client that polls GetTransaction until a transaction reaches a terminal state (SUCCESS or FAILED), using exponential backoff between attempts.

Motivation

When submitting transactions via SendTransaction, the response only indicates that the transaction was accepted for processing, not that it was finalized. Callers currently need to implement their own polling logic to wait for the transaction to reach a terminal state. This is a common pattern that should be provided by the client library.

This functionality already exists in the friendbot repository (stellar/friendbot#20) and should be ported to the SDK for broader use. The JavaScript SDK already provides a similar pollTransaction method.

Use Cases

This polling approach is well-suited for:

  • Scripts and CLI tools
  • Prototypes and smaller applications
  • Linear application flows where waiting for transaction finality is acceptable

For high-throughput production systems, a different approach using persistent queues and databases may be more appropriate to handle edge cases around transaction failures. However, since developers will implement polling regardless of whether the SDK provides it, providing an implementation in the SDK is a convenience.

Details

  • Poll GetTransaction repeatedly until the transaction status is SUCCESS or FAILED
  • Use exponential backoff between polling attempts (default initial interval: 500ms, default max interval: 3500ms)
  • Allow callers to configure the backoff intervals
  • Use context for timeout/cancellation control (caller decides how long to wait)
  • Return the full GetTransactionResponse so callers have access to transaction details like ResultXDR and DiagnosticEventsXDR
  • Treat RPC errors as permanent (no retry)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions