Skip to main content

useAllRoleMembers

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

Available to use on contracts that implement Permission Controls.

import { useAllRoleMembers } from "@thirdweb-dev/react";

Usage

Provide your contract instance as the argument.

import { useAllRoleMembers, useContract } from "@thirdweb-dev/react";

// Your smart contract address (must implement permission controls)
const contractAddress = "{{contract_address}}";

function App() {
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useAllRoleMembers(contract);
}

Return Value

The hook's data property, once loaded, is an object, where the keys are the role names and the values are arrays of wallet addresses that have that role.

Record<"admin" | "transfer" | "minter" | "pauser" | "lister" | "asset" | "unwrap" | "factory" | (string & {}), string[]> | undefined

For example, if the contract has two roles, admin and transfer, and the admin role has two members, the data property will look like this:

{
admin: ["0x1234", "0x5678"],
transfer: [],
}