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

## create\_group(group\_name, group\_id)

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

| Parameter       | Type  | EVM      | Substrate | Description                                                                   |
| --------------- | ----- | -------- | --------- | ----------------------------------------------------------------------------- |
| **group\_name** | `str` | Required | Required  | Name of the group to be created.                                              |
| **group\_id**   | `str` | Optional | Optional  | ID of the group. If not provided, a new ID will be generated (32 characters). |

### Create Group Code Examples

<CodeGroup>
  ```python EVM Unsigned Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  group_name = "test_group_1"

  response = sdk.rbac.create_group(group_name=group_name)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC create group call for the group name of test_group_1 and group id of d07cd755-8f2f-497f-ad53-9d6cf828. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0x65c1e09c64303763643735352d386632662d34393766..."
    }
  }
  ```

  ```python EVM Write Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  group_name = "test_group_1"

  response = sdk.rbac.create_group(group_name=group_name)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully added the RBAC group under the group name of test_group_1 with the group id of 38c9ccb3-2346-4b25-ab28-51e1e2e3.",
    "receipt": {
      "transactionHash": "0x08a3a22c791596271d51e0c896e704efc28f360fa8912f1842ec3e6e4d2ef382",
      "transactionIndex": 0,
      "blockHash": "0x452c99c0e179f477d544eba3d9cea2566726582aaab420a0d896b2a1eed87b4a",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5847190,
      "cumulativeGasUsed": 44942,
      "gasUsed": 44942,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0xa02084845c66cf1021190e4778630b0a6de58f9606261968e3a6a203699cedd1"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c333...",
          "blockHash": "0x452c99c0e179f477d544eba3d9cea2566726582aaab420a0d896b2a1eed87b4a",
          "blockNumber": 5847190,
          "transactionHash": "0x08a3a22c791596271d51e0c896e704efc28f360fa8912f1842ec3e6e4d2ef382",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x0000000000000000000000000000000000000000000000400000000000...",
      "status": 1,
      "effectiveGasPrice": 102000000000,
      "type": 2
    }
  }
  ```

  ```python Substrate Unsigned Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  group_name = "test_group_1"

  response = sdk.rbac.create_group(group_name=group_name)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC create group call for the group name of test_group_1 and group id of 4d56f1e4-b5bd-4a41-8766-1a02d322. You must sign and send externally.",
    "call": {
      "call_module": "PeaqRbac",
      "call_function": "add_group",
      "call_args": {
        "group_id": "4d56f1e4-b5bd-4a41-8766-1a02d322",
        "name": "test_group_1"
      }
    }
  }
  ```

  ```python Substrate Write Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  group_name = "test_group_1"

  response = sdk.rbac.create_group(group_name=group_name)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully added the RBAC group under the group name of test_group_1 with the group id of 1801710e-b83b-4f1e-ba91-f7d53dd2.",
    "receipt": {
      "extrinsic_hash": "0x9c1b654a3d7ae7a58c8c210956ee3fdef9e0d17a3b14869dbfbb5f3e4167d1c8",
      "block_hash": "0xce4285fe64a7ff2d835031a0dec63b115d0617d3fa7b573148562e849baae3c4",
      "finalized": false,
      "extrinsic_index": 2,
      "call": {
        "module": "PeaqRbac",
        "function": "add_group",
        "args": {
          "group_id": "1801710e-b83b-4f1e-ba91-f7d53dd2",
          "name": "test_group_1"
        },
        "call_hash": "0x1539dacdf787f8de1eb622d956caa7e9ccaaf1f3f005ffb25470d379481e447d"
      },
      "events": [...],
      "success": true,
      "total_fee_amount": 2510624816339150
    }
  }

  ```
</CodeGroup>

## fetch\_group(owner, group\_id)

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

| Parameter     | Type  | EVM      | Substrate | Description                                    |
| ------------- | ----- | -------- | --------- | ---------------------------------------------- |
| **owner**     | `str` | Required | Required  | Address representing the owner of the group.   |
| **group\_id** | `str` | Required | Required  | ID of the group to be fetched (32 characters). |

### Fetch Group Code Examples

