useIsAddressRole

Hook to check if an address is a member of a role on a smart contract.

Available to use on contracts that implement Permissions interface

Provide the following arguments to the hook:

  • contract - The contract instance to check the role on.

  • roleName - The name of the role to check.

  • address - The wallet address to see if it is a member of the role.

Example

import { useIsAddressRole, useContract } from "@thirdweb-dev/react";
function App() {
const { contract } = useContract(contractAddress);
const isMember = useIsAddressRole(
contract,
roleName,
walletAddress,
);
}
function useIsAddressRole(
contract: RequiredParam<TContract>,
role: RolesForContract<TContract>,
walletAddress: RequiredParam<string>,
): boolean;

Parameters

Instance of a SmartContract

Type

let contract: RequiredParam<TContract>;

The name of the role to check. 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>;

The wallet address to check if it is a member of the role. Use the useAddress hook to get the current wallet address.

Type

let walletAddress: RequiredParam<string>;

Returns

let returnType: boolean;

true if the address is a member of the role, or false if not