Transaction Parser
Parse, analyze, and test Cardano transactions from CBOR hex.
Overview
TxParser parses Cardano transaction CBOR hex back into a structured MeshTxBuilderBody object. This enables you to analyze transactions, rebuild them with modifications, or run unit tests against transaction logic.
When to use TxParser:
- Debugging transaction building issues
- Analyzing on-chain transactions
- Rebuilding transactions with modifications
- Unit testing transaction logic
- Verifying transaction structure before submission
Quick Start
import { BlockfrostProvider, TxParser } from "@meshsdk/core";
import { CSLSerializer } from "@meshsdk/core-csl";
// Initialize parser
const fetcher = new BlockfrostProvider("<YOUR_API_KEY>");
const serializer = new CSLSerializer();
const txParser = new TxParser(serializer, fetcher);
// Parse a transaction
const txHex = "84a400..."; // Your transaction CBOR hex
const utxos = await wallet.getUtxos(); // Input UTxOs
const txBuilderBody = await txParser.parse(txHex, utxos);
// Inspect the parsed transaction
console.log("Inputs:", txBuilderBody.inputs);
console.log("Outputs:", txBuilderBody.outputs);
console.log("Mints:", txBuilderBody.mints);
// Convert to tester for unit testing
const txTester = txParser.toTester();Documentation
Parser Basics
Parse transactions and rebuild
Unit Testing Transaction
Parse and test transactions with various options
Related
- Transaction Builder — Build transactions
- Providers — Blockchain data providers
- Data Types — Working with Cardano data