# zks_getProof

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

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

This method generates Merkle proofs for one or more storage values associated with a specific account, accompanied by a proof of their authenticity.

Reference: https://www.alchemy.com/docs/chains/zksync/zk-sync-api-endpoints/zks-get-proof

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Address | string | Yes | Account address to fetch storage values and proofs for. |
| Storage keys | string[] | Yes | The storage keys in the account. |
| L1 batch number | string | Yes | Number of the L1 batch specifying the point in time at which the requested values are returned. |

## Result

**Proof** (object): The account details and proofs for storage keys.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "zks_getProof",
  "params": [
    "0x0000000000000000000000000000000000008003",
    [
      "0x8b65c0cf1012ea9f393197eb24619fd814379b298b238285649e14f936a5eb12"
    ],
    354895
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "address": "0x0000000000000000000000000000000000008003",
    "storageProof": [
      {
        "key": "0x8b65c0cf1012ea9f393197eb24619fd814379b298b238285649e14f936a5eb12",
        "proof": [
          "0xe3e8e49a998b3abf8926f62a5a832d829aadc1b7e059f1ea59ffbab8e11edfb7"
        ],
        "value": "0x0000000000000000000000000000000000000000000000000000000000000060",
        "index": 27900957
      }
    ]
  },
  "id": 1
}
```

## Code Examples

### cURL

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

### JavaScript

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

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

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "zks_getProof",
    "params": ["0x0000000000000000000000000000000000008003", ["0x8b65c0cf1012ea9f393197eb24619fd814379b298b238285649e14f936a5eb12"], "string"]
}
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://zksync-mainnet.g.alchemy.com/v2/docs-demo"

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

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://zksync-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\": \"zks_getProof\",\n  \"params\": [\n    \"0x0000000000000000000000000000000000008003\",\n    [\n      \"0x8b65c0cf1012ea9f393197eb24619fd814379b298b238285649e14f936a5eb12\"\n    ],\n    \"string\"\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: zks_getProof
summary: Generates Merkle proofs for storage values associated with a specific account.
description: This method generates Merkle proofs for one or more storage values associated with a specific account, accompanied by a proof of their authenticity.
params:
  - name: Address
    required: true
    description: Account address to fetch storage values and proofs for.
    schema:
      title: hex encoded address
      type: string
      pattern: ^0x[0-9a-fA-F]{40}$
  - name: Storage keys
    required: true
    description: The storage keys in the account.
    schema:
      type: array
      items:
        title: 32 hex encoded bytes
        type: string
        pattern: ^0x[0-9a-f]{64}$
  - name: L1 batch number
    required: true
    description: Number of the L1 batch specifying the point in time at which the requested values are returned.
    schema:
      title: hex encoded 32-bit unsigned integer
      type: string
      pattern: ^0x[0-9a-fA-F]{1,8}$
result:
  name: Proof
  description: The account details and proofs for storage keys.
  schema:
    type: object
    title: Account Proof
    required:
      - address
      - storageProof
    properties:
      address:
        title: hex encoded address
        type: string
        pattern: ^0x[0-9a-fA-F]{40}$
        description: Account address associated with the storage proofs.
      storageProof:
        type: array
        description: Array of storage proofs for the requested keys.
        items:
          type: object
          title: Storage Proof
          required:
            - key
            - proof
            - value
            - index
          properties:
            key:
              title: 32 hex encoded bytes
              type: string
              pattern: ^0x[0-9a-f]{64}$
              description: Storage key for which the proof is provided.
            proof:
              type: array
              description: Merkle proof hashes from root to leaf.
              items:
                title: 32 byte hex value
                type: string
                pattern: ^0x[0-9a-f]{64}$
            value:
              title: 32 hex encoded bytes
              type: string
              pattern: ^0x[0-9a-f]{64}$
              description: Value stored in the specified storage key.
            index:
              type: integer
              description: 1-based index representing the position of the tree entry within the Merkle tree.
examples:
  - name: zks_getProof example
    params:
      - name: Address
        value: '0x0000000000000000000000000000000000008003'
      - name: Storage keys
        value:
          - '0x8b65c0cf1012ea9f393197eb24619fd814379b298b238285649e14f936a5eb12'
      - name: L1 batch number
        value: 354895
    result:
      name: Proof
      value:
        address: '0x0000000000000000000000000000000000008003'
        storageProof:
          - key: '0x8b65c0cf1012ea9f393197eb24619fd814379b298b238285649e14f936a5eb12'
            proof:
              - '0xe3e8e49a998b3abf8926f62a5a832d829aadc1b7e059f1ea59ffbab8e11edfb7'
            value: '0x0000000000000000000000000000000000000000000000000000000000000060'
            index: 27900957
```