<CodeGroup>
  ```python EVM Read theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  EVM_ADDRESS = os.getenv("EVM_ADDRESS")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  group_id = "38c9ccb3-2346-4b25-ab28-51e1e2e3"

  response = sdk.rbac.fetch_group(owner=EVM_ADDRESS, group_id=group_id)
  ```

  ```python EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "id": "38c9ccb3-2346-4b25-ab28-51e1e2e3",
    "name": "test_group_1",
    "enabled": true
  }
  ```

  ```python Substrate Read theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_ADDRESS = os.getenv("SUBSTRATE_ADDRESS")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  group_id = "1801710e-b83b-4f1e-ba91-f7d53dd2"

  response = sdk.rbac.fetch_group(owner=SUBSTRATE_ADDRESS, group_id=group_id)
  ```

  ```python Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "id": "1801710e-b83b-4f1e-ba91-f7d53dd2",
    "name": "test_group_1",
    "enabled": true
  }
  ```
</CodeGroup>

## fetch\_groups(owner)

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

| Parameter | Type  | EVM      | Substrate | Description                                               |
| --------- | ----- | -------- | --------- | --------------------------------------------------------- |
| **owner** | `str` | Required | Required  | Address representing the owner of all the fetched groups. |

### Fetch Groups Code Examples

<CodeGroup>
  ```python EVM Read theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  EVM_ADDRESS = os.getenv("EVM_ADDRESS")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  response = sdk.rbac.fetch_groups(owner=EVM_ADDRESS)
  ```

  ```python EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  [
    {
      "id": "afd2ae0e-b1db-42b9-bca1-93e9328b",
      "name": "test_group_1",
      "enabled": true
    },
    {
      "id": "58a52684-3ace-4e72-a025-85085b1d",
      "name": "peaq-group-1",
      "enabled": true
    }
  ]
  ```

  ```python Substrate Read theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_ADDRESS = os.getenv("SUBSTRATE_ADDRESS")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  response = sdk.rbac.fetch_groups(owner=SUBSTRATE_ADDRESS)
  ```

  ```python Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  [
    {
      "id": "06856fab-c5ff-40cd-8e83-634264c6",
      "name": "test_group_1",
      "enabled": true
    },
    {
      "id": "63d6417e-1a03-4fd8-9439-295ce979",
      "name": "peaq-group-1",
      "enabled": true
    }
  ]
  ```
</CodeGroup>

## update\_group(group\_id, group\_name)

Allows updating the name of an existing group in the RBAC system.

| Parameter       | Type  | EVM      | Substrate | Description                                    |
| --------------- | ----- | -------- | --------- | ---------------------------------------------- |
| **group\_id**   | `str` | Required | Required  | ID of the group to be updated (32 characters). |
| **group\_name** | `str` | Required | Required  | New name for the group.                        |

### Update Group Code Examples

<CodeGroup>
  ```python EVM Unsigned Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  group_id = "d07cd755-8f2f-497f-ad53-9d6cf828"
  new_group_name = "updated_group_1"

  response = sdk.rbac.update_group(group_id=group_id, group_name=new_group_name)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC update group call for group d07cd755-8f2f-497f-ad53-9d6cf828 with name updated_group_1. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0xadb32ee164303763643735352d386632662d343937662d616435332d39643663663832380000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000f757064617465645f67726f75705f310000000000000000000000000000000000"
    }
  }
  ```

  ```python EVM Write Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  group_id = "38c9ccb3-2346-4b25-ab28-51e1e2e3"
  new_group_name = "updated_group_1"

  response = sdk.rbac.update_group(group_id=group_id, group_name=new_group_name)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully updated group 38c9ccb3-2346-4b25-ab28-51e1e2e3 with name updated_group_1.",
    "receipt": {
      "transactionHash": "0xcffd438327fdc964477ae78f3cc5d905d9d313f2978b6dc38ed7f4ed9647ff89",
      "transactionIndex": 0,
      "blockHash": "0xf130dd47b1a2c0e96a53e498d63bdbc911a087e53fec68b40162136e230558cf",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5847406,
      "cumulativeGasUsed": 34396,
      "gasUsed": 34396,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0x874a12c9c30f960e54438e406d3f35a9c0b1e41f61c910516d816ec7ed9011c6"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a396..."
          "blockHash": "0xf130dd47b1a2c0e96a53e498d63bdbc911a087e53fec68b40162136e230558cf",
          "blockNumber": 5847406,
          "transactionHash": "0xcffd438327fdc964477ae78f3cc5d905d9d313f2978b6dc38ed7f4ed9647ff89",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x0000000000000000000000000000000000000...",
      "status": 1,
      "effectiveGasPrice": 102000000000,
      "type": 2
    }
  }
  ```

  ```python Substrate Unsigned Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  group_id = "4d56f1e4-b5bd-4a41-8766-1a02d322"
  new_group_name = "updated_group_1"

  response = sdk.rbac.update_group(group_id=group_id, group_name=new_group_name)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC update group call for group 4d56f1e4-b5bd-4a41-8766-1a02d322 with name updated_group_1. You must sign and send externally.",
    "call": {
      "call_module": "PeaqRbac",
      "call_function": "update_group",
      "call_args": {
        "group_id": "4d56f1e4-b5bd-4a41-8766-1a02d322",
        "name": "updated_group_1"
      }
    }
  }
  ```

  ```python Substrate Write Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  group_id = "1801710e-b83b-4f1e-ba91-f7d53dd2"
  new_group_name = "updated_group_1"

  response = sdk.rbac.update_group(group_id=group_id, group_name=new_group_name)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully updated group 1801710e-b83b-4f1e-ba91-f7d53dd2 with name updated_group_1.",
    "receipt": {
      "extrinsic_hash": "0xd93d6afe32e8a494f6e4587c3ebcc28db447eb9dcb205f2b554ccb7f23fa7720",
      "block_hash": "0x734644badfe943015d101c44e287fc92f4b666285490eb8ed36f6fd5dcfcb2c9",
      "finalized": false,
      "extrinsic_index": 2,
      "call_module": "PeaqRbac",
      "call_function": "update_group",
      "call_args": {
        "group_id": "1801710e-b83b-4f1e-ba91-f7d53dd2",
        "name": "updated_group_1"
      },
      "events": [...],
      "total_fee": 2139486851158385
    }
  }
  ```
