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

# Role

Python SDK provides support for creating and managing roles in the peaq network's Role-Based Access Control (RBAC) system.

## create\_role(role\_name, role\_id)

Creates a new role in the peaq network's Role-Based Access Control (RBAC) system. The role will be owned by the address derived from the seed (if provided) or must be signed externally.

| Parameter      | Type     | EVM      | Substrate | Description                                                                                  |
| -------------- | -------- | -------- | --------- | -------------------------------------------------------------------------------------------- |
| **role\_name** | `string` | Required | Required  | Name of the role to be created.                                                              |
| **role\_id**   | `string` | Optional | Optional  | Unique identifier for the role (32 characters). If not provided, one will be auto-generated. |

### Create Role 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
  )

  role_name = "test_role_1"

  response = sdk.rbac.create_role(role_name=role_name)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC create role call for the role name of test_role_1 and role id of 0bb60413-ebdd-44fb-ab2c-e7e0714f. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0xbca838d630626236303431332d656264642d343466622d616232..."
    }
  }
  ```

  ```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
  )

  role_name = "test_role_1"

  response = sdk.rbac.create_role(role_name=role_name)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully added the RBAC role under the role name of test_role_1 with the role id of afd2ae0e-b1db-42b9-bca1-93e9328b.",
    "receipt": {
      "transactionHash": "0x1c60eee57692882cbd3dfae35305fb07eae6d567eb4a788bcdeda67d18ff63fb",
      "transactionIndex": 0,
      "blockHash": "0xd5cd4c0c29dd7f007dc5fe60b533faaabc4c74d1d8945aaee17a0a3e88911e47",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5846791,
      "cumulativeGasUsed": 44939,
      "gasUsed": 44939,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0x298ec29f9de7335421cd619739f36aa75b4b6d617ac5c411d41ebbab529593b5"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a...",
          "blockHash": "0xd5cd4c0c29dd7f007dc5fe60b533faaabc4c74d1d8945aaee17a0a3e88911e47",
          "blockNumber": 5846791,
          "transactionHash": "0x1c60eee57692882cbd3dfae35305fb07eae6d567eb4a788bcdeda67d18ff63fb",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x...",
      "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
  )

  role_name = "test_role_1"

  response = sdk.rbac.create_role(role_name=role_name)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC create role call for the role name of test_role_1 and role id of bc3a3e43-6f2e-4e55-83d3-72d5148a. You must sign and send externally.",
    "call": {
      "call_module": "PeaqRbac",
      "call_function": "add_role",
      "call_args": {
        "role_id": "bc3a3e43-6f2e-4e55-83d3-72d5148a",
        "name": "test_role_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
  )

  role_name = "test_role_1"

  response = sdk.rbac.create_role(role_name=role_name)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully added the RBAC role under the role name of test_role_1 with the role id of 06856fab-c5ff-40cd-8e83-634264c6.",
    "receipt": {
      "extrinsic_hash": "0x491b16e0bb66505a93b84bdaf7b9114dbde62b4e6e56ffb90f6a005e4aea2393",
      "block_hash": "0x16ef5978e10c9b9b7a7aad676cf6db8531f44175ed72af43bae1384b4e5b9b0d",
      "address": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
      "call": {
        "module": "PeaqRbac",
        "function": "add_role",
        "args": {
          "role_id": "06856fab-c5ff-40cd-8e83-634264c6",
          "name": "test_role_1"
        }
      },
      "events": [...],
      "total_fee_amount": 2510932068336512,
      "status": "success"
    }
  }
  ```
</CodeGroup>

## fetch\_role(owner, role\_id)

Fetches a specific role by its ID and owner address from the peaq network's RBAC system.

| Parameter    | Type     | EVM      | Substrate | Description                                             |
| ------------ | -------- | -------- | --------- | ------------------------------------------------------- |
| **owner**    | `string` | Required | Required  | Address representing the owner of the role.             |
| **role\_id** | `string` | Required | Required  | Unique identifier of the role to fetch (32 characters). |

### Fetch Role 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()

  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
  )

  role_id = "afd2ae0e-b1db-42b9-bca1-93e9328b"

  response = sdk.rbac.fetch_role(owner=EVM_ADDRESS, role_id=role_id)
  ```

  ```python EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "id": "afd2ae0e-b1db-42b9-bca1-93e9328b",
    "name": "test_role_1",
    "enabled": true
  }
  ```

  ```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()

  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
  )

  role_id = "06856fab-c5ff-40cd-8e83-634264c6"

  response = sdk.rbac.fetch_role(owner=SUBSTRATE_ADDRESS, role_id=role_id)
  ```

  ```python Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "id": "06856fab-c5ff-40cd-8e83-634264c6",
    "name": "test_role_1",
    "enabled": true
  }
  ```
