Skip to main content


Contract: JBOperatorStore​‌

Converts an array of permission indexes to a packed uint256.


function _packedPermissions(uint256[] calldata _indexes) private pure returns (uint256 packed) {...}
  • _indexes are the indexes of the permissions to pack.
  • The view function is private to the contract.
  • The view function does not modify or reference state variables outside the function.
  • The function returns the packed value.


  1. Loop through the provided indexes.

    for (uint256 _i; _i < _indexes.length; ) { ... }
    1. Get a reference to the permission index being iterated on.

      uint256 _index = _indexes[_i];
    2. Make sure the permission index is one of the 255 indexes in a uint256.

      if (_index > 255) revert PERMISSION_INDEX_OUT_OF_BOUNDS();
    3. Flip the bit at the specified index of the packed value being returned to indicate a truthy permission.

      // Turn the bit at the index on.
      packed |= 1 << _index;
    4. Increment the loop counter.

      unchecked {