# 📦 Decode Block API

The **Decode Block API** allows you to decode all transactions inside a given block into a structured and human-readable format.

* **Input**:
  * &#x20;**`block_number`**  : number  ***(required)*** – the block number you want to decode.
  * &#x20;**`type`** : string (optional) - protocol type, e.g: DEX &#x20;
  * &#x20;**`protocol`** : string (optional)- protocol name, e.g:  Uniswap V4 .
  * &#x20;**`token`** : string (optional)- token address involving in the transaction.
* **Output**: A standardized JSON array of decoded transactions. Each transaction includes details such as protocol type, user action, participants, tokens, value in USD, and block metadata.

This API is useful when you want to analyze all user activities and protocol interactions that happened within a specific block.

**Endpoint**:<br>

<pre><code><strong>https://[chain_name]-api.txdecoder.xyz/premium/block/decode?block_number=[block number]
</strong><strong>
</strong></code></pre>

**Example code**<br>

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

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

```

\
\
\
**Response format**

```javascript
{
    [transaction_hash_1]: [
        // List of user actions in transaction 1
    ],
    [transaction_hash_2]: [
        // List of user actions in transaction 2
    ]
}
```

**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
        },
    ]
    "0x09782db139021ffa8df9994d74a082d242835690806325537ef4b33f1e4099c7": [
        {
            "type": "DEX",
            "protocol": "Uniswap V3",
            "source": "Uniswap V3",
            "action": "swap",
            "participants": [
                {
                    "address": "0x6532fEcD7f475119Eb2548294A9371728FA447a9",
                    "type": "signer"
                },
                {
                    "address": "0xEff6cb8b614999d130E537751Ee99724D01aA167",
                    "type": "to"
                }
            ],
            "pool_id": "0xd31d41DfFa3589bB0c0183e46a1eed983a5E5978",
            "tokens": [
                {
                    "address": "0xbe0Ed4138121EcFC5c0E56B40517da27E6c5226B",
                    "name": "Aethir Token",
                    "symbol": "ATH",
                    "decimals": 18,
                    "ui_amount": "208874.425628805902533533",
                    "amount": "2.08874425628805902533533e+23",
                    "type": "swap_from"
                },
                {
                    "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
                    "name": "Wrapped Ether",
                    "symbol": "WETH",
                    "decimals": 18,
                    "ui_amount": "1.653190493186746577",
                    "amount": "1653190493186746577",
                    "type": "swap_to"
                }
            ],
            "value_usd": 7801.25715020387,
            "log_index": 101,
            "block_number": 23187124,
            "block_hash": "0x0226dfc0c5ab0b5cc331d94bbda20664e28ce8aa730777a9855d42c7cd79ccae",
            "tx_hash": "0x09782db139021ffa8df9994d74a082d242835690806325537ef4b33f1e4099c7",
            "timestamp": 1755751139
        }
    ]
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://txdecoder.gitbook.io/docs/api-documentations/decode-block-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