</CodeGroup>

## disable\_group(group\_id)

Disables a group within the RBAC system. A disabled group cannot be used for new role assignments.

| Parameter     | Type  | EVM      | Substrate | Description                                     |
| ------------- | ----- | -------- | --------- | ----------------------------------------------- |
| **group\_id** | `str` | Required | Required  | ID of the group to be disabled (32 characters). |

### Disable Group Code Examples

<CodeGroup>
  ```python EVM Unsigned Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  group_id = "d07cd755-8f2f-497f-ad53-9d6cf828"

  response = sdk.rbac.disable_group(group_id=group_id)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC disable group call for group d07cd755-8f2f-497f-ad53-9d6cf828. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0x47538f1264303763643735352d386632..."
    }
  }
  ```

  ```python EVM Write Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  group_id = "38c9ccb3-2346-4b25-ab28-51e1e2e3"

  response = sdk.rbac.disable_group(group_id=group_id)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully disabled group 38c9ccb3-2346-4b25-ab28-51e1e2e3.",
    "receipt": {
      "transactionHash": "0x3d28fb7e4afb225f04c7cb2bf28e0bdc7bd8bbc57b14a37dbc4e034e2b5d0949",
      "transactionIndex": 0,
      "blockHash": "0x0c2ad855d1d9a1a52a65e76f21cb20bbdefddeaa36768d6255d5a9230739f769",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5848348,
      "cumulativeGasUsed": 33784,
      "gasUsed": 33784,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0x35ffdf1d57e58fa1ceb80230b9f8a6e07c11374d095968b31d6e2fdcc4c53d7c"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c...",
          "blockHash": "0x0c2ad855d1d9a1a52a65e76f21cb20bbdefddeaa36768d6255d5a9230739f769",
          "blockNumber": 5848348,
          "transactionHash": "0x3d28fb7e4afb225f04c7cb2bf28e0bdc7bd8bbc57b14a37dbc4e034e2b5d0949",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x000000000000000000000000000000000008000000...",
      "status": 1,
      "effectiveGasPrice": 102000000000,
      "type": 2
    }
  }
  ```

  ```python Substrate Unsigned Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  group_id = "4d56f1e4-b5bd-4a41-8766-1a02d322"

  response = sdk.rbac.disable_group(group_id=group_id)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC disable group call for group 4d56f1e4-b5bd-4a41-8766-1a02d322. You must sign and send externally.",
    "call": {
      "value": {
        "call_module": "PeaqRbac",
        "call_function": "disable_group",
        "call_args": {
          "group_id": "4d56f1e4-b5bd-4a41-8766-1a02d322"
        }
      }
    }
  }
  ```

  ```python Substrate Write Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  group_id = "1801710e-b83b-4f1e-ba91-f7d53dd2"

  response = sdk.rbac.disable_group(group_id=group_id)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully disabled group 1801710e-b83b-4f1e-ba91-f7d53dd2.",
    "receipt": {
      "extrinsic_hash": "0xfba3fc23dd47dc26f349a998b4e26b97bbfd7ed11bd3d6cc1c64af1de3b5e9f1",
      "block_hash": "0x6df45a60532c4a215366f34b60fb0934ac275fc3a5244c14bb007a2ad4a3304d",
      "finalized": false,
      "events": [...],
      "total_fee_amount": 2138625423184026
    }
  }
  ```
