# debug_executePayload

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

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

Re-executes a payload on top of the state at `parent_block_hash` and returns the resulting execution witness. The witness comprises the preimages of every hashed trie node, contract code, and unhashed account/storage key that was required during execution, plus any block headers referenced by the `BLOCKHASH` opcode. Together they are the minimum data needed to prove that the payload executes correctly against the parent state, without access to a full node.

This method is used by fault-proof provers and stateless clients on OP Stack chains. On Base it is served from the historical proofs execution extension (`ExEx`); the currently indexed block range can be queried via `debug_proofsSyncStatus`.

Reference: https://www.alchemy.com/docs/chains/base/base-api-endpoints/debug-execute-payload

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Parent block hash | string | Yes | The 32-byte hash of the parent block. The payload is executed on top of the post-state of this parent. |
| Payload attributes | object | Yes | The Optimism-style payload attributes describing the block to re-execute on top of the parent. The base Engine API `PayloadAttributes` fields (`timestamp`, `prevRandao`, `suggestedFeeRecipient`, `withdrawals`, `parentBeaconBlockRoot`) are flattened onto this object; the rollup-specific fields (`transactions`, `noTxPool`, `gasLimit`, `eip1559Params`, `minBaseFee`) are siblings. |

## Result

**Execution witness** (object): The execution witness of the payload. Contains hashed-trie-node preimages, contract-code preimages, unhashed key preimages, and any block headers required for stateless verification.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "debug_executePayload",
  "params": [
    "0x63db51ce4d0ed91c956090d8b413abb85f113442c6a4d8c89fbe1bd535f011ba",
    {
      "timestamp": "0x6a569479",
      "prevRandao": "0x6c6ae66debdd034422a41803af19c8855938f8cca2805d858dc17679cef58c26",
      "suggestedFeeRecipient": "0x4200000000000000000000000000000000000011",
      "withdrawals": [],
      "parentBeaconBlockRoot": "0xb61925b723172852becabbd1ae58da86f59598aedde6983a5ec4144fc5d33eaa",
      "transactions": [],
      "noTxPool": true,
      "gasLimit": "0x17d78400",
      "eip1559Params": "0x000000fa00000006",
      "minBaseFee": 0
    }
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "state": [
      "0xf90211a0..."
    ],
    "codes": [
      "0x60806040..."
    ],
    "keys": [
      "0x0000000000000000000000004200000000000000000000000000000000000011"
    ],
    "headers": []
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://base-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "debug_executePayload",
  "params": [
    "0x63db51ce4d0ed91c956090d8b413abb85f113442c6a4d8c89fbe1bd535f011ba",
    {
      "timestamp": "0x6a569479",
      "prevRandao": "0x6c6ae66debdd034422a41803af19c8855938f8cca2805d858dc17679cef58c26",
      "suggestedFeeRecipient": "0x4200000000000000000000000000000000000011",
      "withdrawals": [],
      "parentBeaconBlockRoot": "0xb61925b723172852becabbd1ae58da86f59598aedde6983a5ec4144fc5d33eaa",
      "transactions": [],
      "noTxPool": true,
      "gasLimit": "0x17d78400",
      "eip1559Params": "0x000000fa00000006",
      "minBaseFee": 0
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'debug_executePayload',
    params: [
      '0x63db51ce4d0ed91c956090d8b413abb85f113442c6a4d8c89fbe1bd535f011ba',
      {
        timestamp: '0x6a569479',
        prevRandao: '0x6c6ae66debdd034422a41803af19c8855938f8cca2805d858dc17679cef58c26',
        suggestedFeeRecipient: '0x4200000000000000000000000000000000000011',
        withdrawals: [],
        parentBeaconBlockRoot: '0xb61925b723172852becabbd1ae58da86f59598aedde6983a5ec4144fc5d33eaa',
        transactions: [],
        noTxPool: true,
        gasLimit: '0x17d78400',
        eip1559Params: '0x000000fa00000006',
        minBaseFee: 0
      }
    ]
  })
};

