createGroup(groupName, groupId, seed)

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

ParameterTypeEVMSubstrateDescription
groupNamestringRequiredRequiredName of the group to be created.
groupIdstringOptionalOptionalID of the group. If not provided, a new ID will be generated.
seedstringN/AOptionalIf not set at instance creation, allows user to define who sends the Substrate Transactions.

Create Group Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const EVM_PRIVATE = process.env["EVM_PRIVATE"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

const groupName = "peaq-group-1";
const group = await sdk.rbac.createGroup({
    groupName: groupName
});

// Send using Sdk function
const receipt = await Sdk.sendEvmTx({
  tx: group.tx,
  baseUrl: HTTPS_BASE_URL,
  seed: EVM_PRIVATE
});

// Log to see what the auto generated groupId is
console.log(group.groupId);
For the EVM tx it returns in a different form than what was used throughout the sdk. The purpose of this is to show the group-id that was autogenerated if it was not manually set. That way you are able to take note of the group-id for that group-name set.

fetchGroup(owner, groupId, wssBaseUrl)

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

ParameterTypeEVMSubstrateDescription
ownerstringRequiredRequiredAddress representing the owner of the group.
groupIdstringRequiredRequiredID of the group to be fetched.
wssBaseUrlstringRequiredN/AWSS URL used to query RBAC storage.

Fetch Group Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const WSS_BASE_URL = "wss://peaq.api.onfinality.io/public";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

// example of a previously created group id
const groupId = "58a52684-3ace-4e72-a025-85085b1d";

const response = await sdk.rbac.fetchGroup({
    owner: EVM_ADDRESS,
    groupId: groupId,
    wssBaseUrl: WSS_BASE_URL
});

fetchGroups(owner, wssBaseUrl)

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

ParameterTypeEVMSubstrateDescription
ownerstringRequiredRequiredAddress representing the owner of all the fetched groups.
wssBaseUrlstringRequiredN/AWSS URL used to query RBAC storage.

Fetch Groups Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const WSS_BASE_URL = "wss://peaq.api.onfinality.io/public";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

const response = await sdk.rbac.fetchGroups({
    owner: EVM_ADDRESS,
    wssBaseUrl: WSS_BASE_URL
});

updateGroup(groupName, groupId, seed)

Allows the owner to update the group name.

ParameterTypeEVMSubstrateDescription
groupNamestringRequiredRequiredUpdated group name.
groupIdstringRequiredRequiredID of the group (32 bytes) to be updated.
seedstringN/AOptionalIf not set at instance creation, allows user to define who sends the Substrate Transactions.

Update Group Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const WSS_BASE_URL = "wss://peaq.api.onfinality.io/public";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];
const EVM_PRIVATE = process.env["EVM_PRIVATE"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

// new group name that will be set
const groupName = "peaq-group-new";

// example of a previously created group id
const groupId = "58a52684-3ace-4e72-a025-85085b1d";

// build the evm tx
const tx = await sdk.rbac.updateGroup({
    groupName: groupName,
    groupId: groupId
});

// send using Sdk function
const receipt = await Sdk.sendEvmTx({
  tx: tx,
  baseUrl: HTTPS_BASE_URL,
  seed: EVM_PRIVATE
});

// fetch Group to confirm the name change
const response = await sdk.rbac.fetchGroup({
    owner: EVM_ADDRESS,
    groupId: groupId,
    wssBaseUrl: WSS_BASE_URL
});

disableGroup(groupId, seed)

Disables a group within a permission management system.

ParameterTypeEVMSubstrateDescription
groupIdstringRequiredRequiredThe unique identifier (ID) of the group to be disabled.
seedstringN/AOptionalIf not set at instance creation, allows user to define who sends the Substrate Transactions.

Disable Group Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const WSS_BASE_URL = "wss://peaq.api.onfinality.io/public";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];
const EVM_PRIVATE = process.env["EVM_PRIVATE"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

// group id to disable
const groupId = "58a52684-3ace-4e72-a025-85085b1d";

// build the evm tx
const tx = await sdk.rbac.disableGroup({
    groupId: groupId
});

// send using Sdk function
const receipt = await Sdk.sendEvmTx({
  tx: tx,
  baseUrl: HTTPS_BASE_URL,
  seed: EVM_PRIVATE
});

// fetch group to confirm it has been changed to disabled
const response = await sdk.rbac.fetchGroup({
    owner: EVM_ADDRESS,
    groupId: groupId,
    wssBaseUrl: WSS_BASE_URL
});

assignRoleToGroup(groupId, roleId, seed)

This function allows to assign a specific role to a group within a permission management system.

ParameterTypeEVMSubstrateDescription
groupIdstringRequiredRequiredThe unique identifier of the group to which the role will be assigned.
roleIdstringRequiredRequiredID of the role that will be assigned to the group.
seedstringN/AOptionalIf not set at instance creation, allows user to define who sends the Substrate Transactions.

Assign Role to Group Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const EVM_PRIVATE = process.env["EVM_PRIVATE"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

// group id (generated with createGroup)
const groupId = "58a52684-3ace-4e72-a025-85085b1d";

// role id to assign to group
const roleId = "ada650fa-ec62-4d09-849b-b66c7777";

// build the evm tx
const tx = await sdk.rbac.assignRoleToGroup({
    groupId: groupId,
    roleId: roleId
});

// send using Sdk function
const receipt = await Sdk.sendEvmTx({
  tx: tx,
  baseUrl: HTTPS_BASE_URL,
  seed: EVM_PRIVATE
});

fetchGroupRoles(owner, groupId, wssBaseUrl)

Designed to retrieve roles associated with a specific group from the network’s RBAC (Role-Based Access Control) system.

ParameterTypeEVMSubstrateDescription
ownerstringRequiredRequiredAddress of the owner of the roles. This is typically the account that manages the roles and permissions.
groupIdstringRequiredRequiredUnique identifier of the group for whom roles are to be fetched.
wssBaseUrlstringRequiredN/AWSS URL used to query RBAC storage.

Fetch Group Roles Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const WSS_BASE_URL = "wss://peaq.api.onfinality.io/public";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

const groupId = "58a52684-3ace-4e72-a025-85085b1d";

const response = await sdk.rbac.fetchGroupRoles({
    owner: EVM_ADDRESS,
    groupId: groupId,
    wssBaseUrl: WSS_BASE_URL
});

unassignRoleToGroup(groupId, roleId, seed)

This function allows to unassign a specific role to a group in a permission management system.

ParameterTypeEVMSubstrateDescription
groupIdstringRequiredRequiredID of the group from which the role should be unassigned.
roleIdstringRequiredRequiredID of the role that needs to be unassigned.
seedstringN/AOptionalIf not set at instance creation, allows user to define who sends the Substrate Transactions.

Unassign Role to Group Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const WSS_BASE_URL = "wss://peaq.api.onfinality.io/public";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];
const EVM_PRIVATE = process.env["EVM_PRIVATE"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

// previously created groupId
const groupId = "58a52684-3ace-4e72-a025-85085b1d";

// role id to unassign to group
const roleId = "b68a5589-1284-49e9-8276-0359a429";

// build the evm tx
const tx = await sdk.rbac.unassignRoleToGroup({
    groupId: groupId,
    roleId: roleId
});

// send using Sdk function
const receipt = await Sdk.sendEvmTx({
  tx: tx,
  baseUrl: HTTPS_BASE_URL,
  seed: EVM_PRIVATE
});

// fetch to see it has been unassigned
const response = await sdk.rbac.fetchGroupRoles({
    owner: EVM_ADDRESS,
    groupId: groupId,
    wssBaseUrl: WSS_BASE_URL
});

assignUserToGroup(userId, groupId, address, seed)

This function allows to assign a user to a group within the RBAC (Role-Based Access Control) system.

ParameterTypeEVMSubstrateDescription
userIdstringRequiredRequiredThe unique identifier of the user to whom the group will be assigned. ID created by user and must be 32 bytes.
groupIdstringRequiredRequiredID of the group that will be assigned to the user.
seedstringN/AOptionalIf not set at instance creation, allows user to define who sends the Substrate Transactions.

Assign User to Group Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const EVM_PRIVATE = process.env["EVM_PRIVATE"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

// user id to assign to group
const userId = "9e8c7866-8435-4b76-8683-709a03c9";

// group id (generated with createGroup)
const groupId = "58a52684-3ace-4e72-a025-85085b1d";

// build the evm tx
const tx = await sdk.rbac.assignUserToGroup({
    userId: userId,
    groupId: groupId,
});

// send using Sdk function
const receipt = await Sdk.sendEvmTx({
  tx: tx,
  baseUrl: HTTPS_BASE_URL,
  seed: EVM_PRIVATE
});

fetchUserGroups(owner, userId, wssBaseUrl)

Designed to retrieve groups associated with a specific user from the network’s RBAC (Role-Based Access Control) system.

ParameterTypeEVMSubstrateDescription
ownerstringRequiredRequiredAddress of the owner of the roles. This is typically the account that manages the roles and permissions.
userIdstringRequiredRequiredUnique identifier of the user for whom groups are to be fetched.
wssBaseUrlstringRequiredN/AWSS URL used to query RBAC storage.

Fetch User Groups Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const WSS_BASE_URL = "wss://peaq.api.onfinality.io/public";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

const userId = "9e8c7866-8435-4b76-8683-709a03c9";

const response = await sdk.rbac.fetchUserGroups({
    owner: EVM_ADDRESS,
    userId: userId,
    wssBaseUrl: WSS_BASE_URL
});

unassignUserToGroup(userId, groupId, address, seed)

This function allows to unassign a specific user from a group in a permission management system.

ParameterTypeEVMSubstrateDescription
userIdstringRequiredRequiredID of the user from which the group should be unassigned.
groupIdstringRequiredRequiredID of the group that needs to be unassigned.
seedstringN/AOptionalIf not set at instance creation, allows user to define who sends the Substrate Transactions.

Unassign User to Group Code Examples

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

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";
const WSS_BASE_URL = "wss://peaq.api.onfinality.io/public";
const EVM_ADDRESS = process.env["EVM_ADDRESS"];
const EVM_PRIVATE = process.env["EVM_PRIVATE"];

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

// user id to unassign from group
const userId = "9e8c7866-8435-4b76-8683-709a03c9";

// previously created groupId
const groupId = "58a52684-3ace-4e72-a025-85085b1d";

// build the evm tx
const tx = await sdk.rbac.unassignUserToGroup({
    userId: userId,
    groupId: groupId,
});

// send using Sdk function
const receipt = await Sdk.sendEvmTx({
  tx: tx,
  baseUrl: HTTPS_BASE_URL,
  seed: EVM_PRIVATE
});

// fetch to see it has been unassigned
const response = await sdk.rbac.fetchUserGroups({
    owner: EVM_ADDRESS,
    userId: userId,
    wssBaseUrl: WSS_BASE_URL
});