> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Root of a given state

> The /eth/v1/beacon/states/{state_id}/root method calculates the HashTreeRoot for a state with a given stateId. Chainstack via Chainstack.

The `/eth/v1/beacon/states/{state_id}/root` method calculates the HashTreeRoot for a state with a given `stateId`. The same value will be returned if `stateId` is a root.

Developers can use this method to compute the HashTreeRoot of a given state, which is useful in various Ethereum operations.

<Check>
  **Get your own node endpoint today**

  [Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required.

  You can sign up with your GitHub, X, Google, or Microsoft account.
</Check>

## Parameters

* `state_id` — the identifier of the state. This can be one of the following:
  * `head` — the canonical head in the node's view.
  * `genesis` — the very first or initial state of the Beacon Chain.
  * `finalized` — the latest state finalized, meaning the network has accepted it, and a reorganization is extremely unlikely.
  * `justified` — the recent state that has been justified is the first step before finalization in the Ethereum 2.0 Proof of Stake consensus mechanism. This means that a sufficient number of validators have agreed on this state.
  * `<slot>` — a slot is a period of time in the Ethereum protocol during which a block can be proposed.
  * `<hex encoded stateRoot with 0x prefix>` - The state root encoded in hexadecimal.

## Response

* `object` — an object with the following properties:
  * `execution_optimistic` — Indicates whether the response references an unverified execution payload. If true, the optimistic information may be invalidated at a later time. If this field is not present, the value should be assumed to be false.
  * `finalized` — Indicates whether the response references the finalized history of the chain, as determined by the fork choice. If this field is not present, additional calls are necessary to compare the epoch of the requested information with the finalized checkpoint.
  * `data` — Contains an object with one property:
    * `root` — The HashTreeRoot of the BeaconState object.
      * `format` — The format of the root, which is hexadecimal.
      * `description` — HashTreeRoot of the BeaconState object.


## OpenAPI

````yaml /openapi/ethereum_beacon_chain_api/state/getStateRoot.json GET /0a9d79d93fb2f4a4b1e04695da2b77a7/eth/v1/beacon/states/{state_id}/root
openapi: 3.0.0
info:
  title: Ethereum Beacon Chain API
  version: 1.0.0
  description: API for interacting with the Ethereum 2.0 Beacon Chain
servers:
  - url: https://beacon-nd-422-757-666.p2pify.com
security: []
paths:
  /0a9d79d93fb2f4a4b1e04695da2b77a7/eth/v1/beacon/states/{state_id}/root:
    get:
      tags:
        - Beacon
      summary: Get the root of a given state
      operationId: getStateRoot
      parameters:
        - name: state_id
          in: path
          required: true
          description: >-
            State identifier which can be a slot number, an epoch number, a
            block root, or 'genesis', 'head'  (default is 'head').
          schema:
            type: string
            default: head
      responses:
        '200':
          description: Successful response with state root information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StateRoot'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    StateRoot:
      type: object
      properties:
        root:
          type: string
          format: byte
          description: The root of the specified state.
    Error:
      type: object
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string

````