The Roles SDK provides a convenient API for defining conditions on targets. Function inputs can be constrained to exact values, matched against patterns, or checked against condition functions.

Exact values

If a primitive, BigNumber, or array value is given, it will be used for an equality check. This also applies to placeholders. A contract function call will need to use this exact value to pass the condition.

To set an exact constraint on tuples, users can provide the expected tuple values as an array. To provide them as an object with named keys, it must be wrapped in a c.eq({ name: 'foo', age: 30 }) condition function, which enforces an exact match rather than a pattern match.

Matching patterns

If an object is given, it will be used as a matching pattern on tuples. In a matching pattern, the values to each key define the condition that shall be enforced on the respective parameter or tuple field. Each field condition can be either an exact value, a nested matching pattern, or a condition function.

Matching patterns can also be supplied as arrays using the c.matches([ 1, undefined, 3 ]) condition function. This allows using matching patterns on arrays or unnamed tuples. undefined elements in a pattern array will allow anything to pass for that tuple member.

Condition functions

Helper functions for defining conditions are provided under the c export:

import { c } from 'zodiac-roles-sdk;
c.or(1, 2, 3) // a condition that checks if a numeric parameter equals either of `1`, `2` or `3`



See EqualTo operator


See EqualToAvatar operator


Generally, comparison condition helpers are functions to be invoked with the expected value. c.avatar is a special case, because it does not take a comparison value. As such, it is the only member of c that must not be invoked.

Depending on the exact ABI type of the scoped parameter, maps to either a LessThan or a SignedIntLessThan operator.

Depending on the exact ABI type of the scoped parameter, maps to either a GreaterThan or a SignedIntGreaterThan operator.


See Bitmask operator

c.bitmask(params: {
  /** Offset in bytes at which to apply the mask, defaults to `0` */
  shift?: number
  /** The 15 bytes bitmask, each `1` means the bit at that position will be compared against the comparison value bit at the same position  */
  mask: BytesLike
  /** The 15 bytes comparison value, defines the expected value (`0` or `1`) for the bit at that position */
  value: BytesLike

Array conditions


See ArraySome operator


See ArrayEvery operator


See ArraySubset operator

Branch conditions


See And operator


See Or operator


See Nor operator

Tuple matching


Allows defining a matching pattern to check the value against the current scope.


The same as c.matches but skips over the first four bytes of the current scope, i.e. the function selector part of standard EVM call data.

This condition is most commonly used at the root node of the conditions tree for defining the conditions structure to be applied on the call parameters.

For this purpose, it takes the ABI types of all function parameters in the second argument. This information is required for encoding all sub conditions generated for the given matching pattern.

Additionally, c.calldataMatches can be used for setting conditions on bytes parameters that store standard-encoded EVM call data. There is a function overload that takes a permission object instead of a matching pattern + ABI types. This feature makes it convenient to use typed allow kits for scoping bytes parameters.


// Checks that bytes param in scope matches the calldata to the `claim_rewards(address)` function
// with the nested `address` param being equal to the address of the avatar

Allowance conditions


See WithinAllowance operator


See EtherWithinAllowance operator


See CallWithinAllowance operator

Custom conditions

Not yet implemented in the SDK