useGrantRole() function
This feature is currently in beta and may change based on feedback that we receive.
Use this to grant a WalletAddress a specific role on a
Example
const Component = () => {
const { mutate: grantRole, isLoading, error } = useGrantRole(SmartContract);
if (error) {
console.error("failed to grant role", error);
}
return (
<button
disabled={isLoading}
onClick={() => grantRole({ role: "admin", address: "0x123" })}
>
Grant Role
</button>
);
};
Signature:
export declare function useGrantRole<TContract extends ContractWithRoles>(
contract: RequiredParam<TContract>,
): import("@tanstack/react-query").UseMutationResult<
void,
unknown,
{
role: RolesForContract<TContract>;
address: WalletAddress;
},
unknown
>;
Parameters
Parameter | Type | Description |
---|---|---|
contract | RequiredParam<TContract> | an instance of a |
Returns:
import("@tanstack/react-query").UseMutationResult<void, unknown, { role: RolesForContract<TContract>; address: WalletAddress; }, unknown>
a mutation object that can be used to grant a member of a role on the contract