</CodeGroup>

## assign\_role\_to\_group(group\_id, role\_id)

Assigns a role to a group in the RBAC system. This grants all members of the group the permissions associated with the role.

| Parameter     | Type  | EVM      | Substrate | Description                                            |
| ------------- | ----- | -------- | --------- | ------------------------------------------------------ |
| **group\_id** | `str` | Required | Required  | ID of the group to assign the role to (32 characters). |
| **role\_id**  | `str` | Required | Required  | ID of the role to be assigned (32 characters).         |

### Assign Role to Group Code Examples

<CodeGroup>
  ```python EVM Unsigned Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  group_id = "d07cd755-8f2f-497f-ad53-9d6cf828"
  role_id = "0bb60413-ebdd-44fb-ab2c-e7e0714f"

  response = sdk.rbac.assign_role_to_group(group_id=group_id, role_id=role_id)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC assign role to group call for role 0bb60413-ebdd-44fb-ab2c-e7e0714f and group d07cd755-8f2f-497f-ad53-9d6cf828. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0x03c4d7fb30626236303431332d656264642..."
    }
  }
  ```

  ```python EVM Write Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  group_id = "38c9ccb3-2346-4b25-ab28-51e1e2e3"
  role_id = "afd2ae0e-b1db-42b9-bca1-93e9328b"

  response = sdk.rbac.assign_role_to_group(group_id=group_id, role_id=role_id)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully assigned role afd2ae0e-b1db-42b9-bca1-93e9328b to group 38c9ccb3-2346-4b25-ab28-51e1e2e3.",
    "receipt": {
      "transactionHash": "0x72ded295dcbbef84c8cae67af567a769c778b6bc667d0d7713cc47f92b1d6f7d",
      "transactionIndex": 0,
      "blockHash": "0x46b99ed678287ed88a332131a8df6bd31c1ee53c50ffdcd8483de01c26e02eff",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5847482,
      "cumulativeGasUsed": 42080,
      "gasUsed": 42080,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0xd651bb257632b5e6dd788e141bf8eafe9bbaab70e59f796d0984cdb7a18c8cad"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c616...",
          "blockHash": "0x46b99ed678287ed88a332131a8df6bd31c1ee53c50ffdcd8483de01c26e02eff",
          "blockNumber": 5847482,
          "transactionHash": "0x72ded295dcbbef84c8cae67af567a769c778b6bc667d0d7713cc47f92b1d6f7d",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x000000000000000000000000000000..."
      "status": 1,
      "effectiveGasPrice": 102000000000,
      "type": 2
    }
  }
  ```

  ```python Substrate Unsigned Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  group_id = "4d56f1e4-b5bd-4a41-8766-1a02d322"
  role_id = "bc3a3e43-6f2e-4e55-83d3-72d5148a"

  response = sdk.rbac.assign_role_to_group(group_id=group_id, role_id=role_id)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC assign role to group call for role bc3a3e43-6f2e-4e55-83d3-72d5148a and group 4d56f1e4-b5bd-4a41-8766-1a02d322. You must sign and send externally.",
    "call": {
      "call_module": "PeaqRbac",
      "call_function": "assign_role_to_group",
      "call_args": {
        "role_id": "bc3a3e43-6f2e-4e55-83d3-72d5148a",
        "group_id": "4d56f1e4-b5bd-4a41-8766-1a02d322"
      }
    }
  }
  ```

  ```python Substrate Write Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  group_id = "1801710e-b83b-4f1e-ba91-f7d53dd2"
  role_id = "06856fab-c5ff-40cd-8e83-634264c6"

  response = sdk.rbac.assign_role_to_group(group_id=group_id, role_id=role_id)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully assigned role 06856fab-c5ff-40cd-8e83-634264c6 to group 1801710e-b83b-4f1e-ba91-f7d53dd2.",
    "receipt": {
      "extrinsic_hash": "0x9bafb69fa2c5ff1de311ec6bbe3887265f52d48cc484729cfe81a7823d320090",
      "block_hash": "0xb34b3ba10f1eb53500d33866c660deae9ab78a6fe431e0bb136c5a9231f9f659",
      "finalized": false,
      "extrinsic_index": 2,
      "call": {
        "call_module": "PeaqRbac",
        "call_function": "assign_role_to_group",
        "call_args": [
          {
            "name": "role_id",
            "type": "EntityId",
            "value": "0x30363835366661622d633566662d343063642d386538332d3633343236346336"
          },
          {
            "name": "group_id",
            "type": "EntityId",
            "value": "0x31383031373130652d623833622d346631652d626139312d6637643533646432"
          }
        ]
      },
      "events": [...],
      "total_fee_amount": 2411661613644938,
      "is_success": true
    }
  }

  ```
