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

# Blocks

Returns all archived block data. While user commands and snark work is also available, they each have dedicated collections to ease the querying and filtering of very deeply nested objects.

## Return the last 10 blocks from the canonical chain

```json theme={null}
{
  blocks(query: { canonical: true }, sortBy: DATETIME_DESC, limit: 10) {
    creatorAccount {
      publicKey
    }
    stateHash
    dateTime
    protocolState {
      consensusState {
        blockHeight
      }
    }
    transactions {
      coinbase
    }
  }
}
```

## Find all blocks produced by a public key

This query returns all blocks seen by the explorer node, whether on the canonical chain or not.

```json theme={null}
{
  blocks(
    query: {
      creatorAccount: {
        publicKey: "B62qnZwmdaN8yHvonypfcHxCn2dRb3fRK7jKK8CmrG3trRhuUfE58iA"
      }
    }
    sortBy: DATETIME_DESC
  ) {
    creatorAccount {
      publicKey
    }
    stateHash
    protocolState {
      consensusState {
        blockHeight
      }
    }
  }
}
```

## Find all blocks produced past a certain date

Add a date filter to limit your blocks by date.

```json theme={null}
{
  blocks(
    query: {
      dateTime_gte: "2021-01-31T00:00:00Z"
    }
    sortBy: DATETIME_DESC
  ) {
    creatorAccount {
      publicKey
    }
    dateTime
    stateHash
    protocolState {
      consensusState {
        blockHeight
      }
    }
  }
}
```

## Find a block by state hash

Get the full details for a block based on the protocol state hash of the block.

> When returning a single result, you can use the block query. The blocks query will return multiple matching results.

```json theme={null}
{
  block(
    query: {
      stateHash: "3NKF9BSvELt38KqhCYRVTjfY6BbGLHSXqQjoXRa51MRUCE736Wsh"
    }
  ) {
    creatorAccount {
      publicKey
    }
    dateTime
    stateHash
    protocolState {
      consensusState {
        blockHeight
      }
    }
  }
}
```

## Find a canonical block by height

Find the canonical block for a specific height. Remember that a canonical block can be updated for `k`  blocks before it reaches finality!

```json theme={null}
{
  block(
    query: {canonical: true, blockHeight: 1212}
  ) {
    stateHash
    protocolState {
      consensusState {
        blockHeight
      }
    }
    winnerAccount {
      publicKey
    }
    creatorAccount {
      publicKey
    }
    transactions {
      coinbase
    }
  }
}
```

## Return all blocks between two heights

Filter your queries based on the block height to retrieve a range of blocks based on height.

```json theme={null}
{
  blocks(
    query: {
      AND: [
        { canonical: true }
        { blockHeight_gte: 100 }
        { blockHeight_lte: 105 }
      ]
    }
  ) {
    stateHash
    protocolState {
      consensusState {
        blockHeight
      }
    }
    winnerAccount {
      publicKey
    }
    creatorAccount {
      publicKey
    }
    transactions {
      coinbase
    }
  }
}
```
