Solidity Error – Operator ‘==’ Not Compatible with Types Address and Bytes32

addressesdata-typeserrorremixsolidity

How can I change the last line in the following code to make it work?

contract University { 
    address public owner; 
    address public student; 
    bytes32 fName; 
    bytes32 lName; 
    bytes32 Studies; 
    bytes32 private caCertificate; 
    bytes32 ipfs_hash;

    constructor() public { 
        owner = msg.sender; 
    } 

     modifier onlyOwner() { if (msg.sender == owner) _; } 
     modifier onlyOwnerOrStudent() { 
         if (msg.sender == owner || msg.sender == student) _; 

    .....
}

I get the error message:

Operator == not compatible with types address and bytes32

Best Answer

you are comparing data types of address and bytes32 for equality. Since they are two data types operator is not allowed. you need make either student to bytes32 or fName to address depending on your use-case.

Related Topic