Skip to content

Identity module RPC API

Paul edited this page Jun 20, 2025 · 2 revisions

Identity Module API Usage

This document describes all the RPC API methods to interact with the identity module. It covers both storage queries and extrinsics (transactions), including their interfaces and example responses.

Polkadot.js api is used for the Ledger of Things Node interaction.


Queries (Storage)

1. api.query.identity.identityOf(address)

  • Description: Fetches the identity information for a given account address.
  • Arguments:
    • address (string): The SS58-encoded account address.
  • Interface:
    Option<IdentityInfo>
    // IdentityInfo example structure:
    {
      info: {
        display: { Raw: string },
        legal: { Raw: string },
        email: { Raw: string },
        web: { Raw: string },
        twitter: { Raw: string },
        riot: { Raw: string },
        additional: [[{ Raw: string }, { Raw: string }]]
      },
      judgements: [[number, { FeePaid?: string } | { KnownGood?: null } | ...]]
    }
  • Example Response:
    {
      "info": {
        "display": { "Raw": "Alice" },
        "legal": { "Raw": "Alice Liddell" },
        "email": { "Raw": "alice@example.com" },
        "web": { "Raw": "https://alice.me" },
        "twitter": { "Raw": "@alice" },
        "riot": { "Raw": "@alice:matrix.org" },
        "additional": [[{ "Raw": "Discord" }, { "Raw": "alice#1234" }]]
      },
      "judgements": [[0, { "FeePaid": "1000000000000" }]]
    }

2. api.query.identity.identityOf.entries()

  • Description: Fetches all entries in the identityOf storage map (all identities on chain).
  • Arguments:
    • None
  • Interface:
    Array<[StorageKey, Option<IdentityInfo>]> // StorageKey contains address
  • Example Response:
    [
      ["5F3sa2TJ...", { "info": { "display": { "Raw": "Alice" } }, "judgements": [] }],
      ["5DAAnrj7...", { "info": { "display": { "Raw": "Bob" } }, "judgements": [] }]
    ]

3. api.query.identity.registrars()

  • Description: Fetches the list of all registrars.
  • Arguments:
    • None
  • Interface:
    Vec<RegistrarInfo>
    // RegistrarInfo example structure:
    {
      account: string,
      fee: string,
      fields: number[],
      info: {
        display: { Raw: string },
        email: { Raw: string },
        web: { Raw: string },
        twitter: { Raw: string },
        image: { Raw: string },
        additional: [[{ Raw: string }, { Raw: string }]]
      },
      judgements: object[][],
      regIndex: number
    }
  • Example Response:
    [
      {
        "account": "5F3sa2TJ...",
        "fee": "1000000000000",
        "fields": [0, 1],
        "info": { "display": { "Raw": "Registrar 1" } },
        "judgements": [],
        "regIndex": 0
      },
      {
        "account": "5DAAnrj7...",
        "fee": "2000000000000",
        "fields": [0],
        "info": { "display": { "Raw": "Registrar 2" } },
        "judgements": [],
        "regIndex": 1
      }
    ]

4. api.query.identity.suspendedRegistrars()

  • Description: Fetches the indices of suspended registrars.
  • Arguments:
    • None
  • Interface:
    Vec<u32>
  • Example Response:
    [1, 3]

Extrinsics (Transactions)

1. api.tx.identity.setIdentity(identityInfo)

  • Description: Sets or updates the identity information for the sender's account.
  • Arguments:
    • identityInfo (object): The identity fields to set (display, legal, email, web, etc.).
  • Interface:
    setIdentity(identityInfo: IdentityInfo): SubmittableExtrinsic
  • Example:
    api.tx.identity.setIdentity({
      display: { Raw: "Alice" },
      email: { Raw: "alice@example.com" }
    })

2. api.tx.identity.requestJudgement(registrarIndex, fee)

  • Description: Requests a judgement from a registrar for the sender's identity.
  • Arguments:
    • registrarIndex (number): The index of the registrar.
    • fee (string or number): The fee to pay (in plancks, smallest unit).
  • Interface:
    requestJudgement(registrarIndex: number, fee: string | number): SubmittableExtrinsic
  • Example:
    api.tx.identity.requestJudgement(0, "1000000000000")

3. api.tx.identity.provideJudgement(registrarIndex, address, judgement)

  • Description: Registrar provides a judgement for a given address.
  • Arguments:
    • registrarIndex (number): The index of the registrar.
    • address (string): The address to judge.
    • judgement (string): The judgement level (e.g., "Reasonable", "KnownGood").
  • Interface:
    provideJudgement(registrarIndex: number, address: string, judgement: string): SubmittableExtrinsic
  • Example:
    api.tx.identity.provideJudgement(0, "5F3sa2TJ...", "Reasonable")

4. api.tx.identity.cancelRequest(registrarIndex)

  • Description: Cancels a pending judgement request for the sender's identity with the given registrar.
  • Arguments:
    • registrarIndex (number): The index of the registrar.
  • Interface:
    cancelRequest(registrarIndex: number): SubmittableExtrinsic
  • Example:
    api.tx.identity.cancelRequest(0)

5. api.tx.identity.clearIdentity()

  • Description: Clears the sender's identity information from the chain.
  • Arguments:
    • None
  • Interface:
    clearIdentity(): SubmittableExtrinsic
  • Example:
    api.tx.identity.clearIdentity()

6. api.tx.identity.setFee(registrarIndex, fee)

  • Description: Registrar sets their fee for providing judgements.
  • Arguments:
    • registrarIndex (number): The index of the registrar.
    • fee (string or number): The new fee (in plancks, smallest unit).
  • Interface:
    setFee(registrarIndex: number, fee: string | number): SubmittableExtrinsic
  • Example:
    api.tx.identity.setFee(0, "1000000000000")

Notes

  • All extrinsics must be signed by the sender's account.
  • Fees are denominated in the smallest unit (Crumbs), so conversion may be necessary (e.g., fee * 10 ** decimals).
  • The actual types and available fields may depend on the chain's runtime configuration.
Clone this wiki locally