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.api import Client
from solders.keypair import Keypair
from txwhy.solana import send_with_repair
client = Client("https://api.mainnet-beta.solana.com")
signature = send_with_repair(client, tx, keypair) # tx: solders VersionedTransaction, bytes or base64
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 verify_repair
check = 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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| txwhy-0.1.0.tar.gz | 18.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| txwhy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.5 kB
Release files / txwhy-0.1.0.tar.gz
| Download URL | txwhy-0.1.0.tar.gz |
|---|---|
| Size | 18.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f19615ecc7f10698f3bba1c8089f95e0c8a8e5517ee1152d8be5ec3b6027a970
|
|
BLAKE2b-256 checksum How to use checksums |
fcdb8cd2dd1d79cf68c39fa649ff95e1cf5da0c33a0c0a0fc0ab40816fbed622
|
| 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.0-py3-none-any.whl
| Download URL | txwhy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ee2b3b383ff8484a0e513bd86271b923836ac412de327932944fc298db69777
|
|
BLAKE2b-256 checksum How to use checksums |
b4a6e49a6c2b0a8221789ff68f4d63159ef6b5b15db596dea2159a800f548d5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.3
|