Skip to main content
The Python SDK creates and manages roles in peaq’s Role-Based Access Control (RBAC) system.

create_role(role_name, role_id)

Creates a role. The role is owned by the address derived from the seed. Without a seed, the SDK returns an unsigned transaction for you to sign and send.

Create Role Code Examples

fetch_role(owner, role_id)

Fetches a role by its ID and owner address.

Fetch Role Code Examples

fetch_roles(owner)

Fetches all roles owned by an address.

Fetch Roles Code Examples

update_role(role_id, role_name)

Renames an existing role.

Update Role Code Examples

disable_role(role_id)

Disables a role, making it inactive while keeping its data.

Disable Role Code Examples

assign_role_to_user(role_id, user_id)

Assigns a role to a user.

Assign Role to User Code Examples

fetch_user_roles(owner, user_id)

Fetches all roles assigned to a user.

Fetch User Roles Code Examples

unassign_role_to_user(role_id, user_id)

Removes a role assignment from a user.

Unassign Role from User Code Examples