> ## 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.

# Machine Issuer Flow

> Add a Machine Issuer by creating an ONCHAINID identity, issuing and attaching KYC and role claims, and registering the candidate through a Machine Regulator.

This workflow shows how to **add a new Machine Issuer** so that an address can call `mnft.registerMachine` for a given Machine NFT contract.

## What “adding a Machine Issuer” means

* The **Machine Regulator** (e.g. Framework Owner) approves an EOA as a **Machine Issuer**.
* That EOA must have an ONCHAINID identity with a **KYC claim** (`CT_KYC_APPROVED`, `666`) and a **Machine Issuer role claim** (`CT_MNFT_ISSUER`, `7`), both issued by a trusted Claim Issuer.
* The regulator then registers that EOA in the **PeaqRwaNft** contract via `rwanft.addMachineIssuer`. After that, the address can register machines (mint Machine NFTs) for machine controllers.

## Prerequisites

* **Machine Regulator** signer (e.g. `MACHINE_REGULATOR_PRIVATE_KEY`): calls `addMachineIssuer`. The regulator's identity needs a KYC claim (`CT_KYC_APPROVED`, `666`) and a Machine Regulator role claim (`CT_MNFT_REGULATOR`, `8`), and the PeaqRwaNft owner must register the regulator with `addMachineRegulator` (owner only, not exposed in the SDK; call the contract directly). Otherwise `addMachineIssuer` reverts with `Unauthorized` or `Verification failed`.
* **Claim Issuer** contract address (`CLAIM_ISSUER_CONTRACT_ADDRESS`): the same Claim Issuer used for KYC. Its signer issues role claims. One wallet can act as both regulator and claim issuer.
* **Candidate Machine Issuer**: the EOA you want to turn into a Machine Issuer (e.g. Alice). They must already have an **ONCHAINID identity**. Create one first with [Create Identity](/peaqchain/sdk-reference/rwa/identity/createIdentity) if needed.

## Steps

### 1. Ensure the candidate has an identity

Resolve the candidate’s ONCHAINID identity (create it first if they don’t have one):

* [Get Identity](/peaqchain/sdk-reference/rwa/identity/getIdentity) with `subject: candidateAddress`.
* If `status === 'not_found'`, [Create Identity](/peaqchain/sdk-reference/rwa/identity/createIdentity) for that address (ID Factory admin signs), then call Get Identity again.

### 2. Issue the Machine Issuer role claim

The **Claim Issuer** issues a role claim for the candidate’s identity with topic `CT_MNFT_ISSUER`:

* [Issue Role Claim](/peaqchain/sdk-reference/rwa/identity/issueRoleClaim) with:
  * `claimIssuerSigner`: your Claim Issuer signer.
  * `claimIssuerContract`: `CLAIM_ISSUER_CONTRACT_ADDRESS`.
  * `subjectIdentity`: the candidate’s identity address from step 1.
  * `roleTopic`: `ClaimTopics.CT_MNFT_ISSUER` (`7`).
  * `roleDescription`: e.g. `'Machine Issuer'`.

You get back `{ claim, signature }`.

### 3. Add the claim to the candidate’s identity

The **identity owner** (the candidate) must add the claim to their identity:

* [Add Claim to Identity](/peaqchain/sdk-reference/rwa/identity/addClaimToIdentity) with:
  * `identityController`: candidate’s signer (e.g. Alice’s wallet).
  * `subjectIdentity`: candidate’s identity address.
  * `claim`: the claim from step 2.
  * `claimSignature`: the signature from step 2.

### 4. Add a KYC claim

The candidate needs a KYC claim on their identity as well as the role claim. Issue it with [Issue KYC Claim](/peaqchain/sdk-reference/rwa/identity/issueKycClaim) and attach it with [Add Claim to Identity](/peaqchain/sdk-reference/rwa/identity/addClaimToIdentity). Without it, `addMachineIssuer` reverts with `Verification failed`.

### 5. Register the Machine Issuer in PeaqRwaNft

The **Machine Regulator** adds the candidate’s EOA to the PeaqRwaNft contract:

* [Add Machine Issuer](/peaqchain/sdk-reference/rwa/rwanft/addMachineIssuer) with:
  * `machineRegulatorSigner`: Machine Regulator wallet.
  * `newMachineIssuer`: candidate’s EOA address (e.g. `alice.address`).

Result includes `status: 'added'`, `machineIssuer`, `machineNft` (the contract created for this issuer), and `receipt`.

### 6. (Optional) Verify

* [Get Machine Issuers](/peaqchain/sdk-reference/rwa/rwanft/getMachineIssuers) before and after step 5 to confirm the new address appears in the list.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.