</CodeGroup>

## fetch\_roles(owner)

Fetches all roles associated with the specified owner address from the peaq network's RBAC system.

| Parameter | Type     | EVM      | Substrate | Description                                                 |
| --------- | -------- | -------- | --------- | ----------------------------------------------------------- |
| **owner** | `string` | Required | Required  | Address that represents the owner of all the fetched roles. |

### Fetch 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()

  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_roles(owner=EVM_ADDRESS)
  ```

  ```python EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  [
    {
      "id": "b68a5589-1284-49e9-8276-0359a429",
      "name": "test_role_1",
      "enabled": true
    },
    {
      "id": "e09fe342-f8ee-46d1-82e2-a60a5b6e",
      "name": "admin_role",
      "enabled": true
    }
  ]
  ```

  ```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()

  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_roles(owner=SUBSTRATE_ADDRESS)
  ```

  ```python Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  [
    {
      "id": "bc3f20d5-c519-4048-8db1-4bbf48dc",
      "name": "test_role_1",
      "enabled": true
    },
    {
      "id": "bb3d5a05-3a4a-452b-a96d-372832ff",
      "name": "admin_role",
      "enabled": true
    }
  ]
  ```
</CodeGroup>

## update\_role(role\_id, role\_name)

Updates the name of an existing role in the peaq network's RBAC system.

| Parameter      | Type  | EVM      | Substrate | Description                                              |
| -------------- | ----- | -------- | --------- | -------------------------------------------------------- |
| **role\_id**   | `str` | Required | Required  | Unique identifier of the role to update (32 characters). |
| **role\_name** | `str` | Required | Required  | New name to assign to the role.                          |

### Update Role 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
  )

  role_id = "0bb60413-ebdd-44fb-ab2c-e7e0714f"
  new_role_name = "updated-peaq-role"

  response = sdk.rbac.update_role(
      role_id=role_id,
      role_name=new_role_name
  )
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC update role call for role 0bb60413-ebdd-44fb-ab2c-e7e0714f with name updated-peaq-role. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0x7cc0a218306262363034313..."
    }
  }
  ```

  ```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
  )

  role_id = "afd2ae0e-b1db-42b9-bca1-93e9328b"
  new_role_name = "updated-peaq-role"

  response = sdk.rbac.update_role(
      role_id=role_id,
      role_name=new_role_name
  )
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully updated role afd2ae0e-b1db-42b9-bca1-93e9328b with name updated-peaq-role.",
    "receipt": {
      "transactionHash": "0x2e37e5f390d23b0b2d1e3b7360c6a85e6120ece97d5f5c8f4bc0f66b749d9f5d",
      "transactionIndex": 0,
      "blockHash": "0x5cd3a0cee6a138d3c37bba32719f622b68681ca778a539afe4d9c2e36dcbf15a",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5846913,
      "cumulativeGasUsed": 34419,
      "gasUsed": 34419,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0xc43fa962e2791d84b2f4ad1079b7020844acab2410952d61f00c544d837bc47f"
          ],
          "data": "0x0000000000000000000000009eeab1ac...",
          "blockHash": "0x5cd3a0cee6a138d3c37bba32719f622b68681ca778a539afe4d9c2e36dcbf15a",
          "blockNumber": 5846913,
          "transactionHash": "0x2e37e5f390d23b0b2d1e3b7360c6a85e6120ece97d5f5c8f4bc0f66b749d9f5d",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x0000000000000000000000000000000000...",
      "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
  )

  role_id = "bc3a3e43-6f2e-4e55-83d3-72d5148a"
  new_role_name = "updated-peaq-role"

  response = sdk.rbac.update_role(
      role_id=role_id,
      role_name=new_role_name
  )
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC update role call for role bc3a3e43-6f2e-4e55-83d3-72d5148a with name updated-peaq-role. You must sign and send externally.",
    "call": {
      "call_module": "PeaqRbac",
      "call_function": "update_role",
      "call_args": {
        "role_id": "bc3a3e43-6f2e-4e55-83d3-72d5148a",
        "name": "updated-peaq-role"
      }
    }
  }
  ```

  ```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
  )

  role_id = "06856fab-c5ff-40cd-8e83-634264c6"
  new_role_name = "updated-peaq-role"

  response = sdk.rbac.update_role(
      role_id=role_id,
      role_name=new_role_name
  )
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully updated role 06856fab-c5ff-40cd-8e83-634264c6 with name updated-peaq-role.",
    "receipt": {
      "extrinsic_hash": "0xb92e6221fda595175739bc9a5882edfd0dd23193e24636a2037a5d69018b3c3e",
      "block_hash": "0xa22f5ac2f68f587f82d3b0b6b982708e85dbcb9fce874959effe02bfc2d49d33",
      "extrinsic_index": 3,
      "address": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
      "call": {
        "call_index": "0x6703",
        "call_function": "update_role",
        "call_module": "PeaqRbac",
        "call_args": [
          {
            "name": "role_id",
            "type": "EntityId",
            "value": "0x30363835366661622d633566662d343063642d386538332d3633343236346336"
          },
          {
            "name": "name",
            "type": "BoundedVec<u8, BoundedDataLen>",
            "value": "updated-peaq-role"
          }
        ],
        "call_hash": "0x05f9c3dc3912c2cd4315e549a3f83016ba29d05361bd73df541606064492c7e6"
      },
      "events": [...],
      "total_fee": 2139430732072111
    }
  }
  ```