fetch('https://base-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://base-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "debug_executePayload",
    "params": [
        "0x63db51ce4d0ed91c956090d8b413abb85f113442c6a4d8c89fbe1bd535f011ba",
        {
            "timestamp": "0x6a569479",
            "prevRandao": "0x6c6ae66debdd034422a41803af19c8855938f8cca2805d858dc17679cef58c26",
            "suggestedFeeRecipient": "0x4200000000000000000000000000000000000011",
            "withdrawals": [],
            "parentBeaconBlockRoot": "0xb61925b723172852becabbd1ae58da86f59598aedde6983a5ec4144fc5d33eaa",
            "transactions": [],
            "noTxPool": True,
            "gasLimit": "0x17d78400",
            "eip1559Params": "0x000000fa00000006",
            "minBaseFee": 0
        }
    ]
}
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://base-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"debug_executePayload\",\n  \"params\": [\n    \"0x63db51ce4d0ed91c956090d8b413abb85f113442c6a4d8c89fbe1bd535f011ba\",\n    {\n      \"timestamp\": \"0x6a569479\",\n      \"prevRandao\": \"0x6c6ae66debdd034422a41803af19c8855938f8cca2805d858dc17679cef58c26\",\n      \"suggestedFeeRecipient\": \"0x4200000000000000000000000000000000000011\",\n      \"withdrawals\": [],\n      \"parentBeaconBlockRoot\": \"0xb61925b723172852becabbd1ae58da86f59598aedde6983a5ec4144fc5d33eaa\",\n      \"transactions\": [],\n      \"noTxPool\": true,\n      \"gasLimit\": \"0x17d78400\",\n      \"eip1559Params\": \"0x000000fa00000006\",\n      \"minBaseFee\": 0\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://base-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"debug_executePayload\",\n  \"params\": [\n    \"0x63db51ce4d0ed91c956090d8b413abb85f113442c6a4d8c89fbe1bd535f011ba\",\n    {\n      \"timestamp\": \"0x6a569479\",\n      \"prevRandao\": \"0x6c6ae66debdd034422a41803af19c8855938f8cca2805d858dc17679cef58c26\",\n      \"suggestedFeeRecipient\": \"0x4200000000000000000000000000000000000011\",\n      \"withdrawals\": [],\n      \"parentBeaconBlockRoot\": \"0xb61925b723172852becabbd1ae58da86f59598aedde6983a5ec4144fc5d33eaa\",\n      \"transactions\": [],\n      \"noTxPool\": true,\n      \"gasLimit\": \"0x17d78400\",\n      \"eip1559Params\": \"0x000000fa00000006\",\n      \"minBaseFee\": 0\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://base-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\": \"debug_executePayload\",\n  \"params\": [\n    \"0x63db51ce4d0ed91c956090d8b413abb85f113442c6a4d8c89fbe1bd535f011ba\",\n    {\n      \"timestamp\": \"0x6a569479\",\n      \"prevRandao\": \"0x6c6ae66debdd034422a41803af19c8855938f8cca2805d858dc17679cef58c26\",\n      \"suggestedFeeRecipient\": \"0x4200000000000000000000000000000000000011\",\n      \"withdrawals\": [],\n      \"parentBeaconBlockRoot\": \"0xb61925b723172852becabbd1ae58da86f59598aedde6983a5ec4144fc5d33eaa\",\n      \"transactions\": [],\n      \"noTxPool\": true,\n      \"gasLimit\": \"0x17d78400\",\n      \"eip1559Params\": \"0x000000fa00000006\",\n      \"minBaseFee\": 0\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: debug_executePayload
summary: Re-execute a payload and return the execution witness
description: |-
  Re-executes a payload on top of the state at `parent_block_hash` and returns the resulting execution witness. The witness comprises the preimages of every hashed trie node, contract code, and unhashed account/storage key that was required during execution, plus any block headers referenced by the `BLOCKHASH` opcode. Together they are the minimum data needed to prove that the payload executes correctly against the parent state, without access to a full node.

  This method is used by fault-proof provers and stateless clients on OP Stack chains. On Base it is served from the historical proofs execution extension (`ExEx`); the currently indexed block range can be queried via `debug_proofsSyncStatus`.
