Skip to main content

txwhy

Failed Solana transaction in, working transaction out. The Python client for TxWhy: a repair API, a one-call send loop for solana-py, and an offline verifier that proves a repair changed only what a repair is allowed to change.

pip install txwhy            # the client and the verifier, no dependencies
pip install "txwhy[solana]"  # adds the solana-py / solders send loop

One call in your send loop

from solana.rpc.async_api import AsyncClient
from txwhy.solana import async_send_with_repair

client = AsyncClient("https://api.mainnet-beta.solana.com")
signature = await async_send_with_repair(client, tx, keypair)   # tx: solders VersionedTransaction, bytes or base64

With a sync solana.rpc.api.Client, send_with_repair(client, tx, keypair) does the same.

Simulates on your RPC. If it passes, sends and never contacts TxWhy. If it would fail: repair, verify locally, sign, send. Your key never leaves the process; TxWhy only sees unsigned bytes.

What it repairs: compute unit limit, expired blockhash, priority fee, loaded-data limit, a Jupiter swap that failed on slippage (fresh quote, same tokens, amount and tolerance; refused above 3% price impact or more than 25% worse than your quote), and a direct Pump.fun, PumpSwap, Raydium AMM v4, Raydium LaunchLab, Meteora DBC or Meteora DAMM v2 swap (only the limit moves, never more than 25% against you). Anything else comes back as a diagnosis with the exact cause and fix; send_with_repair raises TxWhyError whose .result["cause"] carries it.

Just the repair call

import txwhy

result = txwhy.repair(transaction=tx_base64)       # or txwhy.repair(signature="5xyz...")
result["status"]               # repaired | valid | needs_requote | not_repairable
result["cause"]                # {"title", "code", "cause", "fix"} or None
result["changes"]              # what moved and why
result["repairedTransaction"]  # base64, unsigned, when status is repaired or valid

Just the explanation

txwhy.explain(error=sim.value.err, logs=sim.value.logs)   # cause, failingProgram, repairable, next

You never have to trust us

from txwhy.solana import async_verify_repair   # or verify_repair with a sync Client

check = await async_verify_repair(client, original_bytes, repaired_bytes)   # no call to TxWhy
assert check.ok, check.violations

The rule is the same one the TypeScript SDK and the txwhy-verify Rust crate enforce, and all three are tested against the same real-repair fixtures: same fee payer, same signers, every non-Compute-Budget instruction byte for byte in order, at most one Jupiter swap replaced by an equivalent one (same wallet, token accounts, output token, amount, tolerance, quote no more than 25% worse), one direct swap with only its limit moved within 25%, and a wrap into an exact-out swap's own input account raised by no more than the maximum rose.

Legacy and v0 transactions are decompiled here (lookup tables through your RPC). For version 1 transactions call txwhy.repair(transaction=...) and verify with your own decoder.

Pay per repair, no account (x402)

The free endpoint is rate limited. Agents that need guaranteed capacity use https://txwhy.vercel.app/api/x402/repair, $0.001 in USDC per repair, settled over x402; pass endpoint= to repair() with your x402 client.

MIT. Source: https://github.com/SUNDRAM07/txwhy

Metadata

Release files for txwhy 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for txwhy 0.1.1
File Size Uploaded Provenance Actions
txwhy-0.1.1.tar.gz 18.9 kB Without provenance Details for txwhy-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for txwhy 0.1.1
File Interpreter ABI Platform Actions
txwhy-0.1.1-py3-none-any.whl Python 3 none any Details for txwhy-0.1.1-py3-none-any.whl

Total release size: 35.2 kB

Release files / txwhy-0.1.1.tar.gz

Download URL txwhy-0.1.1.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
897932332ec5338f21813c8444b239af12005d98009b6cb200ba25821a564494
BLAKE2b-256 checksum
How to use checksums
2f153a5d7e25cf3e2a77d33013e7f94187b03edbb983d2c58cc98e94bc1e3ec2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.3

Release files / txwhy-0.1.1-py3-none-any.whl

Download URL txwhy-0.1.1-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f0d0381bc745a90e6c664d86f3cfaa1fad523fac12bf00b100d175d2273ea55
BLAKE2b-256 checksum
How to use checksums
4b60969848692414a895593e6c01f7605931ed5f04eb1f60fc9d4fb6bc635c0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.3

Security for txwhy 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page