createGroup(groupName, groupId, seed)
Used to create a new group within the RBAC (Role-Based Access Control) system.
Parameter Type EVM Substrate Description groupName string
Required Required Name of the group to be created. groupId string
Optional Optional ID of the group. If not provided, a new ID will be generated. seed string
N/A Optional If not set at instance creation, allows user to define who sends the Substrate Transactions.
Create Group Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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.
Parameter Type EVM Substrate Description owner string
Required Required Address representing the owner of the group. groupId string
Required Required ID of the group to be fetched. wssBaseUrl string
Required N/A WSS URL used to query RBAC storage.
Fetch Group Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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.
Parameter Type EVM Substrate Description owner string
Required Required Address representing the owner of all the fetched groups. wssBaseUrl string
Required N/A WSS URL used to query RBAC storage.
Fetch Groups Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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.
Parameter Type EVM Substrate Description groupName string Required Required Updated group name. groupId string Required Required ID of the group (32 bytes) to be updated. seed string N/A Optional If not set at instance creation, allows user to define who sends the Substrate Transactions.
Update Group Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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.
Parameter Type EVM Substrate Description groupId string
Required Required The unique identifier (ID) of the group to be disabled. seed string
N/A Optional If not set at instance creation, allows user to define who sends the Substrate Transactions.
Disable Group Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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.
Parameter Type EVM Substrate Description groupId string
Required Required The unique identifier of the group to which the role will be assigned. roleId string
Required Required ID of the role that will be assigned to the group. seed string
N/A Optional If not set at instance creation, allows user to define who sends the Substrate Transactions.
Assign Role to Group Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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.
Parameter Type EVM Substrate Description owner string
Required Required Address of the owner of the roles. This is typically the account that manages the roles and permissions. groupId string
Required Required Unique identifier of the group for whom roles are to be fetched. wssBaseUrl string
Required N/A WSS URL used to query RBAC storage.
Fetch Group Roles Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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.
Parameter Type EVM Substrate Description groupId string
Required Required ID of the group from which the role should be unassigned. roleId string
Required Required ID of the role that needs to be unassigned. seed string
N/A Optional If not set at instance creation, allows user to define who sends the Substrate Transactions.
Unassign Role to Group Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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.
Parameter Type EVM Substrate Description userId string
Required Required The unique identifier of the user to whom the group will be assigned. ID created by user and must be 32 bytes. groupId string
Required Required ID of the group that will be assigned to the user. seed string
N/A Optional If not set at instance creation, allows user to define who sends the Substrate Transactions.
Assign User to Group Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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.
Parameter Type EVM Substrate Description owner string
Required Required Address of the owner of the roles. This is typically the account that manages the roles and permissions. userId string
Required Required Unique identifier of the user for whom groups are to be fetched. wssBaseUrl string
Required N/A WSS URL used to query RBAC storage.
Fetch User Groups Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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.
Parameter Type EVM Substrate Description userId string
Required Required ID of the user from which the group should be unassigned. groupId string
Required Required ID of the group that needs to be unassigned. seed string
N/A Optional If not set at instance creation, allows user to define who sends the Substrate Transactions.
Unassign User to Group Code Examples
EVM Request
EVM Response
Substrate Request
Substrate Response
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
});