Skip to content

RoleByRoles

RoleByRoles is an electoral mandate that assigns or revokes a role based on whether an account holds any of a set of prerequisite roles. It is useful for composing “grouped” roles — for example, granting a general contributor role to anyone who holds any of several specific contributor roles.

This mandate checks a single account against a list of prerequisite roles and synchronizes a target role accordingly:

  • If the account holds any of the prerequisite roles and does not yet have the target role → assigns the target role.
  • If the account holds none of the prerequisite roles but does have the target role → revokes the target role.
  • If no change is needed (already in sync) → returns empty execution data without reverting.

When adopting a RoleByRoles instance, two parameters must be provided:

  1. newRoleId (uint256): The role ID to assign or revoke based on prerequisites.
  2. roleIdsNeeded (uint256[]): Array of prerequisite role IDs. Holding any one of these is sufficient to qualify for the target role.

When calling the mandate, one parameter must be provided:

  1. account (address): The account to check and potentially assign/revoke the role for.
  1. Prerequisite Check

    • Checks if the account holds any of the roles in roleIdsNeeded.
    • Checks if the account already holds newRoleId.
  2. Role Assignment Logic

    • If account has a prerequisite role and does not have the target role → assigns the target role.
    • If account has no prerequisite roles but has the target role → revokes the target role.
    • If no change is needed → returns empty execution data (no revert).
function initializeMandate(...) public override
  • Stores configuration (target role ID and prerequisite role IDs).
  • Sets input parameters to (address Account).
function handleRequest(...) public view virtual override returns (...)
  • Decodes the target account from calldata.
  • Checks prerequisite role ownership against the Powers contract.
  • Returns an assignRole or revokeRole call, or empty arrays if no change is needed.

This mandate has no explicit reverts for no-op cases. If the account’s role status is already in sync, it returns empty execution data and the action completes without any state change.

Chain IDChain NameAddress
421614Arbitrum Sepolia0xa797799EE0C6FA7d9b76eF52e993288a04982267
11155420Optimism Sepolia0xa797799EE0C6FA7d9b76eF52e993288a04982267
11155111Ethereum Sepolia0xa797799EE0C6FA7d9b76eF52e993288a04982267