Debug Cardano Transaction
Guide the user through diagnosing and fixing failing Cardano transactions.
Works with any SDK (Mesh, Evolution SDK, PyCardano, cardano-client-lib)
and covers both native script and Plutus script errors.
When to Use
- User has a transaction that fails to build, sign, or submit
- User gets a Cardano ledger error message they do not understand
- User has a Plutus script that fails during execution
- User has a transaction rejected by the node
- User wants to understand why a transaction was rolled back
When NOT to Use
- User wants to build a new transaction from scratch -- use
build-transaction
- User wants to review a smart contract for vulnerabilities -- use
review-contract
- User wants to optimize a validator's execution budget -- use
optimize-validator
- User is designing a token standard -- use
design-token
Key Principles
Read the error message carefully. Cardano error messages are verbose
but precise. They usually tell you exactly what is wrong. The error type
name alone often identifies the problem.
Reproduce before fixing. Ensure you can consistently reproduce the error
before attempting a fix; transaction failures are deterministic, so the same inputs
produce the same error. A root cause you have reproduced beats one reasoned from logs
alone.
Isolate the failure layer. Determine if the error occurs during
transaction building (SDK), during submission (node), or during script
evaluation (Plutus VM).
Check the simple things first. Most transaction failures are caused
by insufficient ADA, missing UTxOs, or wrong network. Check these
before investigating complex script logic.
Use the transaction evaluator. Most SDKs support dry-run evaluation
that simulates the transaction without submitting. Use this to test
fixes before spending real resources.
Workflow
Step 1: Capture the Full Error
Ask the user for:
- The complete error message (not just the first line)
- The SDK and version they are using
- The network (preview, preprod, mainnet)
- The transaction type (send, mint, script interaction, etc.)
- The code that builds the transaction (if available)
Step 2: Search Bundled Documentation
Search the bundled documentation for relevant content:
${CLAUDE_SKILL_DIR}/../../docs/sources/evolution-sdk/ - Evolution SDK docs
${CLAUDE_SKILL_DIR}/../../docs/sources/mesh-sdk/ - Mesh SDK docs
${CLAUDE_SKILL_DIR}/../../docs/sources/pycardano/ - PyCardano docs
${CLAUDE_SKILL_DIR}/../../docs/sources/cardano-client-lib/ - cardano-client-lib docs
${CLAUDE_SKILL_DIR}/../../docs/sources/cardano-node-wiki/ - Cardano node wiki
Step 3: Identify the Error Category
Classify the error into one of these categories:
| Category |
Common Errors |
Likely Cause |
| Value errors |
ValueNotConservedUTxO, OutputTooSmallUTxO |
Math error in inputs/outputs, min-UTxO not met |
| Input errors |
BadInputsUTxO |
UTxO already spent or does not exist |
| Fee errors |
FeeTooSmallUTxO |
Fee calculation incorrect or overridden |
| Collateral errors |
InsufficientCollateral, CollateralContainsNonADA |
Missing or wrong collateral for Plutus tx |
| Script errors |
ScriptFailure, ExUnitsTooBigUTxO |
Plutus script fails or exceeds budget |
| Datum errors |
NonOutputSupplimentaryDatums |
Datum provided but not referenced |
| Signer errors |
MissingRequiredSigners |
Required signature not included |
| Validity errors |
OutsideValidityIntervalUTxO |
Transaction time range does not match current slot |
Search ${CLAUDE_SKILL_DIR}/../../docs/sources/ or see references/common-errors.md for
detailed error explanations.
Step 4: Diagnose the Root Cause
For each error category, follow these diagnostic steps:
Value Errors
- List all transaction inputs and their values (ADA + tokens)
- List all transaction outputs and their values
- Verify: sum(input values) = sum(output values) + fee - mint + burn
- Check each output meets the minimum UTxO value (~1-2 ADA depending on
datum and token bundle size)
- For token transactions: ensure all input tokens appear in outputs
(tokens cannot disappear)
Input Errors
- Check if the UTxO reference (tx_hash#index) exists on-chain
- Verify it has not been consumed by another transaction
- Confirm you are querying the correct network
- Check for race conditions: another transaction may have consumed
the UTxO between query and submit
Fee Errors
- Check if you are manually setting fees instead of letting the SDK
calculate them
- Verify protocol parameters are up to date
- For Plutus transactions: ensure execution units are included in
fee calculation
Collateral Errors
- Verify a collateral input is included in the transaction
- Ensure the collateral UTxO contains only ADA (no native tokens)
- Check collateral amount is at least 150% of the transaction fee
- Verify the collateral UTxO has not been consumed
Script Errors
- Check the redeemer matches what the script expects
- Verify the datum (if spending) matches the expected structure
- Look at script logs/traces for the specific assertion that failed
- Check execution budget -- scripts have CPU and memory limits
- Test the script in an emulator or with
evaluate_tx before submitting
Datum Errors
- If using inline datums: ensure the output has the datum attached
- If using datum hashes: ensure the full datum is included in the
transaction witness set
- Verify datum CBOR encoding matches what the script expects
- Check for Plutus data type mismatches (Constr index, field count)
Signer Errors
- Check which verification key hashes the script requires
in
extra_signatories
- Ensure all required keys are signing the transaction
- For multi-sig native scripts: verify the correct combination of signers
Validity Errors
- Check the transaction's validity interval (valid_from, valid_to)
- Verify current slot is within that interval
- For Plutus scripts that check time: ensure
validity_range is tight
enough for the script's must_be_before / must_be_after checks
- Account for slot-to-POSIX-time conversion
Step 5: Apply the Fix
Once the root cause is identified:
- Explain what went wrong and why
- Provide corrected code for the specific SDK the user is using
- Highlight the exact change (e.g., "add this collateral input" or
"change the output value from X to Y")
- Explain how the fix addresses the root cause
Step 6: Verify the Fix
- Use transaction evaluation (dry run) to test before submitting
- Submit to testnet first
- Verify on a block explorer that the transaction succeeded
- Check all outputs match expectations
Step 7: Prevention
Suggest practices to avoid the error in the future:
- For value errors: Always let the SDK calculate change outputs.
Never manually compute output values.
- For input errors: Query UTxOs immediately before building.
Implement retry logic for concurrent environments.
- For collateral errors: Maintain a dedicated collateral UTxO
(5 ADA, no tokens) and never spend it in regular transactions.
- For script errors: Write comprehensive test cases. Use
property-based testing for validators.
- For datum errors: Define datum types in a shared module used
by both on-chain and off-chain code.
- For validity errors: Set reasonable time windows (e.g., current
time +/- 15 minutes) rather than exact times.
Debugging Tools
Transaction Evaluation (Dry Run)
Most SDKs support evaluating a transaction without submitting:
- Mesh SDK: Use Ogmios
evaluateTx endpoint
- Evolution SDK: Use
client.newTx()...buildEither() for non-throwing inspection (result._tag === "Left" carries a tagged error). On Plutus failure, EvaluationError exposes failures[] with per-script purpose, label, validationError, and traces for trace-message-level debugging
- PyCardano:
context.evaluate_tx(tx)
- cardano-cli:
cardano-cli latest transaction calculate-plutus-script-cost (there is no transaction evaluate subcommand; transaction build also evaluates implicitly)
Block Explorers
Look up transaction hashes, UTxOs, and script addresses.
CBOR Decoders
For inspecting raw transaction bytes:
Script Budget Analysis
When ExUnitsTooBigUTxO occurs:
- Evaluate the transaction to get actual CPU and memory usage
- Compare against protocol limits (mainnet currently: 10,000,000,000 CPU
steps and 16,500,000 memory units per transaction — query
max_tx_ex_steps/max_tx_ex_mem from current protocol parameters rather
than trusting static numbers)
- If close to limits: optimize the validator (use
optimize-validator)
- If far over limits: redesign the approach (fewer script inputs,
simpler logic, batching)
References
references/common-errors.md -- complete error reference with causes and fixes
- Search
${CLAUDE_SKILL_DIR}/../../docs/sources/ for SDK-specific error handling guides
- Cardano ledger errors: https://github.com/IntersectMBO/cardano-ledger
1---2name: debug-transaction3description: Debug failing Cardano transaction, fix transaction error, diagnose ValueNotConservedUTxO, InsufficientCollateral, script failure, budget exceeded, datum mismatch, missing signer, min-UTxO error.4---56<!-- Documentation lookup path: ${CLAUDE_SKILL_DIR}/../../docs/sources/ -->78# Debug Cardano Transaction910Guide the user through diagnosing and fixing failing Cardano transactions.11Works with any SDK (Mesh, Evolution SDK, PyCardano, cardano-client-lib)12and covers both native script and Plutus script errors.1314## When to Use1516- User has a transaction that fails to build, sign, or submit17- User gets a Cardano ledger error message they do not understand18- User has a Plutus script that fails during execution19- User has a transaction rejected by the node20- User wants to understand why a transaction was rolled back2122## When NOT to Use2324- User wants to build a new transaction from scratch -- use `build-transaction`25- User wants to review a smart contract for vulnerabilities -- use `review-contract`26- User wants to optimize a validator's execution budget -- use `optimize-validator`27- User is designing a token standard -- use `design-token`2829## Key Principles30311. **Read the error message carefully.** Cardano error messages are verbose32 but precise. They usually tell you exactly what is wrong. The error type33 name alone often identifies the problem.34352. **Reproduce before fixing.** Ensure you can consistently reproduce the error36 before attempting a fix; transaction failures are deterministic, so the same inputs37 produce the same error. A root cause you have reproduced beats one reasoned from logs38 alone.39403. **Isolate the failure layer.** Determine if the error occurs during41 transaction building (SDK), during submission (node), or during script42 evaluation (Plutus VM).43444. **Check the simple things first.** Most transaction failures are caused45 by insufficient ADA, missing UTxOs, or wrong network. Check these46 before investigating complex script logic.47485. **Use the transaction evaluator.** Most SDKs support dry-run evaluation49 that simulates the transaction without submitting. Use this to test50 fixes before spending real resources.5152## Workflow5354### Step 1: Capture the Full Error5556Ask the user for:57581. The complete error message (not just the first line)592. The SDK and version they are using603. The network (preview, preprod, mainnet)614. The transaction type (send, mint, script interaction, etc.)625. The code that builds the transaction (if available)6364### Step 2: Search Bundled Documentation6566Search the bundled documentation for relevant content:67- `${CLAUDE_SKILL_DIR}/../../docs/sources/evolution-sdk/` - Evolution SDK docs68- `${CLAUDE_SKILL_DIR}/../../docs/sources/mesh-sdk/` - Mesh SDK docs69- `${CLAUDE_SKILL_DIR}/../../docs/sources/pycardano/` - PyCardano docs70- `${CLAUDE_SKILL_DIR}/../../docs/sources/cardano-client-lib/` - cardano-client-lib docs71- `${CLAUDE_SKILL_DIR}/../../docs/sources/cardano-node-wiki/` - Cardano node wiki7273### Step 3: Identify the Error Category7475Classify the error into one of these categories:7677| Category | Common Errors | Likely Cause |78|----------|---------------|--------------|79| Value errors | `ValueNotConservedUTxO`, `OutputTooSmallUTxO` | Math error in inputs/outputs, min-UTxO not met |80| Input errors | `BadInputsUTxO` | UTxO already spent or does not exist |81| Fee errors | `FeeTooSmallUTxO` | Fee calculation incorrect or overridden |82| Collateral errors | `InsufficientCollateral`, `CollateralContainsNonADA` | Missing or wrong collateral for Plutus tx |83| Script errors | `ScriptFailure`, `ExUnitsTooBigUTxO` | Plutus script fails or exceeds budget |84| Datum errors | `NonOutputSupplimentaryDatums` | Datum provided but not referenced |85| Signer errors | `MissingRequiredSigners` | Required signature not included |86| Validity errors | `OutsideValidityIntervalUTxO` | Transaction time range does not match current slot |8788Search `${CLAUDE_SKILL_DIR}/../../docs/sources/` or see `references/common-errors.md` for89detailed error explanations.9091### Step 4: Diagnose the Root Cause9293For each error category, follow these diagnostic steps:9495#### Value Errors96971. List all transaction inputs and their values (ADA + tokens)982. List all transaction outputs and their values993. Verify: sum(input values) = sum(output values) + fee - mint + burn1004. Check each output meets the minimum UTxO value (~1-2 ADA depending on101 datum and token bundle size)1025. For token transactions: ensure all input tokens appear in outputs103 (tokens cannot disappear)104105#### Input Errors1061071. Check if the UTxO reference (tx_hash#index) exists on-chain1082. Verify it has not been consumed by another transaction1093. Confirm you are querying the correct network1104. Check for race conditions: another transaction may have consumed111 the UTxO between query and submit112113#### Fee Errors1141151. Check if you are manually setting fees instead of letting the SDK116 calculate them1172. Verify protocol parameters are up to date1183. For Plutus transactions: ensure execution units are included in119 fee calculation120121#### Collateral Errors1221231. Verify a collateral input is included in the transaction1242. Ensure the collateral UTxO contains only ADA (no native tokens)1253. Check collateral amount is at least 150% of the transaction fee1264. Verify the collateral UTxO has not been consumed127128#### Script Errors1291301. Check the redeemer matches what the script expects1312. Verify the datum (if spending) matches the expected structure1323. Look at script logs/traces for the specific assertion that failed1334. Check execution budget -- scripts have CPU and memory limits1345. Test the script in an emulator or with `evaluate_tx` before submitting135136#### Datum Errors1371381. If using inline datums: ensure the output has the datum attached1392. If using datum hashes: ensure the full datum is included in the140 transaction witness set1413. Verify datum CBOR encoding matches what the script expects1424. Check for Plutus data type mismatches (Constr index, field count)143144#### Signer Errors1451461. Check which verification key hashes the script requires147 in `extra_signatories`1482. Ensure all required keys are signing the transaction1493. For multi-sig native scripts: verify the correct combination of signers150151#### Validity Errors1521531. Check the transaction's validity interval (valid_from, valid_to)1542. Verify current slot is within that interval1553. For Plutus scripts that check time: ensure `validity_range` is tight156 enough for the script's `must_be_before` / `must_be_after` checks1574. Account for slot-to-POSIX-time conversion158159### Step 5: Apply the Fix160161Once the root cause is identified:1621631. Explain what went wrong and why1642. Provide corrected code for the specific SDK the user is using1653. Highlight the exact change (e.g., "add this collateral input" or166 "change the output value from X to Y")1674. Explain how the fix addresses the root cause168169### Step 6: Verify the Fix1701711. Use transaction evaluation (dry run) to test before submitting1722. Submit to testnet first1733. Verify on a block explorer that the transaction succeeded1744. Check all outputs match expectations175176### Step 7: Prevention177178Suggest practices to avoid the error in the future:179180- **For value errors:** Always let the SDK calculate change outputs.181 Never manually compute output values.182- **For input errors:** Query UTxOs immediately before building.183 Implement retry logic for concurrent environments.184- **For collateral errors:** Maintain a dedicated collateral UTxO185 (5 ADA, no tokens) and never spend it in regular transactions.186- **For script errors:** Write comprehensive test cases. Use187 property-based testing for validators.188- **For datum errors:** Define datum types in a shared module used189 by both on-chain and off-chain code.190- **For validity errors:** Set reasonable time windows (e.g., current191 time +/- 15 minutes) rather than exact times.192193## Debugging Tools194195### Transaction Evaluation (Dry Run)196197Most SDKs support evaluating a transaction without submitting:198199- **Mesh SDK:** Use Ogmios `evaluateTx` endpoint200- **Evolution SDK:** Use `client.newTx()...buildEither()` for non-throwing inspection (`result._tag === "Left"` carries a tagged error). On Plutus failure, `EvaluationError` exposes `failures[]` with per-script `purpose`, `label`, `validationError`, and `traces` for trace-message-level debugging201- **PyCardano:** `context.evaluate_tx(tx)`202- **cardano-cli:** `cardano-cli latest transaction calculate-plutus-script-cost` (there is no `transaction evaluate` subcommand; `transaction build` also evaluates implicitly)203204### Block Explorers205206- Preview: https://preview.cardanoscan.io207- Preprod: https://preprod.cardanoscan.io208- Mainnet: https://cardanoscan.io209210Look up transaction hashes, UTxOs, and script addresses.211212### CBOR Decoders213214For inspecting raw transaction bytes:215- https://cbor.me216- `cardano-cli transaction view --tx-file tx.signed`217218### Script Budget Analysis219220When `ExUnitsTooBigUTxO` occurs:2212221. Evaluate the transaction to get actual CPU and memory usage2232. Compare against protocol limits (mainnet currently: 10,000,000,000 CPU224 steps and 16,500,000 memory units per transaction — query225 `max_tx_ex_steps`/`max_tx_ex_mem` from current protocol parameters rather226 than trusting static numbers)2273. If close to limits: optimize the validator (use `optimize-validator`)2284. If far over limits: redesign the approach (fewer script inputs,229 simpler logic, batching)230231## References232233- `references/common-errors.md` -- complete error reference with causes and fixes234- Search `${CLAUDE_SKILL_DIR}/../../docs/sources/` for SDK-specific error handling guides235- Cardano ledger errors: https://github.com/IntersectMBO/cardano-ledger