# Get difficulty commitment

`GET /mining/commitment` · Lithos client API · Mining

Source: https://lithosprotocol.org/docs/api/get-commitment

This miner's difficulty commitment, read from the chain. Calls within three seconds of each other share one read, and a `POST /mining/commitment` clears it. NISPs are judged against `inForce`; with none in force this miner cannot submit NISPs and is not paid from rollups.

A commitment sent at tip `h` is served by the stratum from `h + timing.servedAfterBlocks` when it is a first commitment or a raise, and from `h + timing.inForceAfterBlocks` when it is a cut. It is in force from `h + timing.inForceAfterBlocks`, and the next change can be sent from `h + timing.replaceableAfterBlocks`. Each rollup pays `timing.rollupLifetimeBlocks` after it opens.

Check `canCommit` and `blockedReason` before offering a change.

## Responses

### 200: The commitment as read now

`DifficultyCommitment`

- `state` (string, required, one of unregistered, registering, waiting, active, unknown): - `unregistered`: no Miner Dictionary entry; send a commitment to register. - `registering`: a registration was sent and is not yet confirmed and synced. - `waiting`: registered, and the first commitment is not in force yet. - `active`: a commitment is in force. - `unknown`: the commitment could not be read; see `reason`.
- `reason` (string): Why `state` is `unknown` or `registering`.
- `height` (integer): The chain tip the commitment was read at. Absent when it could not be read.
- `inForce` (CommitmentEntry): One commitment. Absent when there is none in that slot.
  - `score` (string, required): The committed score, as an exact decimal string. Payouts are proportional to it.
  - `diff` (string, required): `score` written the way `stratum.diff` is.
  - `declaredHeight` (integer, required): The height the commitment declares. Super shares count toward it from here.
  - `inForceFromHeight` (integer, required): The first height whose rollups judge NISPs against this commitment.
  - `servedFromHeight` (integer): The first block the stratum mines at this score. Present only on a commitment not yet in force.
- `pending` (CommitmentEntry): One commitment. Absent when there is none in that slot.
- `inFlight` (CommitmentInFlight): A registration or change that is sent but not yet part of `inForce` or `pending`.
  - `txId` (string, required)
  - `kind` (string, required, one of registration, change)
  - `confirmedHeight` (integer): Present once the transaction confirmed, while this client has not yet synced to this height.
  - `commitment` (CommitmentEntry, required): One commitment. Absent when there is none in that slot.
- `replaceableFromHeight` (integer): The first tip a change to the newest commitment can be sent from. Absent while unregistered.
- `canCommit` (boolean, required): Whether `POST /mining/commitment` would send now.
- `blockedReason` (string, one of TRANSFORMS_DISABLED, AUTO_COMMIT, UNAVAILABLE, IN_FLIGHT, SYNCING, LOCKED): Why `canCommit` is false. - `TRANSFORMS_DISABLED`: `state.disableTransforms` is on. - `AUTO_COMMIT`: `state.autoCommit` keeps the commitment at `configDiff`. - `UNAVAILABLE`: the commitment could not be read. - `IN_FLIGHT`: an earlier registration or change has not settled; see `inFlight`. - `SYNCING`: the Miner Dictionary is not synced, or the registration is not recorded yet. - `LOCKED`: the newest commitment cannot be replaced before `replaceableFromHeight`.
- `autoCommit` (boolean, required): Whether `state.autoCommit` is running and keeps the commitment at `configDiff`.
- `configDiff` (string, required): The `stratum.diff` setting. The stratum serves it until a commitment takes effect, and auto-commit commits it.
- `timing` (CommitmentTiming, required): Blocks from the tip a commitment is sent at.
  - `servedAfterBlocks` (integer, required): Until the stratum mines at a first commitment or a raise. A cut is served once it is in force.
  - `inForceAfterBlocks` (integer, required): Until rollups judge NISPs against it, and this miner can be paid at it.
  - `replaceableAfterBlocks` (integer, required): Until the next change can be sent.
  - `windowBlocks` (integer, required): The blocks a NISP's super shares are drawn from.
  - `rollupLifetimeBlocks` (integer, required): From a rollup opening to its payout.

### default: Error

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

## Example request

```bash
curl -X GET "http://localhost:9000/mining/commitment"
```

## Example response

```json
{
  "state": "unregistered",
  "reason": "string",
  "height": 0,
  "inForce": {
    "score": "0",
    "diff": "1.50M",
    "declaredHeight": 0,
    "inForceFromHeight": 0,
    "servedFromHeight": 0
  },
  "pending": {
    "score": "0",
    "diff": "1.50M",
    "declaredHeight": 0,
    "inForceFromHeight": 0,
    "servedFromHeight": 0
  },
  "inFlight": {
    "txId": "string",
    "kind": "registration",
    "confirmedHeight": 0,
    "commitment": {
      "score": "0",
      "diff": "1.50M",
      "declaredHeight": 0,
      "inForceFromHeight": 0,
      "servedFromHeight": 0
    }
  },
  "replaceableFromHeight": 0,
  "canCommit": true,
  "blockedReason": "TRANSFORMS_DISABLED",
  "autoCommit": true,
  "configDiff": "4.0G",
  "timing": {
    "servedAfterBlocks": 63,
    "inForceAfterBlocks": 125,
    "replaceableAfterBlocks": 845,
    "windowBlocks": 60,
    "rollupLifetimeBlocks": 720
  }
}
```
