sof-tx
sof-tx is the transaction SDK for SOF.
It provides:
- ergonomic transaction/message building
- signed and pre-signed submission APIs
- runtime mode selection:
RpcOnlyDirectOnly(leader-targeted UDP send)Hybrid(direct first, RPC fallback)
- routing policy and signature-level dedupe
Install
Core Types
TxBuilder: compose transaction instructions and signing inputs.TxSubmitClient: submit through RPC/direct/hybrid.SubmitMode: runtime mode switch.SignedTx: submit externally signed transaction bytes.RoutingPolicy: leader/backup fanout controls.LeaderProviderandRecentBlockhashProvider: provider boundaries.
Quickstart
use Arc;
use ;
use Keypair;
use Signer;
use instruction as system_instruction;
async
Simplifying OpenBook + CPMM Flows
The recommended pattern is to keep strategy-specific instruction creation separate, and route both through one shared SDK pipeline.
use ;
use Instruction;
use Keypair;
use Signer;
async
This gives one consistent path for signing, dedupe, routing, and fallback behavior.
Submitting Pre-Signed Transactions
If your signer is external (wallet/HSM/offline), submit bytes directly:
use ;
async
Developer Tip
TxBuilder::tip_developer() adds a developer-support transfer instruction using a default tip of 5000 lamports.
- default amount:
5000lamports (DEFAULT_DEVELOPER_TIP_LAMPORTS) - default recipient:
G3WHMVjx7Cb3MFhBAHe52zw8yhbHodWnas5gYLceaqze - custom amount:
tip_developer_lamports(...) - custom recipient + amount:
tip_to(...)
Thanks in advance for supporting continued SDK development.
Mode Guidance
RpcOnly: maximum compatibility.DirectOnly: lowest path latency when leader targets are reliable.Hybrid: practical default for latency + fallback resilience.
Reliability Profiles
Direct and hybrid modes include built-in reliability defaults through SubmitReliability.
LowLatency: minimal retries for fastest failover (direct_target_rounds=1,hybrid_direct_attempts=1)Balanced(default): extra direct retries before fallback (direct_target_rounds=2,hybrid_direct_attempts=2)HighReliability: most direct retrying (direct_target_rounds=3,hybrid_direct_attempts=3)
Use TxSubmitClient::with_reliability(...) for presets, or with_direct_config(...) for full control.
Feature Model
Current implementation supports RPC/direct/hybrid runtime modes through one API. Compile-time capability flags from ADR-0006 can be introduced incrementally as the SDK stabilizes.
Docs
- ADR for SDK scope:
../../docs/architecture/adr/0006-transaction-sdk-and-dual-submit-routing.md - Workspace docs index:
../../docs/README.md - Contribution guide:
../../CONTRIBUTING.md