How focus1010/txpilot works
Purpose and Public Entry Points
txpilot is a Node.js/TypeScript library that makes Solana transaction submission resilient: it selects a priority tip, signs and submits a caller-built transaction, tracks outcome, classifies failures, and retries when safe. The public package surface is exported from src/index.ts; the primary API is SmartTx in src/SmartTx.ts. Consumers construct it with RPC/wallet configuration and call send().
Smart Transaction Orchestrator
SmartTx is the control-plane owner for a send attempt and retry loop. It accepts a prebuilt @solana/web3.js transaction plus an optional lifecycle callback, obtains current network context, applies a decision, submits through the appropriate path, and returns a non-throwing typed result. It owns resource cleanup through disconnect().
• src/SmartTx.ts
• src/types.ts
• src/index.ts
Typed Domain Contract
The library’s boundary with consumers is a typed protocol: configuration, tip/retry controls, transaction status updates, send results, failure types, and adapter decision shapes. This keeps lifecycle callbacks and terminal results structured rather than exposing raw Solana/Jito errors.
• src/types.ts
• src/constants.ts
Network Snapshot and Tip Decision Stage
Before submission, the orchestration flow collects Solana/Jito conditions such as slot, congestion, and tip-floor percentiles. A pluggable decision adapter converts that context into a tip and retry-oriented strategy. Default operation uses deterministic rules; AI mode is represented as an alternate adapter boundary.
• src/adapters/rule-based.ts
• src/adapters/ai.ts
• src/SmartTx.ts
Submission Boundary: Solana RPC vs. Jito
Transactions are built by the application but signed/submitted by txpilot using the configured wallet. On mainnet, the sender chooses Jito bundle submission during an eligible leader window; otherwise it uses standard Solana RPC. This isolates external transport behavior from application transaction construction.
• src/SmartTx.ts
• src/constants.ts
• src/types.ts
External services include a user-provided Solana RPC endpoint (for example Helius), Jito block-engine/tip-floor endpoints on mainnet, and optionally Groq or Anthropic for AI decisions. @solana/web3.js is the peer runtime dependency; Node.js 20+ is the execution runtime.
Lifecycle Tracking and Consumer Notifications
After dispatch, the sender tracks the transaction through submitted, processed, confirmed, and finalized states. It emits StatusUpdate events through the caller callback, allowing integrations such as bots to report progress without implementing their own polling/control flow. Yellowstone gRPC configuration is an advanced tracking boundary, though the README identifies streaming integration as roadmap work.
• src/SmartTx.ts
• src/types.ts
Failure Classification and Retry Control
Raw submission, simulation, bundle, RPC, and confirmation failures pass through a classifier into a finite typed failure taxonomy. The orchestrator uses that result to abort unsafe retries (for example instruction or funds errors) or retry recoverable conditions with exponential backoff, a refreshed blockhash, and/or a raised tip. Terminal failure returns an actionable reason and suggestion rather than throwing.
• src/classifier/index.ts
• src/SmartTx.ts
• src/constants.ts>
Integration Examples
Examples demonstrate the intended outer boundary: applications retain transaction composition and user interaction, while txpilot handles delivery. The basic sender is the minimal library integration; the Telegram example maps lifecycle events and final results into chat responses.
• examples/basic-send.ts
• examples/telegram-bot.ts
Main entry points: SmartTx.ts SmartTx · index.ts Package exports · rule-based.ts Rule-based adapter · ai.ts AI adapter
Components 17
Applications
- Basic sender example
examples/basic-send.ts - Telegram bot example · Maps lifecycle events and results to chat responses.
examples/telegram-bot.ts
txpilot Library
- Package exports
src/index.ts - SmartTx · Owns send attempts, retry control, tracking, and cleanup.
src/SmartTx.ts - Typed domain contract · Configuration, status updates, results, failures, and adapter decisions.
src/types.ts - Policy constants · Tip and retry controls.
src/constants.ts - Network snapshot · Collects slot, congestion, and Jito tip-floor conditions.
src/SmartTx.ts - Rule-based adapter · Default deterministic tip and retry strategy.
src/adapters/rule-based.ts - AI adapter · Optional AI-backed decision boundary.
src/adapters/ai.ts - Signing and submission · Uses the configured wallet and selects RPC or eligible Jito bundles.
src/SmartTx.ts - Lifecycle tracking · Emits submitted through finalized updates.
src/SmartTx.ts - Failure classifier · Converts raw transport and confirmation errors into typed failures.
src/classifier/index.ts - Safe retry control · Backs off, refreshes blockhashes, and raises tips only when safe.
src/SmartTx.ts
External Services
- Solana RPC · User-provided endpoint for standard submission and network context.
- Jito services · Block-engine bundle submission and tip-floor data on mainnet.
- Groq / Anthropic · Optional providers for AI decisions.
- Wallet + web3.js · Signs caller-built Solana transactions.
Connections 22
- Basic sender example → Package exports: uses
- Telegram bot example → Package exports: uses
- Package exports → SmartTx: exports
- SmartTx → Typed domain contract: accepts and returns
- SmartTx → Network snapshot: collects
- Network snapshot → Solana RPC: queries
- Network snapshot → Jito services: reads tip floors
- SmartTx → Rule-based adapter: uses by default
- SmartTx → AI adapter: uses optionally
- Rule-based adapter → Policy constants: applies
- AI adapter → Groq / Anthropic: requests decisions
- SmartTx → Signing and submission: dispatches
- Signing and submission → Wallet + web3.js: signs with
- Signing and submission → Solana RPC: standard path
- Signing and submission → Jito services: eligible bundle path
- SmartTx → Lifecycle tracking: tracks outcome
- Lifecycle tracking → Solana RPC: confirms status
- Lifecycle tracking → Typed domain contract: emits status updates
- SmartTx → Failure classifier: classifies failures
- Failure classifier → Safe retry control: determines safety
- Safe retry control → SmartTx: retries or returns terminal result
- Safe retry control → Policy constants: uses backoff policy