useRevokeRole
Hook for revoking a wallet address from a role on a smart contract.
Available to use on contracts that implement Permission Controls.
The wallet address that initiates this transaction must have the relevant permissions on the contract to remove the role from the wallet address (typically admin
level required).
import { useRevokeRole } from "@thirdweb-dev/react";
const { mutateAsync, isLoading, error } = useRevokeRole(contract);
Usage
Provide your contract instance from the useContract
hook as the argument.
import { useContract, useRevokeRole, Web3Button } from "@thirdweb-dev/react";
// Your smart contract address (must implement permission controls)
const contractAddress = "{{contract_address}}";
const walletAddress = "{{wallet_address}}";
function App() {
// Contract must be a contract that implements the Permission Controls interface
const { contract } = useContract(contractAddress);
const { mutateAsync: revokeRole, isLoading, error } = useRevokeRole(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
revokeRole({
role: "admin",
address: walletAddress,
})
}
>
Revoke Role
</Web3Button>
);
}