Skip to main content

unassignRoleToGroup

The unassignRoleToGroup function allows to unassign a role from a specific group within the peaq network's RBAC system. This function returns a JSON object with role and group IDs.

Parameters:

  • groupId (type: string, required): ID of the group from which the role should be unassigned.

  • roleId (type: string, required): ID of the role that needs to be unassigned.

  • address (type: address, optional): address of the entity initiating the request. This parameter is optional and can be used for transaction signing.

  • seed (type: string, optional): seed used for transaction signing. This parameter is optional and provides an alternative way for transaction signing.

Code example


import { Sdk } from "@peaq-network/sdk";

/**
* Unassigns a role from a group in the peaq network's RBAC system.
* @param {string} groupId - The ID of the group from which the role should be unassigned.
* @param {string} roleId - The ID of the role to be unassigned.
* @param {string} [address] - The address of the entity initiating the request (optional).
* @param {string} [seed] - The seed for transaction signing (optional).
* @returns {Promise<object>} - A promise that resolves when the role is successfully unassigned.
*/
async function unassignRoleToGroup(groupId, roleId, seed) {
const sdkInstance = await Sdk.createInstance({
baseUrl: "wss://wsspc1-qa.agung.peaq.network",
seed
});

try {
const result = await sdkInstance.rbac.unassignRoleToGroup({
roleId,
groupId
});
return result
} finally {
await sdkInstance.disconnect();
}
}

// Example usage
const groupId = "02709409-kd01-4444-8222-b5zz8512";
const roleId = "78709009-cf06-4224-8632-b5ee8512";
const seed = "your-seed-phrase";

unassignRoleToGroup(groupId, roleId, seed)
.then((result) => {
console.log(result.message);
})
.catch((error) => {
console.error("Error unassigning role from group:", error);
});


Response object


{
message: "Successfully unassign role: 78709009-cf06-4224-8632-b5ee8512 from group: 02709409-kd01-4444-8222-b5zz8512"
}