So i have this enum, which is later used in struct definition in another contract. i wonder if this is a correct way to use enums in solidity?

Additionally, when i run this in remix, addRight function of RightsRegistry contract expects an address as _rightsType parameter. Which i suppose means that reference to the rights contract was created instead.

Question: what is the correct way to implement this logic?


contract RightsEnum {

  enum Rights {
  Rights rights;

    constructor() public {
        rights = Rights.VIEWER;

  function setValues(uint _value) public {
      require(uint(Rights.OWNER) >= _value);
      rights = Rights(_value);

  function getValue() public view returns (uint){
      return uint(rights);



contract RightsRegistry {

    struct Right 
        address holderEntity;
        address targetEntity;
        RightsEnum rightsType;
        address rightsContract;
        string infoUrl;
        uint status;
        uint startTime;
        uint expireTime;

    Right[] rights;

    function addRight(address _targetEntity, address _holderEntity, RightsEnum _rightsType) 

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.