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

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 **Machine Issuer role claim** (`CT_MNFT_ISSUER`) 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`) — will issue the role claim and call `addMachineIssuer`.
* **Claim Issuer** contract address (`CLAIM_ISSUER_CONTRACT_ADDRESS`) — the same Claim Issuer used for KYC; its signer can issue role claims (in the test the admin is 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** (or the same signer acting as 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`: Machine Regulator (or your Claim Issuer signer).
  * `claimIssuerContract`: `CLAIM_ISSUER_CONTRACT_ADDRESS`.
  * `subjectIdentity`: the candidate’s identity address from step 1.
  * `roleTopic`: `ClaimTopics.CT_MNFT_ISSUER` (e.g. `7` — use the value from your SDK’s `ClaimTopics` enum).
  * `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. 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`.

### 5. (Optional) Verify

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