x-compute-units: 40
x-rate-limit-cus: 1000
params:
  - name: Parent block hash
    required: true
    description: The 32-byte hash of the parent block. The payload is executed on top of the post-state of this parent.
    schema:
      title: 32 byte hex value
      type: string
      pattern: ^0x[0-9a-f]{64}$
  - name: Payload attributes
    required: true
    description: The Optimism-style payload attributes describing the block to re-execute on top of the parent. The base Engine API `PayloadAttributes` fields (`timestamp`, `prevRandao`, `suggestedFeeRecipient`, `withdrawals`, `parentBeaconBlockRoot`) are flattened onto this object; the rollup-specific fields (`transactions`, `noTxPool`, `gasLimit`, `eip1559Params`, `minBaseFee`) are siblings.
    schema:
      title: Optimism payload attributes
      type: object
      description: Payload attributes for building or re-executing an OP Stack block. The fields of the underlying Engine API `PayloadAttributes` object (`timestamp`, `prevRandao`, `suggestedFeeRecipient`, `withdrawals`, `parentBeaconBlockRoot`) are flattened onto this object; the rollup-specific fields (`transactions`, `noTxPool`, `gasLimit`, `eip1559Params`, `minBaseFee`) are siblings.
      required:
        - timestamp
        - prevRandao
        - suggestedFeeRecipient
      additionalProperties: false
      properties:
        timestamp:
          title: Block timestamp
          description: The block timestamp in seconds since the Unix epoch.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        prevRandao:
          title: prevRandao
          type: string
          pattern: ^0x[0-9a-f]{64}$
          description: The `prevRandao` value for the block, sourced from the L1 beacon chain's `RANDAO` output. 32 bytes.
        suggestedFeeRecipient:
          title: Suggested fee recipient
          description: The address to receive the coinbase reward. On OP Stack chains this is typically `0x4200000000000000000000000000000000000011` (`SequencerFeeVault`).
          type: string
          pattern: ^0x[0-9a-fA-F]{40}$
        withdrawals:
          title: Withdrawals
          description: Post-Shanghai validator withdrawals list. On OP Stack chains this is always an empty array.
          type: array
          items:
            type: object
            title: Validator withdrawal
            required:
              - index
              - validatorIndex
              - address
              - amount
            additionalProperties: false
            properties:
              index:
                title: index of withdrawal
                type: string
                pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
              validatorIndex:
                title: index of validator that generated withdrawal
                type: string
                pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
              address:
                title: recipient address for withdrawal value
                type: string
                pattern: ^0x[0-9a-fA-F]{40}$
              amount:
                title: value contained in withdrawal
                type: string
                pattern: ^0x([1-9a-f]+[0-9a-f]{0,31})|0$
        parentBeaconBlockRoot:
          title: Parent beacon block root
          description: The parent beacon block root, from the Cancun-Deneb fork. 32 bytes. Omit or set to `null` on chains where this fork is not active.
          oneOf:
            - title: 32 byte hex value
              type: string
              pattern: ^0x[0-9a-f]{64}$
            - type: 'null'
        transactions:
          title: Forced transactions
          description: Transactions to force-include at the top of the block, as raw EIP-2718 encoded bytes. On OP Stack this is used for deposit transactions and sequencer-inserted L1 attributes calls.
          type: array
          items:
            title: hex encoded bytes
            type: string
            pattern: ^0x[0-9a-f]*$
        noTxPool:
          title: Skip transaction pool
          description: If `true`, only the transactions in the `transactions` field are included in the block; the mempool is not consulted. Verifiers replaying batch transactions from L1 set this to `true`; the sequencer sets it to `false` while producing blocks.
          type: boolean
        gasLimit:
          title: Gas limit
          description: Exact block gas limit. If unset the block uses the chain's configured default.
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        eip1559Params:
          title: EIP-1559 parameters
          description: Holocene-era EIP-1559 parameters, encoded as an 8-byte value where the high 4 bytes are the base fee update denominator and the low 4 bytes are the elasticity multiplier. Required once the Holocene hardfork is active; before then, omit or set to `null`.
          type: string
          pattern: ^0x[0-9a-f]{16}$
        minBaseFee:
          title: Minimum base fee
          description: Jovian-era minimum base fee (in wei) for the block. Required once the Jovian hardfork is active on the chain; before then, omit or set to `null`.
          type: integer
          minimum: 0