</CodeGroup>

## fetch\_group\_roles(owner, group\_id)

Fetches all roles assigned to a specific group in the RBAC system.

| Parameter     | Type  | EVM      | Substrate | Description                                          |
| ------------- | ----- | -------- | --------- | ---------------------------------------------------- |
| **owner**     | `str` | Required | Required  | Address of the group owner.                          |
| **group\_id** | `str` | Required | Required  | ID of the group to fetch roles from (32 characters). |

### Fetch Group Roles Code Examples

<CodeGroup>
  ```python EVM Fetch theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  EVM_ADDRESS = os.getenv("EVM_ADDRESS")
  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  group_id = "38c9ccb3-2346-4b25-ab28-51e1e2e3"

  response = sdk.rbac.fetch_group_roles(owner=EVM_ADDRESS, group_id=group_id)
  ```

  ```python EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  [
    {
      "role": "afd2ae0e-b1db-42b9-bca1-93e9328b",
      "group": "38c9ccb3-2346-4b25-ab28-51e1e2e3"
    }
  ]
  ```

  ```python Substrate Fetch theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  SUBSTRATE_ADDRESS = os.getenv("SUBSTRATE_ADDRESS")
  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  group_id = "1801710e-b83b-4f1e-ba91-f7d53dd2"

  response = sdk.rbac.fetch_group_roles(owner=SUBSTRATE_ADDRESS, group_id=group_id)
  ```

  ```python Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  [
    {
      "role": "06856fab-c5ff-40cd-8e83-634264c6",
      "group": "1801710e-b83b-4f1e-ba91-f7d53dd2"
    }
  ]
  ```
</CodeGroup>

## unassign\_role\_to\_group(group\_id, role\_id)

Removes a role assignment from a group in the RBAC system. This revokes the role's permissions from all group members.

| Parameter     | Type  | EVM      | Substrate | Description                                                |
| ------------- | ----- | -------- | --------- | ---------------------------------------------------------- |
| **group\_id** | `str` | Required | Required  | ID of the group to unassign the role from (32 characters). |
| **role\_id**  | `str` | Required | Required  | ID of the role to be unassigned (32 characters).           |

### Unassign Role to Group Code Examples

