# trace_replayBlockTransactions

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://eth-mainnet.g.alchemy.com/v2/{apiKey}

Reference: https://www.alchemy.com/docs/node/trace-api/trace-api-endpoints/trace-replay-block-transactions

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| blockIdentifier | string | Yes | Block identifier as a string. This can be a block hash, a block number (in hex), or a block tag (such as "latest", "finalized", etc.).  |
| traceTypes | enum[] | Yes | Array of trace types to return. Valid values include "trace" and "stateDiff".  |

## Result

**Block Transactions Traces** (object[]): Returns an array of trace objects for each transaction in the block.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "trace_replayBlockTransactions",
  "params": [
    "0x2ed119",
    [
      "trace"
    ]
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "jsonrpc": "2.0",
    "id": 0,
    "result": [
      {
        "name": "trace item",
        "value": {
          "blockHash": "0x7eb25504e4c202cf3d62fd585d3e238f592c780cca82dacb2ed3cb5b38883add",
          "blockNumber": 3068185,
          "action": {
            "callType": "call",
            "from": "0xaa7b131dc60b80d3cf5e59b5a21a666aa039c951",
            "gas": "0x0",
            "input": "0x",
            "to": "0xd40aba8166a212d6892125f079c33e6f5ca19814",
            "value": "0x4768d7effc3fbe"
          },
          "result": {
            "gasUsed": "0x0",
            "output": "0x"
          },
          "subtraces": 0,
          "traceAddress": [],
          "transactionHash": "0x07da28d752aba3b9dd7060005e554719c6205c8a3aea358599fc9b245c52f1f6",
          "transactionPosition": 0,
          "type": "call"
        }
      },
      {
        "name": "trace item",
        "value": {
          "blockHash": "0x7eb25504e4c202cf3d62fd585d3e238f592c780cca82dacb2ed3cb5b38883add",
          "blockNumber": 3068185,
          "action": {
            "callType": "call",
            "from": "0x4f11ba23bb526c0486d83c6a8f18f632f3fc172a",
            "gas": "0x0",
            "input": "0x",
            "to": "0x7ed1e469fcb3ee19c0366d829e291451be638e59",
            "value": "0x446cde325fbfbe"
          },
          "result": {
            "gasUsed": "0x0",
            "output": "0x"
          },
          "subtraces": 0,
          "traceAddress": [],
          "transactionHash": "0x056f11efb5da4ff7cf8523cfcef08393e5dd2ff3ab3223e4324426d285d7ae92",
          "transactionPosition": 1,
          "type": "call"
        }
      }
    ]
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://eth-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "trace_replayBlockTransactions",
  "params": [
    "0x2ed119",
    [
      "trace"
    ]
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'trace_replayBlockTransactions',
    params: ['0x2ed119', ['trace']]
  })
};

fetch('https://eth-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://eth-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "trace_replayBlockTransactions",
    "params": ["0x2ed119", ["trace"]]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://eth-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"trace_replayBlockTransactions\",\n  \"params\": [\n    \"0x2ed119\",\n    [\n      \"trace\"\n    ]\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://eth-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"trace_replayBlockTransactions\",\n  \"params\": [\n    \"0x2ed119\",\n    [\n      \"trace\"\n    ]\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://eth-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"trace_replayBlockTransactions\",\n  \"params\": [\n    \"0x2ed119\",\n    [\n      \"trace\"\n    ]\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: trace_replayBlockTransactions
summary: Replays all transactions in a block, returning the requested traces for each transaction.
params:
  - name: blockIdentifier
    required: true
    description: |
      Block identifier as a string. This can be a block hash, a block number (in hex), or a block tag (such as "latest", "finalized", etc.).
    schema:
      type: string
      default: finalized
  - name: traceTypes
    required: true
    description: |
      Array of trace types to return. Valid values include "trace" and "stateDiff".
    schema:
      type: array
      default:
        - trace
      items:
        type: string
        enum:
          - trace
          - stateDiff
result:
  name: Block Transactions Traces
  description: Returns an array of trace objects for each transaction in the block.
  schema:
    type: array
    items:
      type: object
      properties:
        blockHash:
          title: 32 byte hex value (any case)
          type: string
          pattern: ^0[xX][0-9A-Fa-f]{64}$
        blockNumber:
          type: integer
        action:
          type: object
          properties:
            callType:
              type: string
            from:
              title: hex encoded address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            gas:
              type: string
            input:
              type: string
            to:
              title: hex encoded address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            value:
              type: string
        result:
          type: object
          properties:
            gasUsed:
              type: string
            output:
              type: string
        subtraces:
          type: integer
        traceAddress:
          type: array
          items:
            type: string
        transactionHash:
          title: 32 byte hex value (any case)
          type: string
          pattern: ^0[xX][0-9A-Fa-f]{64}$
        transactionPosition:
          type: integer
        type:
          type: string
examples:
  - name: trace_replayBlockTransactions example
    params:
      - name: blockIdentifier
        value: '0x2ed119'
      - name: traceTypes
        value:
          - trace
    result:
      name: trace_replayBlockTransactions response
      value:
        jsonrpc: '2.0'
        id: 0
        result:
          - name: trace item
            value:
              blockHash: '0x7eb25504e4c202cf3d62fd585d3e238f592c780cca82dacb2ed3cb5b38883add'
              blockNumber: 3068185
              action:
                callType: call
                from: '0xaa7b131dc60b80d3cf5e59b5a21a666aa039c951'
                gas: '0x0'
                input: 0x
                to: '0xd40aba8166a212d6892125f079c33e6f5ca19814'
                value: '0x4768d7effc3fbe'
              result:
                gasUsed: '0x0'
                output: 0x
              subtraces: 0
              traceAddress: []
              transactionHash: '0x07da28d752aba3b9dd7060005e554719c6205c8a3aea358599fc9b245c52f1f6'
              transactionPosition: 0
              type: call
          - name: trace item
            value:
              blockHash: '0x7eb25504e4c202cf3d62fd585d3e238f592c780cca82dacb2ed3cb5b38883add'
              blockNumber: 3068185
              action:
                callType: call
                from: '0x4f11ba23bb526c0486d83c6a8f18f632f3fc172a'
                gas: '0x0'
                input: 0x
                to: '0x7ed1e469fcb3ee19c0366d829e291451be638e59'
                value: '0x446cde325fbfbe'
              result:
                gasUsed: '0x0'
                output: 0x
              subtraces: 0
              traceAddress: []
              transactionHash: '0x056f11efb5da4ff7cf8523cfcef08393e5dd2ff3ab3223e4324426d285d7ae92'
              transactionPosition: 1
              type: call
```
