# eth_getWithdrawalProof

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

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

Returns the Merkle proof for a given account (and optionally some storage keys) against the withdrawal state root used by MegaETH's L2→L1 withdrawal flow. MegaETH is an OP Stack chain, and withdrawals are initiated by writing to the predeployed `L2ToL1MessagePasser` at `0x4200000000000000000000000000000000000016`; this method returns the account/storage proof needed to prove and finalize a withdrawal on L1. The parameter and result shape match `eth_getProof`.

Reference: https://www.alchemy.com/docs/chains/megaeth/mega-eth-api-endpoints/eth-get-withdrawal-proof

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Address | string | Yes | The address of the account to generate the proof for. For withdrawal proofs, this is typically the `L2ToL1MessagePasser` predeploy at `0x4200000000000000000000000000000000000016`. |
| StorageKeys | string[] | Yes | An array of storage keys (slots) to generate proofs for. For a withdrawal, this is the message slot in the `L2ToL1MessagePasser` `sentMessages` mapping corresponding to the withdrawal being proven. May be empty to fetch only the account proof. |
| Block | string or enum | Yes | The block number, tag, or hash at which to generate the proof. Callers proving a withdrawal on L1 typically use the L2 block that corresponds to the latest output root posted to the `L2OutputOracle` / `DisputeGameFactory` on L1. |

## Result

