# Rotating KES

When manually rotating KES keys, you need to make sure your node.counter value is correct.  \
First check your current Operational Certificate values by running this command:

```
cardano-cli conway query kes-period-info --mainnet  \
  --op-cert-file $NODE_HOME/node.cert
```

Take note of the qKesNodeStateOperationalCertificateNumber.  The number in your node.counter should be:

* 0 if you have never made a block in the history of your pool
* 1 greater than the value of qKesNodeStateOperationalCertificateNumber otherwise

If you find your node.counter has a different value, back it up then create a new node.counter file Using the command below.   Remember to change the number 8 to the current value of qKesNodeStateOperationalCertificateNumber:

```
cd $HOME/cold-keys/
cardano-cli conway node new-counter \
--cold-verification-key-file node.vkey \
--counter-value $((8 + 1)) \
--operational-certificate-issue-counter-file node.counter

## Continue with your KES Rotation
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blockchainlens.gitbook.io/cardano-spot-check/tips/rotating-kes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
