1

I have created a contract where I am taking 2 Hashes from the user and trying to compare them both which in return would give a boolean value of true or false. It works good on remix but when I try to run the contract on Mist the compareString function just shows a message "NO". here is my code.

pragma solidity ^0.4.18;

contract Hash {    
    string fhash;
    string comphash;
    event Instructor(string _fhash);
    event Instructors(string _comphash);

    function setinstructor(string _fhash) public {
        fhash = _fhash;  
        emit Instructor(_fhash);           
    }          

    function getinstructor() public constant returns(string){
        return(fhash);
    }

    function setinstructors(string _comphash) public {
        comphash = _comphash; 
        emit Instructors(_comphash);        
    }

    function getinstructors() public constant returns(string){
        return(comphash);
    }

    function compareStrings() public view returns (bool){
        return sha256(fhash) == sha256(comphash)? true : false;              
    }
}

Image of Mist response

Adam Kipnis
  • 10,175
  • 10
  • 35
  • 48
Vishva Patel
  • 105
  • 1
  • 1
  • 6
  • not sure why you are getting NO back, but I don't think you need the ternary operator in there. You can just use == to compare strings. – digidigo Apr 02 '18 at 02:11

0 Answers0