**Withdrawal proof** (object): An object containing the account proof and storage proofs for the requested address and storage keys against the withdrawal state trie.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_getWithdrawalProof",
  "params": [
    "0x4200000000000000000000000000000000000016",
    [
      "0x0000000000000000000000000000000000000000000000000000000000000000"
    ],
    "latest"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "address": "0x4200000000000000000000000000000000000016",
    "balance": "0x0",
    "codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
    "nonce": "0x0",
    "storageHash": "0xc14bc35540a7e2e36d07ab3404faa5d595fc003be1dd581f3ec8b6794b228741",
    "accountProof": [],
    "storageProof": [
      {
        "key": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "value": "0x0",
        "proof": [
          "0xf90211a085022a3c75f381ae55fc1dea9b8428575a61c6af2cba4e7cda56611b51160964a019aa374163ee898334c55b71ea66862d8a1f2182d9cb628d36bbecbda47bc0ada05bd02c6955c5a0c7b3c51f920e7cf87acaa0eee9cd35658d29d3de32fe7f8beba0ab150e8bbfb33c2c11d6a249b289b4c70838ce791727a3aacde0fffdb3289013a09bd1dba3a75bcd4ec2fea91a1038726bc6461bf6da64f66313d8154fc227102da06afe6053ef8192a8a3dcc328f6b763a4a414238851109a0484da30ac8bf03266a0a854e99f71cb91635aa1cb1e624f716857bf030e6a4fbe9478d44c239b53086aa08e39356a1be08b8f216f03d9353d50613c75a98e9d857335672ffb83f50e976fa0fae826709a4b7cf1bacbcdbdc15dc8ffe62e92f024d0e790bf6d191f8f9b97fea0c951b4adcc2e21290940908d8642c9dc338295cd6193c805c033b4dfead6c698a0e31d80cbb6a3f3755e1d5a7afca4709b338e5c8d3d2a3012b4d6f4637a4f8b55a03ba018a8eb9e89e549397239f4a260fa84774078e5b6f6039de435b40ada4659a04b808d306505c575bc173d31a5f5af0e2488e3f15c19fda23c73f4f4a15cd5e4a0d95caaaa3aa842505b212f73fa6466c8af4628af6a9649441349ff73a0c94beea0695c94a790ef02a58b755249ef4c2f4f7267bd0ba902ae7ee1c9f75fd00ec6daa05c85ad78c50797646583f10ce8d69d34d8f9075133caff79adc5cad88735ce1680",
          "0xf8d180a0ebb27f659515f870028e776b7cae4008653d3775ab0687114a5d668971334962a0b1a4a8c685fd7f40b9823cbf07cf54c70671131db2b0bed7d5f56baa133397eba00ad98feec470de1686a7773d1ee5c4d11082af4008aa038a43b61c9af6c8b1b780808080a02374b1b01f575eb984ae09a087116b5b707264d2e54f28b4e5527d83fe1396ac80a064c59d8430486480a56ba254614900823e5ecf140b0d78aa9443511c3ea7025180a016561199ee9871dc834080947f7445a2306ddead9e9c725ea039af1e781157cb80808080"
        ]
      }
    ]
  },
  "id": 1
}
```

## Code Examples

### cURL

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

### JavaScript

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

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

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_getWithdrawalProof",
    "params": ["0x4200000000000000000000000000000000000016", ["0x0000000000000000000000000000000000000000000000000000000000000000"], "latest"]
}
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://megaeth-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getWithdrawalProof\",\n  \"params\": [\n    \"0x4200000000000000000000000000000000000016\",\n    [\n      \"0x0000000000000000000000000000000000000000000000000000000000000000\"\n    ],\n    \"latest\"\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://megaeth-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getWithdrawalProof\",\n  \"params\": [\n    \"0x4200000000000000000000000000000000000016\",\n    [\n      \"0x0000000000000000000000000000000000000000000000000000000000000000\"\n    ],\n    \"latest\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://megaeth-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\": \"eth_getWithdrawalProof\",\n  \"params\": [\n    \"0x4200000000000000000000000000000000000016\",\n    [\n      \"0x0000000000000000000000000000000000000000000000000000000000000000\"\n    ],\n    \"latest\"\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: eth_getWithdrawalProof
description: Returns the Merkle proof for a given account (and optionally some storage keys) against the withdrawal state root used by MegaETH's L2→L1 withdrawal flow. MegaETH is an OP Stack chain, and withdrawals are initiated by writing to the predeployed `L2ToL1MessagePasser` at `0x4200000000000000000000000000000000000016`; this method returns the account/storage proof needed to prove and finalize a withdrawal on L1. The parameter and result shape match `eth_getProof`.
params:
  - name: Address
    required: true
    description: The address of the account to generate the proof for. For withdrawal proofs, this is typically the `L2ToL1MessagePasser` predeploy at `0x4200000000000000000000000000000000000016`.
    schema:
      title: hex encoded address
      type: string
      pattern: ^0x[0-9a-fA-F]{40}$
  - name: StorageKeys
    required: true
    description: An array of storage keys (slots) to generate proofs for. For a withdrawal, this is the message slot in the `L2ToL1MessagePasser` `sentMessages` mapping corresponding to the withdrawal being proven. May be empty to fetch only the account proof.
    schema:
      title: Storage keys
      type: array
      items:
        title: 32 hex encoded bytes
        type: string
        pattern: ^0x[0-9a-f]{0,64}$
  - name: Block
    required: true
    description: The block number, tag, or hash at which to generate the proof. Callers proving a withdrawal on L1 typically use the L2 block that corresponds to the latest output root posted to the `L2OutputOracle` / `DisputeGameFactory` on L1.
    schema:
      title: Block number, tag, or block hash
      description: Identifies a block by explicit number, a predefined tag (e.g., latest/safe/finalized), or a 32-byte block hash.
      anyOf:
        - title: Block number
          description: Unsigned integer block height (e.g., 0 for genesis).
          type: string
          pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        - title: Block tag
          description: A well-known tag such as "latest", "earliest", "pending", "safe", or "finalized".
          type: string
          enum:
            - earliest
            - finalized
            - safe
            - latest
            - pending
        - title: Block hash
          type: string
          pattern: ^0x[0-9a-f]{64}$
          description: 32-byte Keccak hash of the block header identifying a specific block.
result:
  name: Withdrawal proof
  description: An object containing the account proof and storage proofs for the requested address and storage keys against the withdrawal state trie.
  schema:
    title: Account proof
    type: object
    required:
      - address
      - accountProof
      - balance
      - codeHash
      - nonce
      - storageHash
      - storageProof
    additionalProperties: false
    properties:
      address:
        title: address
        type: string
        pattern: ^0x[0-9a-fA-F]{40}$
      accountProof:
        title: accountProof
        type: array
        items:
          title: hex encoded bytes
          type: string
          pattern: ^0x[0-9a-f]*$
      balance:
        title: balance
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]{0,31})|0$
      codeHash:
        title: codeHash
        type: string
        pattern: ^0x[0-9a-f]{64}$
      nonce:
        title: nonce
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
      storageHash:
        title: storageHash
        type: string
        pattern: ^0x[0-9a-f]{64}$
      storageProof:
        title: Storage proofs
        type: array
        items:
          title: Storage proof
          type: object
          required:
            - key
            - value
            - proof
          additionalProperties: false
          properties:
            key:
              title: key
              type: string
              pattern: ^0x[0-9a-f]{0,64}$
            value:
              title: value
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]{0,31})|0$
            proof:
              title: proof
              type: array
              items:
                title: hex encoded bytes
                type: string
                pattern: ^0x[0-9a-f]*$
examples:
  - name: eth_getWithdrawalProof example
    params:
      - name: Address
        value: '0x4200000000000000000000000000000000000016'
      - name: StorageKeys
        value:
          - '0x0000000000000000000000000000000000000000000000000000000000000000'
      - name: Block
        value: latest
    result:
      name: Withdrawal proof
      value:
        address: '0x4200000000000000000000000000000000000016'
        balance: '0x0'
        codeHash: '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
        nonce: '0x0'
        storageHash: '0xc14bc35540a7e2e36d07ab3404faa5d595fc003be1dd581f3ec8b6794b228741'
        accountProof: []
        storageProof:
          - key: '0x0000000000000000000000000000000000000000000000000000000000000000'
            value: '0x0'
            proof:
              - '0xf90211a085022a3c75f381ae55fc1dea9b8428575a61c6af2cba4e7cda56611b51160964a019aa374163ee898334c55b71ea66862d8a1f2182d9cb628d36bbecbda47bc0ada05bd02c6955c5a0c7b3c51f920e7cf87acaa0eee9cd35658d29d3de32fe7f8beba0ab150e8bbfb33c2c11d6a249b289b4c70838ce791727a3aacde0fffdb3289013a09bd1dba3a75bcd4ec2fea91a1038726bc6461bf6da64f66313d8154fc227102da06afe6053ef8192a8a3dcc328f6b763a4a414238851109a0484da30ac8bf03266a0a854e99f71cb91635aa1cb1e624f716857bf030e6a4fbe9478d44c239b53086aa08e39356a1be08b8f216f03d9353d50613c75a98e9d857335672ffb83f50e976fa0fae826709a4b7cf1bacbcdbdc15dc8ffe62e92f024d0e790bf6d191f8f9b97fea0c951b4adcc2e21290940908d8642c9dc338295cd6193c805c033b4dfead6c698a0e31d80cbb6a3f3755e1d5a7afca4709b338e5c8d3d2a3012b4d6f4637a4f8b55a03ba018a8eb9e89e549397239f4a260fa84774078e5b6f6039de435b40ada4659a04b808d306505c575bc173d31a5f5af0e2488e3f15c19fda23c73f4f4a15cd5e4a0d95caaaa3aa842505b212f73fa6466c8af4628af6a9649441349ff73a0c94beea0695c94a790ef02a58b755249ef4c2f4f7267bd0ba902ae7ee1c9f75fd00ec6daa05c85ad78c50797646583f10ce8d69d34d8f9075133caff79adc5cad88735ce1680'
              - '0xf8d180a0ebb27f659515f870028e776b7cae4008653d3775ab0687114a5d668971334962a0b1a4a8c685fd7f40b9823cbf07cf54c70671131db2b0bed7d5f56baa133397eba00ad98feec470de1686a7773d1ee5c4d11082af4008aa038a43b61c9af6c8b1b780808080a02374b1b01f575eb984ae09a087116b5b707264d2e54f28b4e5527d83fe1396ac80a064c59d8430486480a56ba254614900823e5ecf140b0d78aa9443511c3ea7025180a016561199ee9871dc834080947f7445a2306ddead9e9c725ea039af1e781157cb80808080'
```
