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
EVM Unsigned Tx
EVM Unsigned Tx Response
EVM Write Tx
EVM Write Response
Substrate Unsigned Call
Substrate Unsigned Call Response
Substrate Write Call
Substrate Write Response
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)
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
EVM Fetch
EVM Response
Substrate Fetch
Substrate Response
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)
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
EVM Fetch
EVM Response
Substrate Fetch
Substrate Response
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 )
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
EVM Unsigned Tx
EVM Unsigned Tx Response
EVM Write Tx
EVM Write Response
Substrate Unsigned Call
Substrate Unsigned Call Response
Substrate Write Call
Substrate Write Response
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
)
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
EVM Unsigned Tx
EVM Unsigned Tx Response
EVM Write Tx
EVM Write Response
Substrate Unsigned Call
Substrate Unsigned Call Response
Substrate Write Call
Substrate Write Response
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)
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
EVM Unsigned Tx
EVM Unsigned Tx Response
EVM Write Tx
EVM Write Response
Substrate Unsigned Call
Substrate Unsigned Call Response
Substrate Write Call
Substrate Write Response
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)
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
EVM Read
EVM Response
Substrate Read
Substrate Response
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)
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
EVM Unsigned Tx
EVM Unsigned Tx Response
EVM Write Tx
EVM Write Response
Substrate Unsigned Call
Substrate Unsigned Call Response
Substrate Write Call
Substrate Write Response
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
)
Responses are generated using AI and may contain mistakes.