</CodeGroup>

## disable\_role(role\_id)

Disables a role in the peaq network's RBAC system, making it inactive while preserving its data.

| Parameter    | Type  | EVM      | Substrate | Description                                               |
| ------------ | ----- | -------- | --------- | --------------------------------------------------------- |
| **role\_id** | `str` | Required | Required  | Unique identifier of the role to disable (32 characters). |

### Disable Role 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
  )

  role_id = "0bb60413-ebdd-44fb-ab2c-e7e0714f"

  response = sdk.rbac.disable_role(role_id=role_id)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC disable role call for role 0bb60413-ebdd-44fb-ab2c-e7e0714f. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0x7c4a13b130626236303431332d656264642..."
    }
  }
  ```

  ```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
  )

  role_id = "afd2ae0e-b1db-42b9-bca1-93e9328b"

  response = sdk.rbac.disable_role(role_id=role_id)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully disabled role afd2ae0e-b1db-42b9-bca1-93e9328b.",
    "receipt": {
      "transactionHash": "0x5de14837069c6b4992b0d7da99de6c7a0759e402cf4be2768bfa28a126be9e0e",
      "transactionIndex": 0,
      "blockHash": "0x5f1460c07e1a1dd4951fe258461706f5402b15c6b42fc68c2ba3e2f8d2f3c034",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5848370,
      "cumulativeGasUsed": 33783,
      "gasUsed": 33783,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0x47808f9766351846ab3f47ddfd0cfc00fd1a4831674f2c872826932b0184d0be"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c61666432616530652d62316...",
          "blockHash": "0x5f1460c07e1a1dd4951fe258461706f5402b15c6b42fc68c2ba3e2f8d2f3c034",
          "blockNumber": 5848370,
          "transactionHash": "0x5de14837069c6b4992b0d7da99de6c7a0759e402cf4be2768bfa28a126be9e0e",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000...",
      "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
  )

  role_id = "bc3a3e43-6f2e-4e55-83d3-72d5148a"

  response = sdk.rbac.disable_role(role_id=role_id)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC disable role call for role bc3a3e43-6f2e-4e55-83d3-72d5148a. You must sign and send externally.",
    "call": {
      "value": {
        "call_module": "PeaqRbac",
        "call_function": "disable_role",
        "call_args": {
          "role_id": "bc3a3e43-6f2e-4e55-83d3-72d5148a"
        }
      }
    }
  }
  ```

  ```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
  )

  role_id = "06856fab-c5ff-40cd-8e83-634264c6"

  response = sdk.rbac.disable_role(role_id=role_id)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully disabled role 06856fab-c5ff-40cd-8e83-634264c6.",
    "receipt": {
      "extrinsic_hash": "0x2f1dbdc1c1cdd054a0f62b091795098b510894b328605bd37508cdeb7deab84e",
      "block_hash": "0x347ea0edb1da99e6323cc0e2ec1424af9291d4a9a4d08b88eafadb31bf380b78",
      "finalized": false,
      "events": [...],
      "total_fee_amount": 2138608587458143
    }
  }
  ```
</CodeGroup>

## assign\_role\_to\_user(role\_id, user\_id)

Assigns a specific role to a user in the peaq network's RBAC system.

| Parameter    | Type  | EVM      | Substrate | Description                                                          |
| ------------ | ----- | -------- | --------- | -------------------------------------------------------------------- |
| **role\_id** | `str` | Required | Required  | Unique identifier of the role to assign (32 characters).             |
| **user\_id** | `str` | Required | Required  | Unique identifier of the user to assign the role to (32 characters). |

### Assign Role to User 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
  )

  role_id = "0bb60413-ebdd-44fb-ab2c-e7e0714f"
  user_id = "9e8c7866-8435-4b76-8683-709a03c9"

  response = sdk.rbac.assign_role_to_user(role_id=role_id, user_id=user_id)
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC assign role to user call for role 0bb60413-ebdd-44fb-ab2c-e7e0714f and user 9e8c7866-8435-4b76-8683-709a03c9. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0xae8cdd7930626236303..."
    }
  }
  ```

  ```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
  )

  role_id = "afd2ae0e-b1db-42b9-bca1-93e9328b"
  user_id = "9e8c7866-8435-4b76-8683-709a03c9"

  response = sdk.rbac.assign_role_to_user(role_id=role_id, user_id=user_id)
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully assigned role afd2ae0e-b1db-42b9-bca1-93e9328b to user 9e8c7866-8435-4b76-8683-709a03c9.",
    "receipt": {
      "transactionHash": "0xeaabe5ac83c9e7f3701e21434c1c75c4740e5f1beb9f2315536732888acea8c9",
      "transactionIndex": 1,
      "blockHash": "0xcc52548f9cdc19bbe866b98d6a2d759713a9323fb66892377dbcd3a9025fe8ec",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5846990,
      "cumulativeGasUsed": 297661,
      "gasUsed": 40890,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0x484758882cb51a9d0452f6ef468ec5c3baaf0363de4265321ccc1bb959e7a445"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646...",
          "blockHash": "0xcc52548f9cdc19bbe866b98d6a2d759713a9323fb66892377dbcd3a9025fe8ec",
          "blockNumber": 5846990,
          "transactionHash": "0xeaabe5ac83c9e7f3701e21434c1c75c4740e5f1beb9f2315536732888acea8c9",
          "transactionIndex": 1,
          "logIndex": 4,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x00000000000000000000000000000...",
      "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
  )

  role_id = "bc3a3e43-6f2e-4e55-83d3-72d5148a"
  user_id = "9e8c7866-8435-4b76-8683-709a03c9"

  response = sdk.rbac.assign_role_to_user(role_id=role_id, user_id=user_id)
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC assign role to user call for role bc3a3e43-6f2e-4e55-83d3-72d5148a and user 9e8c7866-8435-4b76-8683-709a03c9. You must sign and send externally.",
    "call": {
      "call_module": "PeaqRbac",
      "call_function": "assign_role_to_user",
      "call_args": {
        "role_id": "bc3a3e43-6f2e-4e55-83d3-72d5148a",
        "user_id": "9e8c7866-8435-4b76-8683-709a03c9"
      }
    }
  }
  ```

  ```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
  )

  role_id = "06856fab-c5ff-40cd-8e83-634264c6"
  user_id = "9e8c7866-8435-4b76-8683-709a03c9"

  response = sdk.rbac.assign_role_to_user(role_id=role_id, user_id=user_id)
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully assigned role 06856fab-c5ff-40cd-8e83-634264c6 to user 9e8c7866-8435-4b76-8683-709a03c9.",
    "receipt": {
      "extrinsic_hash": "0x8e7f2aeb8e3691d788f003df50f7515002fb5408d4ff0bbb2d60b69dfa1adba6",
      "block_hash": "0xd92005c22c82221ef4c98047724cab91c537ecb08ddc7e0a21626a47f6753922",
      "finalized": false,
      "extrinsic_index": 2,
      "call": {
        "call_module": "PeaqRbac",
        "call_function": "assign_role_to_user",
        "call_args": {
          "role_id": "06856fab-c5ff-40cd-8e83-634264c6",
          "user_id": "9e8c7866-8435-4b76-8683-709a03c9"
        }
      },
      "events": [...],
      "total_fee": "2369909013455249"
    }
  }

  ```
