# This client's payouts and claims

`GET /stats/mining/payments` · Lithos client API · Statistics

Source: https://lithosprotocol.org/docs/api/get-mining-payments

Every payout to this client's primary mining address in retained history, newest first, each
with what it was made of and the rollup it came from. Alongside them, the rollups this client
has a claim in that have not paid yet, and the fraud proofs it was paid for.

**Payouts** break the output into reward, refunded bond and surplus. Only reward and surplus
are earnings — the bond is this client's own deposit coming back. `score / rollupScore` is the
share of the block this client earned, out of `rollupMiners` miners.

**Claims** follow each unpaid rollup through `holding`, `evaluation` and `payout`. The expected
reward is exact once the payout is ready and projected during evaluation, where a fraud proof
against another miner can still raise it. Holding has no projection. A `slashed` claim lost its
bond to a fraud proof and will never pay.

**Bounties** are fraud proofs this client submitted. Each pays the slashed miner's bond.

Payouts are paged by `offset` and `limit` in the order `sort` and `order` choose, and `total`
counts every retained payout. A payout confirmed between two requests shifts later pages by
one. Claims and bounties always come in full.

## Parameters

| Name | In | Type | Required | Description |

|---|---|---|---|---|

| `offset` | query | integer · int32 | no | Payouts to skip, counting from the newest. |

| `limit` | query | integer · int32 | no | Payouts per page. |

| `sort` | query | string | no | `paid` orders by the block that paid each payout, `mined` by the block its rollup was mined in. Paid time needs no option of its own: block timestamps rise with height, so it always agrees with `paid`.  |

| `order` | query | string | no | `desc` puts the highest first. |

## Responses

### 200: One page of payouts, with every open claim and bounty.

`PaymentLedgerPage`

- `holdingBlocks` (integer, required): Blocks a rollup takes submissions for, counted from the block that mined it.
- `evaluationBlocks` (integer, required): Blocks a rollup stays open to fraud proofs, counted from the block evaluation started in.
- `status` (string, required, one of disabled, loading, ready, stale, unavailable, catching-up, recovering): How far collection has got. `ready` means it reached the last checked chain tip. `catching-up` and `recovering` mean replay or reorg work is still running, `stale` means the last successful check is too old, and `unavailable` means collection failed. On `disabled` or `loading` the numbers are not evidence that the period was quiet.
- `source` (MiningCursor, required): The processed chain point a statistics result was read from.
  - `height` (integer, required)
  - `blockId` (string, required)
  - `parentId` (string, required)
  - `timestamp` (integer · int64, required): The block's own timestamp in Unix milliseconds, not the time the client read it.
- `retainedFromHeight` (integer, required): First retained height. Nothing older is listed.
- `payments` (LocalPayment[], required): In the order `sort` and `order` give.
  - `transactionId` (string, required)
  - `outputId` (string, required)
  - `payoutBoxId` (string, required)
  - `rollupNft` (string, required): NFT minted from the original collateral box id.
  - `minedBlockId` (string, required): The block holding the rollup genesis, even when that block is older than retained history.
  - `minedHeight` (integer, required)
  - `minedTimestamp` (integer · int64, required): Timestamp of `minedBlockId`, in Unix milliseconds. With `timestamp`, how long the payout took.
  - `blockId` (string, required): The block holding this payout transaction.
  - `height` (integer, required)
  - `timestamp` (integer · int64, required)
  - `grossNanoErg` (string, required): Exact output value, including the refunded bond and any surplus.
  - `score` (string, required): An exact nonnegative integer as a decimal string. Parse it without going through a float.
  - `rewardNanoErg` (string, required): This client's share of the rollup's ERG reward. Earnings.
  - `bondNanoErg` (string, required): The submission bond coming back. Not earnings.
  - `surplusNanoErg` (string, required): Anything the output carried beyond reward and bond. Earnings; usually zero.
  - `litTokenId` (string)
  - `rewardLit` (string, required): LIT the protocol owed this share.
  - `receivedLit` (string, required): LIT the output actually carried. Never less than `rewardLit`.
  - `rollupScore` (string, required): The whole rollup's score. `score / rollupScore` is this client's share.
  - `rollupMiners` (integer, required): Miners the rollup paid.
  - `rollupRewardNanoErg` (string, required): The ERG reward the whole rollup distributed, bonds excluded.
  - `rollupRewardLit` (string, required): The LIT the whole rollup distributed.