<CodeGroup>
  ```python EVM Unsigned Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  group_id = "d07cd755-8f2f-497f-ad53-9d6cf828"
  role_id = "0bb60413-ebdd-44fb-ab2c-e7e0714f"

  response = sdk.rbac.unassign_role_to_group(group_id=group_id, role_id=role_id)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC unassign role from group call for role 0bb60413-ebdd-44fb-ab2c-e7e0714f and group d07cd755-8f2f-497f-ad53-9d6cf828. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0xad58943730626236303431332d6562646..."
    }
  }
  ```

  ```python EVM Write Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  group_id = "38c9ccb3-2346-4b25-ab28-51e1e2e3"
  role_id = "afd2ae0e-b1db-42b9-bca1-93e9328b"

  response = sdk.rbac.unassign_role_to_group(group_id=group_id, role_id=role_id)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully unassigned role afd2ae0e-b1db-42b9-bca1-93e9328b from group 38c9ccb3-2346-4b25-ab28-51e1e2e3.",
    "receipt": {
      "transactionHash": "0x36dd75c5b4826e9bb644f76b1729aac2f04b32bc8af579f57b67ac0ff92cbc53",
      "transactionIndex": 0,
      "blockHash": "0x5ed9f7af6fcc840cca9edc7d0e17cd6e60beff9e72bf561c8d1017e825d3a186",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5847564,
      "cumulativeGasUsed": 39887,
      "gasUsed": 39887,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0x6673f6cc0e410bc95e511d3c8b391c75558f5f7cb06ce317a6e05934ea60cff6"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c616...",
          "blockHash": "0x5ed9f7af6fcc840cca9edc7d0e17cd6e60beff9e72bf561c8d1017e825d3a186",
          "blockNumber": 5847564,
          "transactionHash": "0x36dd75c5b4826e9bb644f76b1729aac2f04b32bc8af579f57b67ac0ff92cbc53",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x00000000000000000000000000000000000...",
      "status": 1,
      "effectiveGasPrice": 102000000000,
      "type": 2
    }
  }
  ```

  ```python Substrate Unsigned Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  group_id = "4d56f1e4-b5bd-4a41-8766-1a02d322"
  role_id = "bc3a3e43-6f2e-4e55-83d3-72d5148a"

  response = sdk.rbac.unassign_role_to_group(group_id=group_id, role_id=role_id)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC unassign role from group call for role bc3a3e43-6f2e-4e55-83d3-72d5148a and group 4d56f1e4-b5bd-4a41-8766-1a02d322. You must sign and send externally.",
    "call": {
      "call_module": "PeaqRbac",
      "call_function": "unassign_role_to_group",
      "call_args": {
        "role_id": "bc3a3e43-6f2e-4e55-83d3-72d5148a",
        "group_id": "4d56f1e4-b5bd-4a41-8766-1a02d322"
      }
    }
  }
  ```

  ```python Substrate Write Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  group_id = "1801710e-b83b-4f1e-ba91-f7d53dd2"
  role_id = "06856fab-c5ff-40cd-8e83-634264c6"

  response = sdk.rbac.unassign_role_to_group(group_id=group_id, role_id=role_id)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully unassigned role 06856fab-c5ff-40cd-8e83-634264c6 from group 1801710e-b83b-4f1e-ba91-f7d53dd2.",
    "receipt": {
      "extrinsic_hash": "0x2543c6fddadcbae7ea487da0e7e04760fa309dc4c02574dea9222f09249bbaef",
      "block_hash": "0x344a637b2f9482fa4a23022db2a26e9898eaf165ff1c30f7c076b0ef376ee281",
      "finalized": false,
      "call": {
        "module": "PeaqRbac",
        "function": "unassign_role_to_group",
        "args": {
          "role_id": "06856fab-c5ff-40cd-8e83-634264c6",
          "group_id": "1801710e-b83b-4f1e-ba91-f7d53dd2"
        }
      },
      "events": [...],
      "success": true,
      "total_fee": 2334736376131475
    }
  }

  ```
</CodeGroup>

## assign\_user\_to\_group(user\_id, group\_id)

Assigns a user to a group in the RBAC system. The user will inherit all roles and permissions assigned to the group.

| Parameter     | Type  | EVM      | Substrate | Description                                                 |
| ------------- | ----- | -------- | --------- | ----------------------------------------------------------- |
| **user\_id**  | `str` | Required | Required  | ID of the user to be assigned to the group (32 characters). |
| **group\_id** | `str` | Required | Required  | ID of the group to assign the user to (32 characters).      |

### Assign User to Group Code Examples

