createRole(roleName, roleId, seed)
Create a new role in the peaq network’s Role-Based Access Control (RBAC) system.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| roleName | string | Required | Required | Name of the role to be created. |
| roleId | string | Optional | Optional | ID of the role (32 bytes). If not supplied one will be generated for you. |
| seed | string | N/A | Optional | If not set at instance creation, allows user to define who sends the Substrate Transactions. |
Create Role Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const EVM_PRIVATE = process.env["EVM_PRIVATE"];
const sdk = await Sdk.createInstance({
baseUrl: HTTPS_BASE_URL,
chainType: Sdk.ChainType.EVM
});
const roleName = "peaq-role-1";
const role = await sdk.rbac.createRole({
roleName: roleName
});
// Send using Sdk function
const receipt = await Sdk.sendEvmTx({
tx: role.tx,
baseUrl: HTTPS_BASE_URL,
seed: EVM_PRIVATE
});
// Log to see what the auto generated roleId is
console.log(role.roleId);
// sdk.rbac.createRole({}) return object
{
tx: {
to: '0x0000000000000000000000000000000000000802',
data: '0xbca838d662363861353538392d313238342d343965392d383237362d30333539613432390000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000b706561712d726f6c652d31000000000000000000000000000000000000000000'
},
roleId: 'b68a5589-1284-49e9-8276-0359a429'
}
// sendEvmTx({}) return object
TransactionReceipt {
provider: JsonRpcProvider {},
to: '0x0000000000000000000000000000000000000802',
from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
contractAddress: null,
hash: '0x9b3d1ae6b9045e36b0985de3f4704aa84e5fd0d02b6f84fc1091e124a7dad8ee',
index: 0,
blockHash: '0x62b334b67c157a754b76276244911a086fc13f0f951ee7a3d1d0277f74d393de',
blockNumber: 4489206,
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000002000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
gasUsed: 34414n,
blobGasUsed: null,
cumulativeGasUsed: 34414n,
gasPrice: 100000000000n,
blobGasPrice: null,
type: 2,
status: 1,
root: undefined
}
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE,
seed: SUBSTRATE_SEED
});
const roleName = "peaq-role-1";
const response = await sdk.rbac.createRole({
roleName: roleName
});
// disconnect when finished
await sdk.disconnect();
// sdk.rbac.createRole({}) return object
{ roleId: 'bc3f20d5-c519-4048-8db1-4bbf48dc' }
The EVM tx it returns in a different form than what was used throughout the sdk. The purpose of this is to show the role-id that was autogenerated if it was not manually set.
fetchRole(owner, roleId, wssBaseUrl)
Fetch a role at the given roleId and address associated.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| owner | string | Required | Required | Address representing the owner of the role. |
| roleId | string | Required | Required | ID of the role to be fetched. |
| wssBaseUrl | string | Required | N/A | WSS URL used to query RBAC storage. Substrate WSS is stored at instance creation. |
Fetch Role Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
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 role id
const roleId = "b68a5589-1284-49e9-8276-0359a429";
const response = await sdk.rbac.fetchRole({
owner: EVM_ADDRESS,
roleId: roleId,
wssBaseUrl: WSS_BASE_URL
});
// sdk.rbac.fetchRole({}) response object
{
id: 'b68a5589-1284-49e9-8276-0359a429',
name: 'peaq-role-1',
enabled: true
}
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE
});
// example of a previously created role id
const roleId = "bc3f20d5-c519-4048-8db1-4bbf48dc";
const response = await sdk.rbac.fetchRole({
owner: SUBSTRATE_ADDRESS,
roleId: roleId
});
// disconnect when finished
await sdk.disconnect();
// sdk.rbac.fetchRole({}) response object
{
id: 'bc3f20d5-c519-4048-8db1-4bbf48dc',
name: 'peaq-role-1',
enabled: true
}
fetchRoles(owner, wssBaseUrl)
Used to fetch all the roles associated with the passed owner address.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| owner | string | Required | Required | Address that represents the owner of all the fetched roles. |
| wssBaseUrl | string | Required | N/A | WSS URL used to query RBAC storage. Substrate WSS is stored at instance creation. |
Fetch Roles Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
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.fetchRoles({
owner: EVM_ADDRESS,
wssBaseUrl: WSS_BASE_URL
});
// sdk.rbac.fetchRoles({}) response object
[
{
id: 'e09fe342-f8ee-46d1-82e2-a60a5b6e',
name: 'role-name-123',
enabled: true
},
...
{
id: 'b68a5589-1284-49e9-8276-0359a429',
name: 'peaq-role-1',
enabled: true
}
]
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE
});
const response = await sdk.rbac.fetchRoles({
owner: SUBSTRATE_ADDRESS
});
// disconnect when finished
await sdk.disconnect();
// sdk.rbac.fetchRoles({}) response object
[
{
id: 'bb3d5a05-3a4a-452b-a96d-372832ff',
name: 'role-name-123',
enabled: true
},
...
{
id: 'bc3f20d5-c519-4048-8db1-4bbf48dc',
name: 'peaq-role-1',
enabled: true
}
]
updateRole(roleName, roleId, seed)
Allows the owner to update the role name.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| roleName | string | Required | Required | Updated role name. |
| roleId | string | Required | Required | ID of the role (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 Role Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
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 role name that will be set
const roleName = "peaq-role-new";
// example of a previously created role id
const roleId = "b68a5589-1284-49e9-8276-0359a429";
// build the evm tx
const tx = await sdk.rbac.updateRole({
roleName: roleName,
roleId: roleId
});
// send using Sdk function
const receipt = await Sdk.sendEvmTx({
tx: tx,
baseUrl: HTTPS_BASE_URL,
seed: EVM_PRIVATE
});
// fetch Role to confirm the name change
const response = await sdk.rbac.fetchRole({
owner: EVM_ADDRESS,
roleId: roleId,
wssBaseUrl: WSS_BASE_URL
});
// sdk.rbac.updateRole({}) return object
{
to: '0x0000000000000000000000000000000000000802',
data: '0x7cc0a21862363861353538392d313238342d343965392d383237362d30333539613432390000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000d706561712d726f6c652d6e657700000000000000000000000000000000000000'
}
// sendEvmTx({}) return object
TransactionReceipt {
provider: JsonRpcProvider {},
to: '0x0000000000000000000000000000000000000802',
from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
contractAddress: null,
hash: '0x9fea31cc7edc8571f5236249b62e4fa45b5515a6c316fb62998bda01129f1236',
index: 1,
blockHash: '0x3e0a30ab7a32d3d9bb46bde23571ab0e5e5db1c428b4ab1585e0e76883b1a3be',
blockNumber: 4489512,
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
gasUsed: 35281n,
blobGasUsed: null,
cumulativeGasUsed: 89785n,
gasPrice: 100000000000n,
blobGasPrice: null,
type: 2,
status: 1,
root: undefined
}
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE,
seed: SUBSTRATE_SEED
});
// new role name that will be set
const roleName = "peaq-role-new";
// example of a previously created role id
const roleId = "bc3f20d5-c519-4048-8db1-4bbf48dc";
const response = await sdk.rbac.updateRole({
roleName: roleName,
roleId: roleId
});
// fetch Role to confirm the name change
const fetchedRole = await sdk.rbac.fetchRole({
owner: SUBSTRATE_ADDRESS,
roleId: roleId
});
// disconnect when finished
await sdk.disconnect();
// sdk.rbac.updateRole({}) return object
{
message: 'Successfully update role bc3f20d5-c519-4048-8db1-4bbf48dc with new name: peaq-role-new'
}
disableRole(roleId, seed)
Disables a role within a permission management system.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| roleId | string | Required | Required | The unique identifier (ID) of the role to be disabled. |
| seed | string | N/A | Optional | If not set at instance creation, allows user to define who sends the Substrate Transactions. |
Disable Role Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
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
});
// role id to disable
const roleId = "b68a5589-1284-49e9-8276-0359a429";
// build the evm tx
const tx = await sdk.rbac.disableRole({
roleId: roleId
});
// send using Sdk function
const receipt = await Sdk.sendEvmTx({
tx: tx,
baseUrl: HTTPS_BASE_URL,
seed: EVM_PRIVATE
});
// Fetch Role to confirm it has been changed to disabled
const response = await sdk.rbac.fetchRole({
owner: EVM_ADDRESS,
roleId: roleId,
wssBaseUrl: WSS_BASE_URL
});
// sdk.rbac.disableRole({}) return object
{
to: '0x0000000000000000000000000000000000000802',
data: '0x7c4a13b162363861353538392d313238342d343965392d383237362d3033353961343239'
}
// sendEvmTx({}) return object
TransactionReceipt {
provider: JsonRpcProvider {},
to: '0x0000000000000000000000000000000000000802',
from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
contractAddress: null,
hash: '0x9cd4cfecbdeac0fc5c501f26a1b1c52314bdf24731c26bf05797b2b6ca00588f',
index: 0,
blockHash: '0x90f3daabfb05d1e3ed83850398e8593ff8a08d59df3cf20db2b4538169491459',
blockNumber: 4489862,
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000020000000000000000000000020000020000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
gasUsed: 34782n,
blobGasUsed: null,
cumulativeGasUsed: 34782n,
gasPrice: 100000000000n,
blobGasPrice: null,
type: 2,
status: 1,
root: undefined
}
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE,
seed: SUBSTRATE_SEED
});
// role id to disable
const roleId = "bc3f20d5-c519-4048-8db1-4bbf48dc";
// execute the extrinsic
const response = await sdk.rbac.disableRole({
roleId: roleId
});
// Fetch Role to confirm it has been changed to disabled
const fetchedRole = await sdk.rbac.fetchRole({
owner: SUBSTRATE_ADDRESS,
roleId: roleId,
});
// disconnect when finished
await sdk.disconnect();
// sdk.rbac.disableRole({}) return object
{
message: 'Successfully disable role bc3f20d5-c519-4048-8db1-4bbf48dc'
}
assignRoleToUser(userId, roleId, seed)
This function allows you to assign a specific role to a user in a permission management system.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| userId | string | Required | Required | The unique identifier of the user to whom the role will be assigned. ID created by user and must be 32 bytes. |
| roleId | string | Required | Required | ID of the role 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 Role to User Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const EVM_PRIVATE = process.env["EVM_PRIVATE"];
const sdk = await Sdk.createInstance({
baseUrl: HTTPS_BASE_URL,
chainType: Sdk.ChainType.EVM
});
// self-generated userId
const userId = "9e8c7866-8435-4b76-8683-709a03c9";
// role id to assign to user
const roleId = "b68a5589-1284-49e9-8276-0359a429";
// build the evm tx
const tx = await sdk.rbac.assignRoleToUser({
userId: userId,
roleId: roleId
});
// send using Sdk function
const receipt = await Sdk.sendEvmTx({
tx: tx,
baseUrl: HTTPS_BASE_URL,
seed: EVM_PRIVATE
});
// sdk.rbac.assignRoleToUser({}) return object
{
to: '0x0000000000000000000000000000000000000802',
data: '0xae8cdd7962363861353538392d313238342d343965392d383237362d303335396134323939653863373836362d383433352d346237362d383638332d3730396130336339'
}
// sendEvmTx({}) return object
TransactionReceipt {
provider: JsonRpcProvider {},
to: '0x0000000000000000000000000000000000000802',
from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
contractAddress: null,
hash: '0x71b13a8507b540937cbba58843497516edc505ce1af09a3e573cd5789c48cccf',
index: 0,
blockHash: '0xc44b43afbc16ecba36b2051a88a62f9b942293394ace5c193cbea73f8e9f2460',
blockNumber: 4489679,
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000020000000000000000000000000000000000000000000000000000000001000000000000000000000000000004000000000000000000008000000000000000000000000000000000000000000000000000000',
gasUsed: 31390n,
blobGasUsed: null,
cumulativeGasUsed: 31390n,
gasPrice: 100000000000n,
blobGasPrice: null,
type: 2,
status: 1,
root: undefined
}
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE,
seed: SUBSTRATE_SEED
});
// self-generated userId
const userId = "9e8c7866-8435-4b76-8683-709a03c9";
// role id to assign to user
const roleId = "bc3f20d5-c519-4048-8db1-4bbf48dc";
// build the evm tx
const response = await sdk.rbac.assignRoleToUser({
userId: userId,
roleId: roleId
});
// disconnect when finished
await sdk.disconnect();
// sdk.rbac.assignRoleToUser({}) return object
{
message: 'Successfully assign role bc3f20d5-c519-4048-8db1-4bbf48dc to user 9e8c7866-8435-4b76-8683-709a03c9'
}
fetchUserRoles(owner, userId, wssBaseUrl)
Designed to retrieve roles 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 roles are to be fetched. |
| wssBaseUrl | string | Required | N/A | WSS URL used to query RBAC storage. Substrate WSS is stored at instance creation. |
Fetch User Roles Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
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.fetchUserRoles({
owner: EVM_ADDRESS,
userId: userId,
wssBaseUrl: WSS_BASE_URL
});
// sdk.rbac.fetchUserRoles({}) return object
[
{
role: 'b68a5589-1284-49e9-8276-0359a429',
user: '9e8c7866-8435-4b76-8683-709a03c9'
}
]
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE
});
const userId = "9e8c7866-8435-4b76-8683-709a03c9";
const response = await sdk.rbac.fetchUserRoles({
owner: SUBSTRATE_ADDRESS,
userId: userId,
});
// disconnect when finished
await sdk.disconnect();
// sdk.rbac.fetchUserRoles({}) return object
[
{
role: 'bc3f20d5-c519-4048-8db1-4bbf48dc',
user: '9e8c7866-8435-4b76-8683-709a03c9'
}
]
unassignRoleToUser(userId, roleId, seed)
This function allows you to unassign a specific role from a user in a permission management system.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| userId | string | Required | Required | ID of the user 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 User Code Examples
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode.peaq.xyz";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
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
});
// self-generated userId
const userId = "9e8c7866-8435-4b76-8683-709a03c9";
// role id to unassign to user
const roleId = "b68a5589-1284-49e9-8276-0359a429";
// build the evm tx
const tx = await sdk.rbac.unassignRoleToUser({
userId: userId,
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 (should throw an error)
const response = await sdk.rbac.fetchUserRoles({
owner: EVM_ADDRESS,
userId: userId,
wssBaseUrl: WSS_BASE_URL
});
// sdk.rbac.unassignRoleToUser({}) return object
{
to: '0x0000000000000000000000000000000000000802',
data: '0x7663575062363861353538392d313238342d343965392d383237362d303335396134323939653863373836362d383433352d346237362d383638332d3730396130336339'
}
// sendEvmTx({}) return object
TransactionReceipt {
provider: JsonRpcProvider {},
to: '0x0000000000000000000000000000000000000802',
from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
contractAddress: null,
hash: '0xe128c68cd4ea9480c33d6fde4a5929d6d27b0ec8c20ddf1060505da2a9f31ab0',
index: 1,
blockHash: '0xcf871f18022d80ba2c3e627cb44f4d4ccae9ce3191ccd70518574a7019a3cf44',
blockNumber: 4489791,
logsBloom: '0x00000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000002000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
gasUsed: 29181n,
blobGasUsed: null,
cumulativeGasUsed: 159305n,
gasPrice: 100000000000n,
blobGasPrice: null,
type: 2,
status: 1,
root: undefined
}
import { Sdk } from "@peaq-network/sdk";
const WSS_BASE_URL = "wss://quicknode.peaq.xyz";
const SUBSTRATE_ADDRESS = process.env["SUBSTRATE_ADDRESS"];
const SUBSTRATE_SEED = process.env["SUBSTRATE_SEED"];
const sdk = await Sdk.createInstance({
baseUrl: WSS_BASE_URL,
chainType: Sdk.ChainType.SUBSTRATE,
seed: SUBSTRATE_SEED
});
// self-generated userId
const userId = "9e8c7866-8435-4b76-8683-709a03c9";
// role id to unassign to user
const roleId = "bc3f20d5-c519-4048-8db1-4bbf48dc";
// send extrinsic
const response = await sdk.rbac.unassignRoleToUser({
userId: userId,
roleId: roleId
});
// fetch to see it has been unassigned (should throw an error)
const fetchedRoles = await sdk.rbac.fetchUserRoles({
owner: SUBSTRATE_ADDRESS,
userId: userId
});
// disconnect when finished
await sdk.disconnect();
// sdk.rbac.unassignRoleToUser({}) return object
{
message: 'Successfully unassign user: 9e8c7866-8435-4b76-8683-709a03c9 from role: bc3f20d5-c519-4048-8db1-4bbf48dc'
}