</CodeGroup>

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

Fetches all roles assigned to a specific user in the peaq network's RBAC system.

| Parameter    | Type  | EVM      | Substrate | Description                                                       |
| ------------ | ----- | -------- | --------- | ----------------------------------------------------------------- |
| **owner**    | `str` | Required | Required  | Address representing the owner of the roles.                      |
| **user\_id** | `str` | Required | Required  | Unique identifier of the user to fetch roles for (32 characters). |

### Fetch User Roles 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
  )

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

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

  ```python EVM Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  [
    {
      "role": "65503c15-6cd7-4320-b326-3f5c7d2b",
      "user": "9e8c7866-8435-4b76-8683-709a03c9"
    },
    {
      "role": "afd2ae0e-b1db-42b9-bca1-93e9328b",
      "user": "9e8c7866-8435-4b76-8683-709a03c9"
    }
  ]
  ```

  ```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
  )

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

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

  ```python Substrate Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  [
    {
      "role": "06856fab-c5ff-40cd-8e83-634264c6",
      "user": "9e8c7866-8435-4b76-8683-709a03c9"
    },
    {
      "role": "7128759c-f869-4818-8b1d-98ce4b12",
      "user": "9e8c7866-8435-4b76-8683-709a03c9"
    }
  ]
  ```
</CodeGroup>

## unassign\_role\_to\_user(role\_id, user\_id)

Removes a role assignment from a user in the peaq network's RBAC system.

| Parameter    | Type  | EVM      | Substrate | Description                                                            |
| ------------ | ----- | -------- | --------- | ---------------------------------------------------------------------- |
| **role\_id** | `str` | Required | Required  | Unique identifier of the role to unassign (32 characters).             |
| **user\_id** | `str` | Required | Required  | Unique identifier of the user to remove the role from (32 characters). |

### Unassign Role from User 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
  )

  role_id = "0bb60413-ebdd-44fb-ab2c-e7e0714f"
  user_id = "9e8c7866-8435-4b76-8683-709a03c9"

  response = sdk.rbac.unassign_role_to_user(
      role_id=role_id,
      user_id=user_id
  )
  ```

  ```python EVM Unsigned Tx Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC unassign role from user call for role 0bb60413-ebdd-44fb-ab2c-e7e0714f and user 9e8c7866-8435-4b76-8683-709a03c9. You must sign and send externally.",
    "tx": {
      "to": "0x0000000000000000000000000000000000000802",
      "data": "0x7663575030626236303431332d65626..."
    }
  }
  ```

  ```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
  )

  role_id = "afd2ae0e-b1db-42b9-bca1-93e9328b"
  user_id = "9e8c7866-8435-4b76-8683-709a03c9"

  response = sdk.rbac.unassign_role_to_user(
      role_id=role_id,
      user_id=user_id
  )
  ```

  ```python EVM Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully unassigned role afd2ae0e-b1db-42b9-bca1-93e9328b from user 9e8c7866-8435-4b76-8683-709a03c9.",
    "receipt": {
      "transactionHash": "0x8497af05650616bd105cf4eb88247b469f2c62c9f393dd7caaba93017c6136a1",
      "transactionIndex": 0,
      "blockHash": "0x0de592d66c9292cf8d4b5fcabcb618cacb33371f002acaeb4c0b1fb340f40eeb",
      "from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
      "to": "0x0000000000000000000000000000000000000802",
      "blockNumber": 5847073,
      "cumulativeGasUsed": 39869,
      "gasUsed": 39869,
      "contractAddress": null,
      "logs": [
        {
          "address": "0x0000000000000000000000000000000000000802",
          "topics": [
            "0x0ff1a305be9c0b5a533bc46d137628af9c53f1941825d0bfe94c23c1d046dc6b"
          ],
          "data": "0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c616664326165...",
          "blockHash": "0x0de592d66c9292cf8d4b5fcabcb618cacb33371f002acaeb4c0b1fb340f40eeb",
          "blockNumber": 5847073,
          "transactionHash": "0x8497af05650616bd105cf4eb88247b469f2c62c9f393dd7caaba93017c6136a1",
          "transactionIndex": 0,
          "logIndex": 0,
          "transactionLogIndex": "0x0",
          "removed": false
        }
      ],
      "logsBloom": "0x00000000000000000000000000000100000000000...",
      "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
  )

  role_id = "bc3a3e43-6f2e-4e55-83d3-72d5148a"
  user_id = "9e8c7866-8435-4b76-8683-709a03c9"

  response = sdk.rbac.unassign_role_to_user(
      role_id=role_id,
      user_id=user_id
  )
  ```

  ```python Substrate Unsigned Call Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Constructed RBAC unassign role from user call for role bc3a3e43-6f2e-4e55-83d3-72d5148a and user 9e8c7866-8435-4b76-8683-709a03c9. You must sign and send externally.",
    "call": {
      "call_module": "PeaqRbac",
      "call_function": "unassign_role_to_user",
      "call_args": {
        "role_id": "bc3a3e43-6f2e-4e55-83d3-72d5148a",
        "user_id": "9e8c7866-8435-4b76-8683-709a03c9"
      }
    }
  }
  ```

  ```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
  )

  role_id = "06856fab-c5ff-40cd-8e83-634264c6"
  user_id = "9e8c7866-8435-4b76-8683-709a03c9"

  response = sdk.rbac.unassign_role_to_user(
      role_id=role_id,
      user_id=user_id
  )
  ```

  ```python Substrate Write Response theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
  {
    "message": "Successfully unassigned role 06856fab-c5ff-40cd-8e83-634264c6 from user 9e8c7866-8435-4b76-8683-709a03c9.",
    "receipt": {
      "extrinsic_hash": "0xd1a7972b2425b07044e16265894246540b7ec90a5a5f398a71279dd5feae23a6",
      "block_hash": "0xae7f7e1dfe1288aa40f2cfa328d7e6e600bee95a51cb448aea9caeeeefd26396",
      "finalized": false,
      "events": [...],
      "is_success": true,
      "total_fee_amount": 2334112051296649
    }
  }

  ```
</CodeGroup>