<CodeGroup>
  ```python EVM Unsigned Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  user_id = "9e8c7866-8435-4b76-8683-709a03c9"
  group_id = "d07cd755-8f2f-497f-ad53-9d6cf828"

  response = sdk.rbac.assign_user_to_group(user_id=user_id, group_id=group_id)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC assign user to group call for user 9e8c7866-8435-4b76-8683-709a03c9 and group d07cd755-8f2f-497f-ad53-9d6cf828. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0xa76110c439653863373836362d383433352..."
    }
  }
  ```

  ```python EVM Write Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  user_id = "9e8c7866-8435-4b76-8683-709a03c9"
  group_id = "38c9ccb3-2346-4b25-ab28-51e1e2e3"

  response = sdk.rbac.assign_user_to_group(user_id=user_id, group_id=group_id)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully assigned user 9e8c7866-8435-4b76-8683-709a03c9 to group 38c9ccb3-2346-4b25-ab28-51e1e2e3.",
    "receipt": {
      "transactionHash": "0x03e12d10aeb79f1a46fcd0cd1b373ce6da3056659dc7752bcd3db4ac04804bee",
      "transactionIndex": 0,
      "blockHash": "0xde2e5d5fde16013727952341cc5f38c622794c9970215b642287f231f63aad9a",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5847609,
      "cumulativeGasUsed": 40896,
      "gasUsed": 40896,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0x09eada7abd703e77ea8611684f278dfc3e735c19b0b17b32d1a51e23e9032514"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c39...",
          "blockHash": "0xde2e5d5fde16013727952341cc5f38c622794c9970215b642287f231f63aad9a",
          "blockNumber": 5847609,
          "transactionHash": "0x03e12d10aeb79f1a46fcd0cd1b373ce6da3056659dc7752bcd3db4ac04804bee",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x000000000000000000000000000000000...",
      "status": 1,
      "effectiveGasPrice": 102000000000,
      "type": 2
    }
  }
  ```

  ```python Substrate Unsigned Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  user_id = "9e8c7866-8435-4b76-8683-709a03c9"
  group_id = "4d56f1e4-b5bd-4a41-8766-1a02d322"

  response = sdk.rbac.assign_user_to_group(user_id=user_id, group_id=group_id)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC assign user to group call for user 9e8c7866-8435-4b76-8683-709a03c9 and group 4d56f1e4-b5bd-4a41-8766-1a02d322. You must sign and send externally.",
    "call": {
      "call_module": "PeaqRbac",
      "call_function": "assign_user_to_group",
      "call_args": {
        "user_id": "9e8c7866-8435-4b76-8683-709a03c9",
        "group_id": "4d56f1e4-b5bd-4a41-8766-1a02d322"
      }
    }
  }
  ```

  ```python Substrate Write Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  user_id = "9e8c7866-8435-4b76-8683-709a03c9"
  group_id = "1801710e-b83b-4f1e-ba91-f7d53dd2"

  response = sdk.rbac.assign_user_to_group(user_id=user_id, group_id=group_id)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully assigned user 9e8c7866-8435-4b76-8683-709a03c9 to group 1801710e-b83b-4f1e-ba91-f7d53dd2.",
    "receipt": {
      "extrinsic_hash": "0x542e07579f5d802867505afd4adfb17ff207dade3caed8757b929500afac4e87",
      "block_hash": "0xec8ece52b4e616c0d1fae292eb56ff804601946045bd2dea686da02003174d97",
      "finalized": false,
      "sender": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
      "call": {
        "module": "PeaqRbac",
        "function": "assign_user_to_group",
        "user_id": "9e8c7866-8435-4b76-8683-709a03c9",
        "group_id": "1801710e-b83b-4f1e-ba91-f7d53dd2"
      },
      "events": [...],
      "success": true,
      "fee": 2370129280868884
    }
  }

  ```
</CodeGroup>

## fetch\_user\_groups(owner, user\_id)

Fetches all groups that a specific user is assigned to in the RBAC system.

| Parameter    | Type  | EVM      | Substrate | Description                                         |
| ------------ | ----- | -------- | --------- | --------------------------------------------------- |
| **owner**    | `str` | Required | Required  | Address of the group owner.                         |
| **user\_id** | `str` | Required | Required  | ID of the user to fetch groups for (32 characters). |

### Fetch User Groups Code Examples

<CodeGroup>
  ```python EVM Fetch theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  EVM_ADDRESS = os.getenv("EVM_ADDRESS")
  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  user_id = "9e8c7866-8435-4b76-8683-709a03c9"

  response = sdk.rbac.fetch_user_groups(owner=EVM_ADDRESS, user_id=user_id)
  ```

  ```python EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  [
    {
      "user": "9e8c7866-8435-4b76-8683-709a03c9",
      "group": "38c9ccb3-2346-4b25-ab28-51e1e2e3"
    }
  ]
  ```

  ```python Substrate Fetch theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  SUBSTRATE_ADDRESS = os.getenv("SUBSTRATE_ADDRESS")
  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )

  user_id = "9e8c7866-8435-4b76-8683-709a03c9"

  response = sdk.rbac.fetch_user_groups(owner=SUBSTRATE_ADDRESS, user_id=user_id)
  ```

  ```python Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  [
    {
      "user": "9e8c7866-8435-4b76-8683-709a03c9",
      "group": "1801710e-b83b-4f1e-ba91-f7d53dd2"
    }
  ]
  ```
</CodeGroup>

## unassign\_user\_to\_group(user\_id, group\_id)

Removes a user from a group in the RBAC system. The user will lose all roles and permissions associated with the group.

| Parameter     | Type  | EVM      | Substrate | Description                                                     |
| ------------- | ----- | -------- | --------- | --------------------------------------------------------------- |
| **user\_id**  | `str` | Required | Required  | ID of the user to be unassigned from the group (32 characters). |
| **group\_id** | `str` | Required | Required  | ID of the group to unassign the user from (32 characters).      |

### Unassign User to Group Code Examples