result:
  name: Execution witness
  description: The execution witness of the payload. Contains hashed-trie-node preimages, contract-code preimages, unhashed key preimages, and any block headers required for stateless verification.
  schema:
    title: Execution witness
    type: object
    description: Preimages and headers required to re-execute a payload independently. Used by fault-proof provers and stateless clients.
    additionalProperties: false
    properties:
      state:
        title: Trie node preimages
        description: The preimages of every hashed trie node that was required during execution of the payload, including during state root recomputation. Each entry is an RLP-encoded trie node.
        type: array
        items:
          title: hex encoded bytes
          type: string
          pattern: ^0x[0-9a-f]*$
      codes:
        title: Contract code preimages
        description: The preimages (deployed bytecode) of every contract that was created or accessed during execution of the payload.
        type: array
        items:
          title: hex encoded bytes
          type: string
          pattern: ^0x[0-9a-f]*$
      keys:
        title: Key preimages
        description: The unhashed preimages of every account address and storage slot that was required during execution of the payload. Used to reconstruct the trie paths from their hashes.
        type: array
        items:
          title: hex encoded bytes
          type: string
          pattern: ^0x[0-9a-f]*$
      headers:
        title: RLP-encoded block headers
        description: RLP-encoded block headers required for stateless verification. Includes at minimum the parent header (so the pre-state root can be verified) plus any additional headers referenced by the `BLOCKHASH` opcode during execution.
        type: array
        items:
          title: hex encoded bytes
          type: string
          pattern: ^0x[0-9a-f]*$
examples:
  - name: debug_executePayload example
    params:
      - name: Parent block hash
        value: '0x63db51ce4d0ed91c956090d8b413abb85f113442c6a4d8c89fbe1bd535f011ba'
      - name: Payload attributes
        value:
          timestamp: '0x6a569479'
          prevRandao: '0x6c6ae66debdd034422a41803af19c8855938f8cca2805d858dc17679cef58c26'
          suggestedFeeRecipient: '0x4200000000000000000000000000000000000011'
          withdrawals: []
          parentBeaconBlockRoot: '0xb61925b723172852becabbd1ae58da86f59598aedde6983a5ec4144fc5d33eaa'
          transactions: []
          noTxPool: true
          gasLimit: '0x17d78400'
          eip1559Params: '0x000000fa00000006'
          minBaseFee: 0
    result:
      name: Execution witness
      value:
        state:
          - 0xf90211a0...
        codes:
          - 0x60806040...
        keys:
          - '0x0000000000000000000000004200000000000000000000000000000000000011'
        headers: []
errors:
  - code: -32602
    message: Invalid params. Common causes include a missing or malformed `parent_block_hash`, or missing/mistyped payload attribute fields. Note that after the Jovian hardfork activates on the chain, `minBaseFee` is required; before then it must be omitted.
  - code: -32603
    message: Internal error. Examples include `no header found for Hash(<parent hash>)` when the parent block is not indexed by the historical proofs store (see `debug_proofsSyncStatus` for the current coverage window), and execution failures while producing the witness.
```
