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

# Group

## createGroup(groupName, groupId, seed)

Used to create a new group within the RBAC (Role-Based Access Control) system.

| Parameter     | Type     | EVM      | Substrate | Description                                                                                  |
| ------------- | -------- | -------- | --------- | -------------------------------------------------------------------------------------------- |
| **groupName** | `string` | Required | Required  | Name of the group to be created.                                                             |
| **groupId**   | `string` | Optional | Optional  | ID of the group. If not provided, a new ID will be generated.                                |
| **seed**      | `string` | N/A      | Optional  | If not set at instance creation, allows user to define who sends the Substrate Transactions. |

### Create Group Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const EVM_PRIVATE = process.env["EVM_PRIVATE"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  const groupName = "peaq-group-1";
  const group = await sdk.rbac.createGroup({
      groupName: groupName
  });

  // Send using Sdk function
  const receipt = await Sdk.sendEvmTx({
    tx: group.tx,
    baseUrl: HTTPS_BASE_URL,
    seed: EVM_PRIVATE
  });

  // Log to see what the auto generated groupId is
  console.log(group.groupId);
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.createGroup({}) return object
  {
    tx: {
      to: '0x0000000000000000000000000000000000000802',
      data: '0x65c1e09c35386135323638342d336163652d346537322d613032352d38353038356231640000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000c706561712d67726f75702d310000000000000000000000000000000000000000'
    },
    groupId: '58a52684-3ace-4e72-a025-85085b1d'
  }

  // sendEvmTx({}) return object
  TransactionReceipt {
    provider: JsonRpcProvider {},
    to: '0x0000000000000000000000000000000000000802',
    from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
    contractAddress: null,
    hash: '0x07eb9b0e02ad279b04c4bea1affcc23ba1f5fc2e97f946a05e3db6cb36f32338',
    index: 0,
    blockHash: '0x686188b5eefb03c7ea40621a0e7d72459f1fa8387c7eb2e0cbab92c6eaeff04f',
    blockNumber: 4490069,
    logsBloom: '0x00000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002020000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    gasUsed: 34430n,
    blobGasUsed: null,
    cumulativeGasUsed: 34430n,
    gasPrice: 100000000000n,
    blobGasPrice: null,
    type: 2,
    status: 1,
    root: undefined
  }
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE,
      seed: SUBSTRATE_SEED
  });

  const groupName = "peaq-group-1";
  const response = await sdk.rbac.createGroup({
      groupName: groupName
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.createGroup({}) return object
  { groupId: '63d6417e-1a03-4fd8-9439-295ce979' }
  ```
</CodeGroup>

<Note>For the EVM tx it returns in a different form than what was used throughout the sdk. The purpose of this is to show the group-id that was autogenerated if it was not manually set.
That way you are able to take note of the group-id for that group-name set.</Note>

## fetchGroup(owner, groupId, wssBaseUrl)

Fetches group information from the RBAC system based on the provided group ID and owner's address.

| Parameter      | Type     | EVM      | Substrate | Description                                  |
| -------------- | -------- | -------- | --------- | -------------------------------------------- |
| **owner**      | `string` | Required | Required  | Address representing the owner of the group. |
| **groupId**    | `string` | Required | Required  | ID of the group to be fetched.               |
| **wssBaseUrl** | `string` | Required | N/A       | WSS URL used to query RBAC storage.          |

### Fetch Group Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const EVM_ADDRESS = process.env["EVM_ADDRESS"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  // example of a previously created group id
  const groupId = "58a52684-3ace-4e72-a025-85085b1d";

  const response = await sdk.rbac.fetchGroup({
      owner: EVM_ADDRESS,
      groupId: groupId,
      wssBaseUrl: WSS_BASE_URL
  });
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.fetchGroup({}) response object
  {
    id: '58a52684-3ace-4e72-a025-85085b1d',
    name: 'peaq-group-1',
    enabled: true
  }
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE
  });

  // example of a previously created group id
  const groupId = "63d6417e-1a03-4fd8-9439-295ce979";

  const response = await sdk.rbac.fetchGroup({
      owner: SUBSTRATE_ADDRESS,
      groupId: groupId
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.fetchGroup({}) response object
  {
    id: '63d6417e-1a03-4fd8-9439-295ce979',
    name: 'peaq-group-1',
    enabled: true
  }
  ```
</CodeGroup>

## fetchGroups(owner, wssBaseUrl)

Used to fetch all the groups associated with the passed owner address.

| Parameter      | Type     | EVM      | Substrate | Description                                               |
| -------------- | -------- | -------- | --------- | --------------------------------------------------------- |
| **owner**      | `string` | Required | Required  | Address representing the owner of all the fetched groups. |
| **wssBaseUrl** | `string` | Required | N/A       | WSS URL used to query RBAC storage.                       |

### Fetch Groups Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const EVM_ADDRESS = process.env["EVM_ADDRESS"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  const response = await sdk.rbac.fetchGroups({
      owner: EVM_ADDRESS,
      wssBaseUrl: WSS_BASE_URL
  });
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.fetchGroups({}) response object
  [
    {
      id: 'eda650fa-ec62-4d09-849b-b66c7771',
      name: 'group-name-123',
      enabled: true
    },
      ...
    {
      id: '58a52684-3ace-4e72-a025-85085b1d',
      name: 'peaq-group-1',
      enabled: true
    }
  ]
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE
  });

  const response = await sdk.rbac.fetchGroups({
      owner: SUBSTRATE_ADDRESS
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.fetchGroups({}) response object
  [
    {
      id: '9763c33e-2b1b-4834-a908-03f2a9e0',
      name: 'group-name-123',
      enabled: true
    },
      ...
    {
      id: '63d6417e-1a03-4fd8-9439-295ce979',
      name: 'peaq-group-1',
      enabled: true
    }
  ]
  ```
</CodeGroup>

## updateGroup(groupName, groupId, seed)

Allows the owner to update the group name.

| Parameter     | Type   | EVM      | Substrate | Description                                                                                  |
| ------------- | ------ | -------- | --------- | -------------------------------------------------------------------------------------------- |
| **groupName** | string | Required | Required  | Updated group name.                                                                          |
| **groupId**   | string | Required | Required  | ID of the group (32 bytes) to be updated.                                                    |
| **seed**      | string | N/A      | Optional  | If not set at instance creation, allows user to define who sends the Substrate Transactions. |

### Update Group Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const EVM_ADDRESS = process.env["EVM_ADDRESS"];
  const EVM_PRIVATE = process.env["EVM_PRIVATE"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  // new group name that will be set
  const groupName = "peaq-group-new";

  // example of a previously created group id
  const groupId = "58a52684-3ace-4e72-a025-85085b1d";

  // build the evm tx
  const tx = await sdk.rbac.updateGroup({
      groupName: groupName,
      groupId: groupId
  });

  // send using Sdk function
  const receipt = await Sdk.sendEvmTx({
    tx: tx,
    baseUrl: HTTPS_BASE_URL,
    seed: EVM_PRIVATE
  });

  // fetch Group to confirm the name change
  const response = await sdk.rbac.fetchGroup({
      owner: EVM_ADDRESS,
      groupId: groupId,
      wssBaseUrl: WSS_BASE_URL
  });
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.updateGroup({}) return object
  {
    to: '0x0000000000000000000000000000000000000802',
    data: '0xadb32ee135386135323638342d336163652d346537322d613032352d38353038356231640000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000e706561712d67726f75702d6e6577000000000000000000000000000000000000'
  }

  // sendEvmTx({}) return object
  TransactionReceipt {
    provider: JsonRpcProvider {},
    to: '0x0000000000000000000000000000000000000802',
    from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
    contractAddress: null,
    hash: '0xf0f8c39077ae3c3d631579d9c71ef1d84729bb63bbc5ec8b75ed175f71034707',
    index: 0,
    blockHash: '0xdfcd14d7be74ef7680791ec7455821ffaa37d642f055d14331be791904535577',
    blockNumber: 4500445,
    logsBloom: '0x00000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000',
    gasUsed: 35283n,
    blobGasUsed: null,
    cumulativeGasUsed: 35283n,
    gasPrice: 100000000000n,
    blobGasPrice: null,
    type: 2,
    status: 1,
    root: undefined
  }
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
  const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE,
      seed: SUBSTRATE_SEED
  });

  // new group name that will be set
  const groupName = "peaq-group-new";

  // example of a previously created group id
  const groupId = "63d6417e-1a03-4fd8-9439-295ce979";

  // build the evm tx
  const response = await sdk.rbac.updateGroup({
      groupName: groupName,
      groupId: groupId
  });

  // fetch Group to confirm the name change
  const fetchedGroup = await sdk.rbac.fetchGroup({
      owner: SUBSTRATE_ADDRESS,
      groupId: groupId
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.updateGroup({}) return object
  {
    message: 'Successfully update group 63d6417e-1a03-4fd8-9439-295ce979 with new name: peaq-group-new'
  }
  ```
</CodeGroup>

## disableGroup(groupId, seed)

Disables a group within a permission management system.

| Parameter   | Type     | EVM      | Substrate | Description                                                                                  |
| ----------- | -------- | -------- | --------- | -------------------------------------------------------------------------------------------- |
| **groupId** | `string` | Required | Required  | The unique identifier (ID) of the group to be disabled.                                      |
| **seed**    | `string` | N/A      | Optional  | If not set at instance creation, allows user to define who sends the Substrate Transactions. |

### Disable Group Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const EVM_ADDRESS = process.env["EVM_ADDRESS"];
  const EVM_PRIVATE = process.env["EVM_PRIVATE"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  // group id to disable
  const groupId = "58a52684-3ace-4e72-a025-85085b1d";

  // build the evm tx
  const tx = await sdk.rbac.disableGroup({
      groupId: groupId
  });

  // send using Sdk function
  const receipt = await Sdk.sendEvmTx({
    tx: tx,
    baseUrl: HTTPS_BASE_URL,
    seed: EVM_PRIVATE
  });

  // fetch group to confirm it has been changed to disabled
  const response = await sdk.rbac.fetchGroup({
      owner: EVM_ADDRESS,
      groupId: groupId,
      wssBaseUrl: WSS_BASE_URL
  });
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.disableGroup({}) return object
  {
    to: '0x0000000000000000000000000000000000000802',
    data: '0x47538f1235386135323638342d336163652d346537322d613032352d3835303835623164'
  }

  // sendEvmTx({}) return object
  TransactionReceipt {
    provider: JsonRpcProvider {},
    to: '0x0000000000000000000000000000000000000802',
    from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
    contractAddress: null,
    hash: '0x4e70353fba441965af6fe54eb05c7968979f643892d7d02955c2cce78940cf7a',
    index: 0,
    blockHash: '0xe850a8b6aacf3ae4e06d127ae81b5420a3f0548ef41585eb1a7737768fa9d1e5',
    blockNumber: 4501188,
    logsBloom: '0x00000000000000000000000000000000000800000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    gasUsed: 34680n,
    blobGasUsed: null,
    cumulativeGasUsed: 34680n,
    gasPrice: 100000000000n,
    blobGasPrice: null,
    type: 2,
    status: 1,
    root: undefined
  }
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
  const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE,
      seed: SUBSTRATE_SEED
  });

  // group id to disable
  const groupId = "63d6417e-1a03-4fd8-9439-295ce979";

  // execute the extrinsic
  const response = await sdk.rbac.disableGroup({
      groupId: groupId
  });

  // fetch group to confirm it has been changed to disabled
  const fetchedGroup = await sdk.rbac.fetchGroup({
      owner: SUBSTRATE_ADDRESS,
      groupId: groupId,
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.disableGroup({}) return object
  {
    message: 'Successfully disable group 63d6417e-1a03-4fd8-9439-295ce979'
  }
  ```
</CodeGroup>

## assignRoleToGroup(groupId, roleId, seed)

This function allows to assign a specific role to a group within a permission management system.

| Parameter   | Type     | EVM      | Substrate | Description                                                                                  |
| ----------- | -------- | -------- | --------- | -------------------------------------------------------------------------------------------- |
| **groupId** | `string` | Required | Required  | The unique identifier of the group to which the role will be assigned.                       |
| **roleId**  | `string` | Required | Required  | ID of the role that will be assigned to the group.                                           |
| **seed**    | `string` | N/A      | Optional  | If not set at instance creation, allows user to define who sends the Substrate Transactions. |

### Assign Role to Group Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const EVM_PRIVATE = process.env["EVM_PRIVATE"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  // group id (generated with createGroup)
  const groupId = "58a52684-3ace-4e72-a025-85085b1d";

  // role id to assign to group
  const roleId = "ada650fa-ec62-4d09-849b-b66c7777";

  // build the evm tx
  const tx = await sdk.rbac.assignRoleToGroup({
      groupId: groupId,
      roleId: roleId
  });

  // send using Sdk function
  const receipt = await Sdk.sendEvmTx({
    tx: tx,
    baseUrl: HTTPS_BASE_URL,
    seed: EVM_PRIVATE
  });
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.assignRoleToGroup({}) return object
  {
    to: '0x0000000000000000000000000000000000000802',
    data: '0x03c4d7fb62363861353538392d313238342d343965392d383237362d303335396134323935386135323638342d336163652d346537322d613032352d3835303835623164'
  }

  // sendEvmTx({}) return object
  TransactionReceipt {
    provider: JsonRpcProvider {},
    to: '0x0000000000000000000000000000000000000802',
    from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
    contractAddress: null,
    hash: '0xf65f894de591b5bbd7c3bb482c95ced55b7989ef07980cf7f469f19944ab02e1',
    index: 0,
    blockHash: '0x12c4ac10e6abed8148a7b6477b3c53cdabfbbfdb5abd42fa0f12aaba87aecf73',
    blockNumber: 4500565,
    logsBloom: '0x00000000000000000000000000000000000000000000080006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    gasUsed: 31322n,
    blobGasUsed: null,
    cumulativeGasUsed: 31322n,
    gasPrice: 100000000000n,
    blobGasPrice: null,
    type: 2,
    status: 1,
    root: undefined
  }
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE,
      seed: SUBSTRATE_SEED
  });

  // group id (generated with createGroup)
  const groupId = "63d6417e-1a03-4fd8-9439-295ce979";

  // role id to assign to group
  const roleId = "bc3f20d5-c519-4048-8db1-4bbf48dc";

  // execute extrinsic
  const response = await sdk.rbac.assignRoleToGroup({
      groupId: groupId,
      roleId: roleId
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.assignRoleToGroup({}) return object
  {
    message: 'Successfully assign role bc3f20d5-c519-4048-8db1-4bbf48dc to group 63d6417e-1a03-4fd8-9439-295ce979'
  }
  ```
</CodeGroup>

## fetchGroupRoles(owner, groupId, wssBaseUrl)

Designed to retrieve roles associated with a specific group from the network's RBAC (Role-Based Access Control) system.

| Parameter      | Type     | EVM      | Substrate | Description                                                                                              |
| -------------- | -------- | -------- | --------- | -------------------------------------------------------------------------------------------------------- |
| **owner**      | `string` | Required | Required  | Address of the owner of the roles. This is typically the account that manages the roles and permissions. |
| **groupId**    | `string` | Required | Required  | Unique identifier of the group for whom roles are to be fetched.                                         |
| **wssBaseUrl** | `string` | Required | N/A       | WSS URL used to query RBAC storage.                                                                      |

### Fetch Group Roles Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const EVM_ADDRESS = process.env["EVM_ADDRESS"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  const groupId = "58a52684-3ace-4e72-a025-85085b1d";

  const response = await sdk.rbac.fetchGroupRoles({
      owner: EVM_ADDRESS,
      groupId: groupId,
      wssBaseUrl: WSS_BASE_URL
  });
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.fetchGroupRoles({}) return object
  [
    {
      role: 'b68a5589-1284-49e9-8276-0359a429',
      group: '58a52684-3ace-4e72-a025-85085b1d'
    }
  ]
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE
  });

  const groupId = "63d6417e-1a03-4fd8-9439-295ce979";

  const response = await sdk.rbac.fetchGroupRoles({
      owner: SUBSTRATE_ADDRESS,
      groupId: groupId
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.fetchGroupRoles({}) return object
  [
    {
      role: 'bc3f20d5-c519-4048-8db1-4bbf48dc',
      group: '63d6417e-1a03-4fd8-9439-295ce979'
    }
  ]
  ```
</CodeGroup>

## unassignRoleToGroup(groupId, roleId, seed)

This function allows to unassign a specific role to a group in a permission management system.

| Parameter   | Type     | EVM      | Substrate | Description                                                                                  |
| ----------- | -------- | -------- | --------- | -------------------------------------------------------------------------------------------- |
| **groupId** | `string` | Required | Required  | ID of the group from which the role should be unassigned.                                    |
| **roleId**  | `string` | Required | Required  | ID of the role that needs to be unassigned.                                                  |
| **seed**    | `string` | N/A      | Optional  | If not set at instance creation, allows user to define who sends the Substrate Transactions. |

### Unassign Role to Group Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const EVM_ADDRESS = process.env["EVM_ADDRESS"];
  const EVM_PRIVATE = process.env["EVM_PRIVATE"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  // previously created groupId
  const groupId = "58a52684-3ace-4e72-a025-85085b1d";

  // role id to unassign to group
  const roleId = "b68a5589-1284-49e9-8276-0359a429";

  // build the evm tx
  const tx = await sdk.rbac.unassignRoleToGroup({
      groupId: groupId,
      roleId: roleId
  });

  // send using Sdk function
  const receipt = await Sdk.sendEvmTx({
    tx: tx,
    baseUrl: HTTPS_BASE_URL,
    seed: EVM_PRIVATE
  });

  // fetch to see it has been unassigned
  const response = await sdk.rbac.fetchGroupRoles({
      owner: EVM_ADDRESS,
      groupId: groupId,
      wssBaseUrl: WSS_BASE_URL
  });
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.unassignRoleToGroup({}) return object
  {
    to: '0x0000000000000000000000000000000000000802',
    data: '0xad58943762363861353538392d313238342d343965392d383237362d303335396134323935386135323638342d336163652d346537322d613032352d3835303835623164'
  }

  // sendEvmTx({}) return object
  TransactionReceipt {
    provider: JsonRpcProvider {},
    to: '0x0000000000000000000000000000000000000802',
    from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
    contractAddress: null,
    hash: '0x2a2134db9dd1e1ff3c70c5e350223c3d776e2e2822c8264bb2879a49b7d542da',
    index: 0,
    blockHash: '0x5e5dad9089357d1095b0b2177a26b13cce1f52f0e808f3f95260f588b4a9fe40',
    blockNumber: 4500781,
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000040000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    gasUsed: 29291n,
    blobGasUsed: null,
    cumulativeGasUsed: 29291n,
    gasPrice: 100000000000n,
    blobGasPrice: null,
    type: 2,
    status: 1,
    root: undefined
  }
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
  const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE,
      seed: SUBSTRATE_SEED
  });

  // previously created groupId
  const groupId = "63d6417e-1a03-4fd8-9439-295ce979";

  // role id to unassign to group
  const roleId = "bc3f20d5-c519-4048-8db1-4bbf48dc";

  // send extrinsic
  const response = await sdk.rbac.unassignRoleToGroup({
      groupId: groupId,
      roleId: roleId
  });

  // fetch to see it has been unassigned (throws an error)
  const fetchedUserGroups = await sdk.rbac.fetchGroupRoles({
      owner: SUBSTRATE_ADDRESS,
      groupId: groupId
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.unassignRoleToGroup({}) return object
  {
    message: 'Successfully unassign role: bc3f20d5-c519-4048-8db1-4bbf48dc from group: 63d6417e-1a03-4fd8-9439-295ce979'
  }
  ```
</CodeGroup>

## assignUserToGroup(userId, groupId, address, seed)

This function allows to assign a user to a group within the RBAC (Role-Based Access Control) system.

| Parameter   | Type     | EVM      | Substrate | Description                                                                                                    |
| ----------- | -------- | -------- | --------- | -------------------------------------------------------------------------------------------------------------- |
| **userId**  | `string` | Required | Required  | The unique identifier of the user to whom the group will be assigned. ID created by user and must be 32 bytes. |
| **groupId** | `string` | Required | Required  | ID of the group that will be assigned to the user.                                                             |
| **seed**    | `string` | N/A      | Optional  | If not set at instance creation, allows user to define who sends the Substrate Transactions.                   |

### Assign User to Group Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const EVM_PRIVATE = process.env["EVM_PRIVATE"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  // user id to assign to group
  const userId = "9e8c7866-8435-4b76-8683-709a03c9";

  // group id (generated with createGroup)
  const groupId = "58a52684-3ace-4e72-a025-85085b1d";

  // build the evm tx
  const tx = await sdk.rbac.assignUserToGroup({
      userId: userId,
      groupId: groupId,
  });

  // send using Sdk function
  const receipt = await Sdk.sendEvmTx({
    tx: tx,
    baseUrl: HTTPS_BASE_URL,
    seed: EVM_PRIVATE
  });
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.assignUserToGroup({}) return object
  {
    to: '0x0000000000000000000000000000000000000802',
    data: '0xa76110c439653863373836362d383433352d346237362d383638332d373039613033633935386135323638342d336163652d346537322d613032352d3835303835623164'
  }

  // sendEvmTx({}) return object
  TransactionReceipt {
    provider: JsonRpcProvider {},
    to: '0x0000000000000000000000000000000000000802',
    from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
    contractAddress: null,
    hash: '0x9e1da68de86d6d1f68e600a6a525d117b4493be046be6fdfeda7a21a26c80cec',
    index: 0,
    blockHash: '0x24bc140d800cfc15d5c8fd45d201a8e4b31dfaa8aa044b1d799cb2a5cb7dc8d1',
    blockNumber: 4500957,
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000001',
    gasUsed: 30248n,
    blobGasUsed: null,
    cumulativeGasUsed: 30248n,
    gasPrice: 100000000000n,
    blobGasPrice: null,
    type: 2,
    status: 1,
    root: undefined
  }
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE,
      seed: SUBSTRATE_SEED
  });

  // user id to assign to group
  const userId = "9e8c7866-8435-4b76-8683-709a03c9";

  // group id (generated with createGroup)
  const groupId = "63d6417e-1a03-4fd8-9439-295ce979";

  // send the extrinsic
  const response = await sdk.rbac.assignUserToGroup({
      userId: userId,
      groupId: groupId,
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.assignUserToGroup({}) return object
  {
    message: 'Successfully assign user 9e8c7866-8435-4b76-8683-709a03c9 to group 63d6417e-1a03-4fd8-9439-295ce979'
  }
  ```
</CodeGroup>

## fetchUserGroups(owner, userId, wssBaseUrl)

Designed to retrieve groups associated with a specific user from the network's RBAC (Role-Based Access Control) system.

| Parameter      | Type     | EVM      | Substrate | Description                                                                                              |
| -------------- | -------- | -------- | --------- | -------------------------------------------------------------------------------------------------------- |
| **owner**      | `string` | Required | Required  | Address of the owner of the roles. This is typically the account that manages the roles and permissions. |
| **userId**     | `string` | Required | Required  | Unique identifier of the user for whom groups are to be fetched.                                         |
| **wssBaseUrl** | `string` | Required | N/A       | WSS URL used to query RBAC storage.                                                                      |

### Fetch User Groups Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const EVM_ADDRESS = process.env["EVM_ADDRESS"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  const userId = "9e8c7866-8435-4b76-8683-709a03c9";

  const response = await sdk.rbac.fetchUserGroups({
      owner: EVM_ADDRESS,
      userId: userId,
      wssBaseUrl: WSS_BASE_URL
  });
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.fetchUserGroups({}) return object
  [
    {
      user: '9e8c7866-8435-4b76-8683-709a03c9',
      group: '58a52684-3ace-4e72-a025-85085b1d'
    }
  ]
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE
  });

  const userId = "9e8c7866-8435-4b76-8683-709a03c9";

  const response = await sdk.rbac.fetchUserGroups({
      owner: SUBSTRATE_ADDRESS,
      userId: userId
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.fetchUserGroups({}) return object
  [
    {
      user: '9e8c7866-8435-4b76-8683-709a03c9',
      group: '63d6417e-1a03-4fd8-9439-295ce979'
    }
  ]
  ```
</CodeGroup>

## unassignUserToGroup(userId, groupId, address, seed)

This function allows to unassign a specific user from a group in a permission management system.

| Parameter   | Type     | EVM      | Substrate | Description                                                                                  |
| ----------- | -------- | -------- | --------- | -------------------------------------------------------------------------------------------- |
| **userId**  | `string` | Required | Required  | ID of the user from which the group should be unassigned.                                    |
| **groupId** | `string` | Required | Required  | ID of the group that needs to be unassigned.                                                 |
| **seed**    | `string` | N/A      | Optional  | If not set at instance creation, allows user to define who sends the Substrate Transactions. |

### Unassign User to Group Code Examples

<CodeGroup>
  ```javascript EVM Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const EVM_ADDRESS = process.env["EVM_ADDRESS"];
  const EVM_PRIVATE = process.env["EVM_PRIVATE"];

  const sdk = await Sdk.createInstance({
      baseUrl: HTTPS_BASE_URL,
      chainType: Sdk.ChainType.EVM
  });

  // user id to unassign from group
  const userId = "9e8c7866-8435-4b76-8683-709a03c9";

  // previously created groupId
  const groupId = "58a52684-3ace-4e72-a025-85085b1d";

  // build the evm tx
  const tx = await sdk.rbac.unassignUserToGroup({
      userId: userId,
      groupId: groupId,
  });

  // send using Sdk function
  const receipt = await Sdk.sendEvmTx({
    tx: tx,
    baseUrl: HTTPS_BASE_URL,
    seed: EVM_PRIVATE
  });

  // fetch to see it has been unassigned
  const response = await sdk.rbac.fetchUserGroups({
      owner: EVM_ADDRESS,
      userId: userId,
      wssBaseUrl: WSS_BASE_URL
  });
  ```

  ```javascript EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.unassignUserToGroup({}) return object
  {
    to: '0x0000000000000000000000000000000000000802',
    data: '0x0b9cc42839653863373836362d383433352d346237362d383638332d373039613033633935386135323638342d336163652d346537322d613032352d3835303835623164'
  }

  // sendEvmTx({}) return object
  TransactionReceipt {
    provider: JsonRpcProvider {},
    to: '0x0000000000000000000000000000000000000802',
    from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
    contractAddress: null,
    hash: '0x1790d5bdc25d5ddd814e957a45a539400b4c717b5f0a25abec3d73896ac643ac',
    index: 0,
    blockHash: '0x3a862b4795987cdab60a62dd7d00fea2bd91e89b7a780a85af6c47c07b59ac65',
    blockNumber: 4501124,
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000001000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    gasUsed: 29169n,
    blobGasUsed: null,
    cumulativeGasUsed: 29169n,
    gasPrice: 100000943831n,
    blobGasPrice: null,
    type: 2,
    status: 1,
    root: undefined
  }
  ```

  ```javascript Substrate Request theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import { Sdk } from "@peaq-network/sdk";

  const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
  const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
  const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];

  const sdk = await Sdk.createInstance({
      baseUrl: WSS_BASE_URL,
      chainType: Sdk.ChainType.SUBSTRATE,
      seed: SUBSTRATE_SEED
  });

  // user id to unassign from group
  const userId = "9e8c7866-8435-4b76-8683-709a03c9";

  // previously created groupId
  const groupId = "63d6417e-1a03-4fd8-9439-295ce979";

  const response = await sdk.rbac.unassignUserToGroup({
      userId: userId,
      groupId: groupId,
  });

  // fetch to see it has been unassigned
  const fetchedUserGroups = await sdk.rbac.fetchUserGroups({
      owner: SUBSTRATE_ADDRESS,
      userId: userId
  });

  // disconnect when finished
  await sdk.disconnect();
  ```

  ```javascript Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  // sdk.rbac.unassignUserToGroup({}) return object
  {
    message: 'Successfully unassign user: 9e8c7866-8435-4b76-8683-709a03c9 from group: 63d6417e-1a03-4fd8-9439-295ce979'
  }
  ```
</CodeGroup>
