> For the complete documentation index, see [llms.txt](https://txdecoder.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://txdecoder.gitbook.io/docs/api-documentations/decode-transaction-api.md).

# 🔎 Decode Transaction API

The **Decode Transaction API** allows you to decode any blockchain transaction into a structured and human-readable format.

* **Input**:
  * &#x20;**`tx_hash`** :string ***(required)*** – the hash of the transaction you want to decode.
  * &#x20;**`type`** : string (optional)- protocol type, e.g: DEX .
  * &#x20;**`protocol`** : string (optional)- protocol name, e.g:  Uniswap V4 .
  * &#x20;**`token`** : string (optional)- token address involving in the transaction.
* **Output**: A standardized JSON object that includes the transaction’s protocol type, user action, participants, tokens involved, value in USD, and other relevant metadata.

This API makes it easy to transform raw blockchain transaction data into meaningful business or user activity insights.

**Endpoint**<br>

```
https://[chain_name]-api.txdecoder.xyz/premium/transaction/decode?tx_hash=[transaction_hash]

```

**Example code**

```javascript
const axios = require('axios')

const main = async() => {
    const { data } = await axios.get(
    `https://ethereum-api.txdecoder.xyz/premium/transaction/decode?tx_hash=0xf74e5042eb57b5cd0e308e8b3108c9a0d631514829aeee728e40e61564ced0ba`,
    {
        headers: {
            "x-api-key": process.env.API_KEY
        }
    })
    console.log(data)
}
main()

```

\
**Response format**

```javascript
{
    [transaction_hash]: [
        // List of user actions
    ]
}
```

**Example Response**<br>

```
{
    "0xf74e5042eb57b5cd0e308e8b3108c9a0d631514829aeee728e40e61564ced0ba": [
        {
            "type": "LENDING",
            "protocol": "Morpho",
            "source": "Morpho",
            "action": "repay",
            "participants": [
                {
                    "address": "0x9fb1750Da6266a05601855bb62767eBC742707B1",
                    "type": "signer"
                },
                {
                    "address": "0x9fb1750Da6266a05601855bb62767eBC742707B1",
                    "type": "repayer"
                },
                {
                    "address": "0x4095F064B8d3c3548A3bebfd0Bbfd04750E30077",
                    "type": "initiator"
                }
            ],
            "pool_id": "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
            "tokens": [
                {
                    "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
                    "name": "USD Coin",
                    "symbol": "USDC",
                    "decimals": 6,
                    "amount": "264463759538",
                    "ui_amount": "264463.759538"
                }
            ],
            "value_usd": 264463.759538,
            "extra_data": {
                "shares": "246984185247671317"
            },
            "log_index": 89,
            "block_number": 23187124,
            "block_hash": "0x0226dfc0c5ab0b5cc331d94bbda20664e28ce8aa730777a9855d42c7cd79ccae",
            "tx_hash": "0xf74e5042eb57b5cd0e308e8b3108c9a0d631514829aeee728e40e61564ced0ba",
            "timestamp": 1755751139
        },
    ]
}

```
