# Commit a difficulty

`POST /mining/commitment` · Lithos client API · Mining · requires the `api_key` header

Source: https://lithosprotocol.org/docs/api/commit-difficulty

Registers this miner with `diff` as its first commitment, or replaces its commitment with `diff`. The response gives the heights the new commitment acts at.

A registration locks 0.001 ERG in this miner's data box and pays a 0.001 ERG network fee. A change pays the network fee.

**Refused with 409 while `state.autoCommit` is on**, since it keeps the commitment at `stratum.diff`.

## Request body

`CommitmentRequest`, application/json.

- `diff` (string, required): A number and one of K, M, G, T or P, as `stratum.diff` is written.

## Responses

### 200: The transaction was sent. With `outcome` uncertain the node's answer was lost and it may still confirm: read `GET /mining/commitment` before sending again.

`CommitmentResult`

- `txId` (string, required)
- `kind` (string, required, one of registration, change)
- `outcome` (string, required, one of accepted, uncertain): The node's answer. `uncertain` means it was lost and the transaction may still confirm.
- `score` (string, required)
- `diff` (string, required)
- `sentAtHeight` (integer, required): The tip the transaction was built at.
- `declaredHeight` (integer, required)
- `servedFromHeight` (integer, required): The first block the stratum mines at this score.
- `inForceFromHeight` (integer, required): The first height whose rollups judge NISPs against this commitment.
- `replaceableFromHeight` (integer, required): The first tip the next change can be sent from.

### 400: Malformed body, a `diff` that does not parse, or a `diff` that is already the newest commitment.

`ApiError`

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

### 403: The api_key header is missing or wrong.

`ApiError`

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

### 409: `state.autoCommit` is on, an earlier registration or change has not settled, another request is being sent, or the chain moved between the read and the send. Read `GET /mining/commitment` and retry.

`ApiError`

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

### 422: The newest commitment cannot be replaced yet, `state.disableTransforms` is on, the wallet cannot pay, or the node refused the transaction.

`ApiError`

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

### 503: The commitment or the Miner Dictionary could not be read, or the transaction engine did not answer.

`ApiError`

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

### 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 POST "http://localhost:9000/mining/commitment" \
  -H "api_key: $LITHOS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "diff": "1.5M" }'
```

## Example response

```json
{
  "txId": "string",
  "kind": "registration",
  "outcome": "accepted",
  "score": "0",
  "diff": "1.50M",
  "sentAtHeight": 0,
  "declaredHeight": 0,
  "servedFromHeight": 0,
  "inForceFromHeight": 0,
  "replaceableFromHeight": 0
}
```