- `offset` (integer, required): The offset this page starts at.
- `total` (integer, required): Every payout in retained history. Pages end at `offset + limit >= total`.
- `sort` (string, required, one of paid, mined): The ordering this page is in.
- `order` (string, required, one of desc, asc)
- `claims` (PaymentClaim[], required): Unpaid claims, newest submission first.
  - `rollupNft` (string, required)
  - `minedBlockId` (string, required)
  - `minedHeight` (integer, required)
  - `phase` (string, required, one of holding, evaluation, payout, slashed): The furthest transition seen. `holding` still takes submissions, `evaluation` is open to fraud proofs, `payout` has a fixed reward waiting to be sent. `slashed` will never pay. 
  - `submittedHeight` (integer, required)
  - `submittedTimestamp` (integer · int64, required)
  - `submissionTransactionId` (string, required)
  - `score` (string, required): An exact nonnegative integer as a decimal string. Parse it without going through a float.
  - `bondNanoErg` (string, required): The bond this client posted. Comes back with the payout, or is lost if slashed.
  - `phaseHeight` (integer, required): Height of the transition that set `phase`.
  - `phaseTimestamp` (integer · int64, required)
  - `rollupMiners` (integer): Miners still in the rollup. Absent while holding.
  - `rollupScore` (string): The rollup's total score. Absent while holding.
  - `rewardNanoErg` (string): Expected ERG reward, bond excluded. Absent while holding or slashed.
  - `rewardLit` (string): Expected LIT. Only known once the payout is ready.
  - `rewardBasis` (string, one of exact, projected): `exact` once the payout is ready; `projected` during evaluation.
  - `slashedTransactionId` (string): The fraud proof that removed this client's entry.
  - `payoutReadyFrom` (integer): First height the payout can become ready. Exact during evaluation; during holding it assumes evaluation starts the moment holding ends, so it is the earliest possible. Absent once the payout is ready, and when slashed. 
- `bounties` (FraudBounty[], required): Newest first.
  - `transactionId` (string, required)
  - `rollupNft` (string, required)
  - `minedHeight` (integer, required)
  - `height` (integer, required)
  - `timestamp` (integer · int64, required)
  - `bondNanoErg` (string, required): The slashed bond, paid to this client.
  - `claimedScore` (string, required): The score the slashed miner had claimed.
  - `minerHash` (string): Hash identifying the slashed entry. Not a miner address.

### 400: `limit` is outside 1–500, `offset` is negative, or `sort` or `order` is not one of its values.

`ApiError`

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

### 503: History is loading, disabled, busy, or unreadable. Check `mining.status` in /stats before retrying.

`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/stats/mining/payments"
```

## Example response

```json
{
  "holdingBlocks": 0,
  "evaluationBlocks": 0,
  "status": "disabled",
  "source": {
    "height": 0,
    "blockId": "string",
    "parentId": "string",
    "timestamp": 0
  },
  "retainedFromHeight": 0,
  "payments": [
    {
      "transactionId": "string",
      "outputId": "string",
      "payoutBoxId": "string",
      "rollupNft": "string",
      "minedBlockId": "string",
      "minedHeight": 0,
      "minedTimestamp": 0,
      "blockId": "string",
      "height": 0,
      "timestamp": 0,
      "grossNanoErg": "string",
      "score": "1000000000",
      "rewardNanoErg": "string",
      "bondNanoErg": "string",
      "surplusNanoErg": "string",
      "litTokenId": "string",
      "rewardLit": "string",
      "receivedLit": "string",
      "rollupScore": "string",
      "rollupMiners": 0,
      "rollupRewardNanoErg": "string",
      "rollupRewardLit": "string"
    }
  ],
  "offset": 0,
  "total": 0,
  "sort": "paid",
  "order": "desc",
  "claims": [
    {
      "rollupNft": "string",
      "minedBlockId": "string",
      "minedHeight": 0,
      "phase": "holding",
      "submittedHeight": 0,
      "submittedTimestamp": 0,
      "submissionTransactionId": "string",
      "score": "1000000000",
      "bondNanoErg": "string",
      "phaseHeight": 0,
      "phaseTimestamp": 0,
      "rollupMiners": 0,
      "rollupScore": "string",
      "rewardNanoErg": "string",
      "rewardLit": "string",
      "rewardBasis": "exact",
      "slashedTransactionId": "string",
      "payoutReadyFrom": 0
    }
  ],
  "bounties": [
    {
      "transactionId": "string",
      "rollupNft": "string",
      "minedHeight": 0,
      "height": 0,
      "timestamp": 0,
      "bondNanoErg": "string",
      "claimedScore": "string",
      "minerHash": "string"
    }
  ]
}
```
