useIsAddressRole
Hook to check if an address is a member of a role on a smart contract.
Available to use on contracts that implement Permission Controls.
import { useIsAddressRole } from "@thirdweb-dev/react";
const isMember = useIsAddressRole(
contract,
"{{role_name}}",
"{{wallet_address}}",
);
Usage
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.
import { useIsAddressRole, useContract } from "@thirdweb-dev/react";
// Your smart contract address (must implement permission controls)
const contractAddress = "{{contract_address}}";
// Address of the wallet to check
const walletAddress = "{{wallet_address}}";
// Name of the role to check
const roleName = "admin";
function App() {
const { contract } = useContract(contractAddress);
const isMember = useIsAddressRole(contract, roleName, walletAddress);
}