Docs

useRevokeRole

Hook for revoking a wallet address from a role on a smart contract.

Available to use on contracts that implement Permissions interface

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 {
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>
);
}

Parameters

Returns

A mutation object to revoke a role from a member on the contract

role (required)

The role to revoke from the wallet address.

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

  • "admin"

  • "transfer"

  • "minter"

  • "pauser"

  • "lister"

  • "asset"

  • "unwrap"

  • "factory"

address

The wallet address to revoke the role from.

To use the connected wallet address, use the useAddress hook.