# Chainstate

## GET /chainstate

> Get chain tip handler.

```json
{"openapi":"3.0.3","info":{"title":"emily-openapi-spec","version":"0.1.0"},"servers":[{"url":"http://localhost:3031","description":"Local Emily server"},{"url":"https://sbtc-emily.com","description":"Production Emily server"},{"url":"https://temp.sbtc-emily-dev.com","description":"Testnet Emily server"}],"paths":{"/chainstate":{"get":{"tags":["chainstate"],"summary":"Get chain tip handler.","operationId":"getChainTip","responses":{"200":{"description":"Chain tip retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Chainstate"}}}},"404":{"description":"Address not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"405":{"description":"Method not allowed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"Chainstate":{"type":"object","description":"Chainstate.","required":["stacksBlockHeight","stacksBlockHash"],"properties":{"bitcoinBlockHeight":{"type":"integer","format":"int64","description":"Bitcoin block height","nullable":true,"minimum":0},"stacksBlockHash":{"type":"string","description":"Stacks block hash at the height."},"stacksBlockHeight":{"type":"integer","format":"int64","description":"Stacks block height.","minimum":0}}},"ErrorResponse":{"type":"object","description":"Structure representing an error response\nThis is used to serialize error messages in HTTP responses","required":["message"],"properties":{"message":{"type":"string"}}}}}}
```

## GET /chainstate/{height}

> Get chainstate handler.

```json
{"openapi":"3.0.3","info":{"title":"emily-openapi-spec","version":"0.1.0"},"servers":[{"url":"http://localhost:3031","description":"Local Emily server"},{"url":"https://sbtc-emily.com","description":"Production Emily server"},{"url":"https://temp.sbtc-emily-dev.com","description":"Testnet Emily server"}],"paths":{"/chainstate/{height}":{"get":{"tags":["chainstate"],"summary":"Get chainstate handler.","operationId":"getChainstateAtHeight","parameters":[{"name":"height","in":"path","description":"Height of the blockchain data to receive.","required":true,"schema":{"type":"integer","format":"int64","minimum":0}}],"responses":{"200":{"description":"Chainstate retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Chainstate"}}}},"400":{"description":"Invalid request body","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Address not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"405":{"description":"Method not allowed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"Chainstate":{"type":"object","description":"Chainstate.","required":["stacksBlockHeight","stacksBlockHash"],"properties":{"bitcoinBlockHeight":{"type":"integer","format":"int64","description":"Bitcoin block height","nullable":true,"minimum":0},"stacksBlockHash":{"type":"string","description":"Stacks block hash at the height."},"stacksBlockHeight":{"type":"integer","format":"int64","description":"Stacks block height.","minimum":0}}},"ErrorResponse":{"type":"object","description":"Structure representing an error response\nThis is used to serialize error messages in HTTP responses","required":["message"],"properties":{"message":{"type":"string"}}}}}}
```
