> For the complete documentation index, see [llms.txt](https://docs.minervachain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.minervachain.org/protocol/account-control.md). Agents can also search and read this documentation through its [MCP server](https://docs.minervachain.org/~gitbook/mcp).

# Account control, rotation and device keys

Sender derivation binds a native transaction to the key the account was created with. That is right before deployment and wrong after a rotation, so Minerva keeps a consensus-enforced record of each account's current control key.

## The account control registry

`AccountControlRegistry` at `0x…0204` stores, per account, `(commitment, algorithm, policyVersion)`. Only the account itself can write its record, and the version can only increase. The account writes version 0 at construction and bumps it on every `rotatePQKey`, `enrollDeviceKey` and `revokeDeviceKey`.

The node reads these slots directly during transaction validation. The storage layout is pinned by a Foundry test and a Go round-trip test so the two sides cannot drift.

Read it over RPC:

```json
{"jsonrpc":"2.0","id":1,"method":"minerva_getAccountControl","params":["0xYourAccount"]}
```

## Key rotation

`rotatePQKey(newPublicKey, nonce, signature)` is authorised by the **current** key. It stores the new commitment, increments `policyVersion`, and leaves the address unchanged. From the next block, a transaction signed by the old key is rejected by every node with `ErrMinervaStaleControlKey`, at pool admission and in block validation.

Rotation requires a deployed account. Minerva Wallet deploys a counterfactual account automatically before the first rotation.

## Device keys

An account can enrol additional ML-DSA-65 keys with a scope, so that a second device can spend within limits without holding the control key.

* **Registry.** `deviceKeys[account][commitment]` packed as `algorithm | enrolledVersion | active | exists`, written only by the account.
* **Consensus.** A native transaction signed by a key that is not the control key must be an active device key, carry the account's current `policyVersion`, and be a zero-value call to the account itself. Anything else fails with `ErrMinervaDeviceKeyScope` or `ErrMinervaDeviceKeyRevoked`.
* **Precompile `MINERVA_TX_CONTEXT` (`0x…4D01`).** Returns `abi.encode(account, keyCommitment, algorithm, policyVersion, factorySalt)` of the native transaction being executed, and zeros for any other call. Fixed 100 gas.
* **Account.** `MinervaAccount.executeNative` reads the signer from the precompile. The control key is unrestricted. A device key is bound to allowed targets (or any), a value limit per window or lifetime, an expiry, and a set of protected targets (the account itself and the registries) that no scope can include. A device key therefore cannot rotate, enrol, revoke or rewrite the registry.
* **RPC.** `minerva_getDeviceKey(account, commitment[, block])` returns the record plus the account's current policy version.

## Reading an account's state

| Method                                            | Returns                               |
| ------------------------------------------------- | ------------------------------------- |
| `minerva_getSmartAccountDeploymentState(address)` | counterfactual or deployed            |
| `minerva_getAccountSecurityMode(address)`         | the security mode label               |
| `minerva_getAccountReadiness(address)`            | readiness as recorded by the account  |
| `minerva_getAccountControl(address)`              | commitment, algorithm, policy version |
| `minerva_getDeviceKey(address, commitment)`       | device key record                     |

Each accepts an optional block tag as the last parameter.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.minervachain.org/protocol/account-control.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
