> ## Documentation Index
> Fetch the complete documentation index at: https://docs.peaq.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Qualify

> Credit rate your machine from its revenue and activity history.

Qualify turns a machine's on-chain history into a [Machine Credit Rating (MCR)](/peaqos/concepts/machine-credit-rating): a Moody's-style letter rating that any protocol, agent, or frontend can query from any chain.

## What ships

| Component            | Description                                                                                           |
| :------------------- | :---------------------------------------------------------------------------------------------------- |
| EventRegistry        | On-chain store for revenue (type `0`) and activity (type `1`) events, with a cross-chain audit trail. |
| MCR scoring pipeline | Computes AAA-to-NR ratings from a bonded machine's event history.                                     |
| MCR API              | Public read API. Any chain, any caller, no auth.                                                      |
| SDK helpers          | `submitEvent`, `validateSubmitEventParams`, `computeDataHash`, `queryMcr` on both JS and Python.      |

## How it works

<Steps>
  <Step title="Submit events">
    Each time a machine earns revenue or performs a trackable activity, the operator submits an event to the EventRegistry. The SDK validates the payload, computes a `keccak256` data hash, and writes the minimal on-chain record.

    ```typescript theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
    import "dotenv/config";
    import { 
      PeaqosClient, 
      EVENT_TYPE_REVENUE, 
      TRUST_SELF_REPORTED, 
      SUPPORTED_CHAIN_IDS 
    } from "@peaqos/peaq-os-sdk";

    const client = PeaqosClient.fromEnv();
    const { txHash, dataHash } = await client.submitEvent({
      machineId,
      eventType: EVENT_TYPE_REVENUE,
      value: 500,                       // $5.00 in cents
      currency: "USD",
      timestamp: Math.floor(Date.now() / 1000) - 10, // Must be after block time
      rawData: new TextEncoder().encode(JSON.stringify({ session: "abc" })),
      trustLevel: TRUST_SELF_REPORTED,
      sourceChainId: SUPPORTED_CHAIN_IDS.peaq,
      sourceTxHash: null,
      metadata: new Uint8Array([]),
    });
    ```

    Full walkthrough: [Submit events](/peaqos/guides/submit-events).
  </Step>

  <Step title="Events accumulate">
    A freshly registered machine is **Provisioned** until it has enough history to score. Events feed the scoring pipeline, which blends revenue trend, activity cadence, bond status, and trust level.
  </Step>

  <Step title="Query the MCR">
    Any consumer (an agent, protocol, frontend, or another chain) can fetch the current rating from the public API.

    ```bash theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
    curl ${PEAQOS_MCR_API_URL}/mcr/did:peaq:0xabc...
    ```

    Response includes the rating (AAA / AA / A / BBB / BB / B / NR / Provisioned), score, event counts, revenue trend, and bond status. Full walkthrough: [Query MCR](/peaqos/guides/query-mcr).
  </Step>
</Steps>

## Cross-chain revenue

Revenue earned on another chain (e.g., Base) is recorded on peaq with `sourceChainId` and `sourceTxHash` pointing to the origin transaction. Consumers can verify each event against its source chain.

See [Events](/peaqos/concepts/events#cross-chain-revenue-accounting) and [Trust levels](/peaqos/concepts/trust-levels).

## Concepts

<CardGroup cols={3}>
  <Card title="Machine Credit Rating" icon="chart-line" href="/peaqos/concepts/machine-credit-rating">
    AAA-to-NR scale, lifecycle from Provisioned to rated.
  </Card>

  <Card title="Events" icon="clock" href="/peaqos/concepts/events">
    Revenue and activity records that feed MCR.
  </Card>

  <Card title="Trust levels" icon="shield-check" href="/peaqos/concepts/trust-levels">
    Self-reported, on-chain verifiable, hardware-signed.
  </Card>
</CardGroup>

## SDK reference

* [`submitEvent`](/peaqos/sdk-reference/sdk-js#submitevent): Write a single event to EventRegistry.
* [`validateSubmitEventParams`](/peaqos/sdk-reference/sdk-js#validatesubmiteventparams): Validate event params client-side.
* [`computeDataHash`](/peaqos/sdk-reference/sdk-js#computedatahash): keccak256 of raw event data.
* [`queryMcr`](/peaqos/sdk-reference/sdk-js#querymcr): Fetch a machine's rating from the MCR API.

## API reference

<CardGroup cols={2}>
  <Card title="GET /mcr/{did}" icon="gauge" href="/peaqos/api-reference/get-mcr">
    Rating, score, trend, bond status for a single machine.
  </Card>

  <Card title="GET /operator/{did}/machines" icon="users" href="/peaqos/api-reference/get-operator-machines">
    Paginated operator fleet with per-machine MCR.
  </Card>
</CardGroup>

## Guides

<CardGroup cols={2}>
  <Card title="Submit events" icon="arrow-up-from-bracket" href="/peaqos/guides/submit-events">
    Event types, validation, data hashing, cross-chain pattern.
  </Card>

  <Card title="Query MCR" icon="magnifying-glass" href="/peaqos/guides/query-mcr">
    Fetch ratings from curl, JS, or Python.
  </Card>
</CardGroup>
