# starknet_getStorageProof

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

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

Returns Merkle inclusion proofs for selected elements of the Starknet state at a given block

Reference: https://www.alchemy.com/docs/chains/starknet/starknet-api-endpoints/starknet-get-storage-proof

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| block_id | object or enum | Yes | The hash of the requested block, or number (height) of the requested block, or a block tag  |
| class_hashes | string[] | No | Class hashes to prove inclusion in the classes trie |
| contract_addresses | string[] | No | Contract addresses to prove inclusion in the contracts trie |
| contracts_storage_keys | object[] | No | Storage keys to prove for specific contracts |

## Result

**result** (object): Inclusion proofs for requested state elements at the given block

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://starknet-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "starknet_getStorageProof",
  "params": [
    {
      "block_hash": "string"
    },
    [
      "string"
    ],
    [
      "string"
    ],
    [
      {
        "contract_address": "string",
        "storage_keys": [
          "string"
        ]
      }
    ]
  ]
}'
```

### JavaScript

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

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

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "starknet_getStorageProof",
    "params": [{ "block_hash": "string" }, ["string"], ["string"], [
            {
                "contract_address": "string",
                "storage_keys": ["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://starknet-mainnet.g.alchemy.com/v2/docs-demo"

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

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://starknet-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\": \"starknet_getStorageProof\",\n  \"params\": [\n    {\n      \"block_hash\": \"string\"\n    },\n    [\n      \"string\"\n    ],\n    [\n      \"string\"\n    ],\n    [\n      {\n        \"contract_address\": \"string\",\n        \"storage_keys\": [\n          \"string\"\n        ]\n      }\n    ]\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: starknet_getStorageProof
description: Returns Merkle inclusion proofs for selected elements of the Starknet state at a given block
paramStructure: by-name
params:
  - name: block_id
    description: |
      The hash of the requested block, or number (height) of the requested block, or a block tag
    required: true
    schema:
      title: Block id
      description: Block hash, number or tag
      oneOf:
        - title: Block hash
          type: object
          required:
            - block_hash
          properties:
            block_hash:
              title: Block hash
              description: The hash identifying a block
              type: string
              pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
        - title: Block number
          type: object
          required:
            - block_number
          properties:
            block_number:
              title: Block number
              description: The block's number (its height)
              type: integer
              minimum: 0
        - title: Block tag
          description: A tag specifying a dynamic reference to a block
          type: string
          enum:
            - latest
            - pending
  - name: class_hashes
    description: Class hashes to prove inclusion in the classes trie
    required: false
    schema:
      type: array
      items:
        title: Field element
        description: A field element. Represented by at most 63 hex digits
        type: string
        pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
  - name: contract_addresses
    description: Contract addresses to prove inclusion in the contracts trie
    required: false
    schema:
      type: array
      items:
        title: Address
        description: A contract address
        type: string
        pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
  - name: contracts_storage_keys
    description: Storage keys to prove for specific contracts
    required: false
    schema:
      type: array
      items:
        type: object
        required:
          - contract_address
          - storage_keys
        properties:
          contract_address:
            title: Address
            description: A contract address
            type: string
            pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
          storage_keys:
            type: array
            items:
              title: Storage key
              description: |
                A storage key. Represented as up to 62 hex digits, 3 bits, and 5 leading zeroes.
              type: string
              pattern: ^0x(0|[0-7]{1}[a-fA-F0-9]{0,62})$
result:
  name: result
  description: Inclusion proofs for requested state elements at the given block
  schema:
    title: StorageProof
    type: object
    properties:
      classes_proof:
        description: Proofs for requested class hashes (if any)
        type: array
        items:
          type: object
          required:
            - class_hash
            - proof
          properties:
            class_hash:
              title: Field element
              description: A field element. Represented by at most 63 hex digits
              type: string
              pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
            proof:
              description: Merkle path nodes (top→bottom)
              type: array
              items:
                type: string
      contracts_proof:
        description: Proofs for requested contract addresses (if any)
        type: array
        items:
          type: object
          required:
            - contract_address
            - proof
          properties:
            contract_address:
              title: Address
              description: A contract address
              type: string
              pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
            proof:
              type: array
              items:
                type: string
      storage_proofs:
        description: Proofs for requested (contract, storage_key) pairs (if any)
        type: array
        items:
          type: object
          required:
            - contract_address
            - storage_key
            - proof
          properties:
            contract_address:
              title: Address
              description: A contract address
              type: string
              pattern: ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
            storage_key:
              title: Storage key
              description: |
                A storage key. Represented as up to 62 hex digits, 3 bits, and 5 leading zeroes.
              type: string
              pattern: ^0x(0|[0-7]{1}[a-fA-F0-9]{0,62})$
            proof:
              type: array
              items:
                type: string
```
