DOCS

useGrantRole

Grant a role to a specific address

Example

const Component = () => {
  const { contract } = useContract("{{contract_address}}");
  const {
    mutate: grantRole,
    isLoading,
    error,
  } = useGrantRole(contract);

  if (error) {
    console.error("failed to grant role", error);
  }

  return (
    <button
      disabled={isLoading}
      onClick={() => grantRole({ role: "admin", address: {{wallet_address}} })}
    >
      Grant Role
    </button>
  );
};

Parameters

Returns

a mutation object that can be used to grant a member of a role on the contract