useRoleMembers

Hook for getting all wallet addresses that have a specific role in a smart contract.

Available to use on contracts that implement the Permissions interface.

Example

import { useContract, useRoleMembers } from "@thirdweb-dev/react";
// Your smart contract address (must implement permission controls)
const contractAddress = "{{contract_address}}";
const roleName = "admin";
function App() {
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useRoleMembers(
contract,
roleName,
);
}
function useRoleMembers(
contract: RequiredParam<TContract>,
role: RolesForContract<TContract>,
): UseQueryResult<Array<string>, unknown>;

Parameters

Instance of a SmartContract

Type

let contract: RequiredParam<TContract>;

The name of the role to get the members of

Can be any custom role, or a built-in role, such as:

  • "admin"

  • "transfer"

  • "minter"

  • "pauser"

  • "lister"

  • "asset"

  • "unwrap"

  • "factory"

Type

let role: RolesForContract<TContract>;

Returns

let returnType: UseQueryResult<Array<string>, unknown>;

The hook's data property, once loaded, is an array of wallet addresses that have the specified role