<CodeGroup>
  ```python EVM Unsigned Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM
  )

  user_id = "9e8c7866-8435-4b76-8683-709a03c9"
  group_id = "d07cd755-8f2f-497f-ad53-9d6cf828"

  response = sdk.rbac.unassign_user_to_group(user_id=user_id, group_id=group_id)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC unassign user from group call for user 9e8c7866-8435-4b76-8683-709a03c9 and group d07cd755-8f2f-497f-ad53-9d6cf828. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0x0b9cc42839653863373836362d38343335..."
    }
  }
  ```

  ```python EVM Write Tx theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
  EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")

  sdk = Sdk.create_instance(
      base_url=HTTPS_PEAQ_URL,
      chain_type=ChainType.EVM,
      seed=EVM_PRIVATE_KEY
  )

  user_id = "9e8c7866-8435-4b76-8683-709a03c9"
  group_id = "38c9ccb3-2346-4b25-ab28-51e1e2e3"

  response = sdk.rbac.unassign_user_to_group(user_id=user_id, group_id=group_id)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully unassigned user 9e8c7866-8435-4b76-8683-709a03c9 from group 38c9ccb3-2346-4b25-ab28-51e1e2e3.",
    "receipt": {
      "transactionHash": "0x60f742420c44b769d1c0184c739f9bd4552363f56e6e8619f4ca03486ba35c72",
      "transactionIndex": 0,
      "blockHash": "0x77a9c51a20451ef6cd7ee32f440a76dd1a8d9bdf3bf17ff646d081ff17a02005",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5847665,
      "cumulativeGasUsed": 39867,
      "gasUsed": 39867,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0x8ce274ea85050978acba6aae9ca3616564f6fd4e74829427f298d0507a609aa6"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275...",
          "blockHash": "0x77a9c51a20451ef6cd7ee32f440a76dd1a8d9bdf3bf17ff646d081ff17a02005",
          "blockNumber": 5847665,
          "transactionHash": "0x60f742420c44b769d1c0184c739f9bd4552363f56e6e8619f4ca03486ba35c72",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x0000000000000000000000000000000000000...",
      "status": 1,
      "effectiveGasPrice": 102000000000,
      "type": 2
    }
  }
  ```

  ```python Substrate Unsigned Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE
  )
  user_id = "9e8c7866-8435-4b76-8683-709a03c9"
  group_id = "4d56f1e4-b5bd-4a41-8766-1a02d322"

  response = sdk.rbac.unassign_user_to_group(user_id=user_id, group_id=group_id)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC unassign user from group call for user 9e8c7866-8435-4b76-8683-709a03c9 and group 4d56f1e4-b5bd-4a41-8766-1a02d322. You must sign and send externally.",
    "call": {
      "call_module": "PeaqRbac",
      "call_function": "unassign_user_to_group",
      "call_args": {
        "user_id": "9e8c7866-8435-4b76-8683-709a03c9",
        "group_id": "4d56f1e4-b5bd-4a41-8766-1a02d322"
      }
    }
  }
  ```

  ```python Substrate Write Call theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  import os
  from dotenv import load_dotenv
  from peaq_sdk import Sdk
  from peaq_sdk.types import ChainType

  load_dotenv()

  WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
  SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")

  sdk = Sdk.create_instance(
      base_url=WSS_PEAQ_URL,
      chain_type=ChainType.SUBSTRATE,
      seed=SUBSTRATE_SEED
  )

  user_id = "9e8c7866-8435-4b76-8683-709a03c9"
  group_id = "1801710e-b83b-4f1e-ba91-f7d53dd2"

  response = sdk.rbac.unassign_user_to_group(user_id=user_id, group_id=group_id)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully unassigned user 9e8c7866-8435-4b76-8683-709a03c9 from group 1801710e-b83b-4f1e-ba91-f7d53dd2.",
    "receipt": {
      "extrinsic_hash": "0x3060b1cf3c041a79cd992c9769297e1bdfc448e034723c2c1d92afc5f63f8b34",
      "block_hash": "0x824263ac6db7a08f1f8608b6b376e4b837b99fe15e79bec485d42dd3d8485c0f",
      "finalized": false,
      "extrinsic_idx": 2,
      "call": {
        "call_module": "PeaqRbac",
        "call_function": "unassign_user_to_group",
        "call_args": [
          {
            "name": "user_id",
            "type": "EntityId",
            "value": "0x39653863373836362d383433352d346237362d383638332d3730396130336339"
          },
          {
            "name": "group_id",
            "type": "EntityId",
            "value": "0x31383031373130652d623833622d346631652d626139312d6637643533646432"
          }
        ]
      },
      "events": [...],
      "total_fee_amount": 2334013842895666
    }
  }
  ```
</CodeGroup>
