Is it okay to change the pragma version of openzeppelin library

Is it okay to change the pragma version so that it can match my contract version which is 0.8.0. because i keep getting errors when compiling

pragma solidity ^0.5.0;

/**

  • @title Roles

  • @dev Library for managing addresses assigned to a Role.
    */
    library Roles {
    struct Role {
    mapping (address => bool) bearer;
    }

    /**

    • @dev Give an account access to this role.
      */
      function add(Role storage role, address account) internal {
      require(!has(role, account), "Roles: account already has role");
      role.bearer[account] = true;
      }

    /**

    • @dev Remove an account's access to this role.
      */
      function remove(Role storage role, address account) internal {
      require(has(role, account), "Roles: account does not have role");
      role.bearer[account] = false;
      }

    /**

    • @dev Check if an account has this role.
    • @return bool
      */
      function has(Role storage role, address account) internal view returns (bool) {
      require(account != address(0), "Roles: account is the zero address");
      return role.bearer[account];
      }
      }

Hello @ohoodrichard

OpenZeppelin contracts version 4.x are written using solidity 0.8. Some part of it may work with 0.8.0 while other parts may need newer version.

Version 3.x of our contract are available for developpers using solidity 0.6 or 0.7

Version 2.x of our contract is using solidity 0.5. That is the version you should be using if you want to compile with version 0.5.0 of the solidity compiler.

Please keep in mind that this is a very old version of the compiler, that is known to contain a lot of bugs. We strongly recommand you don't use it, and chose a more recent version of the compiler instead.

1 Like