Sending hash in function parameter

0 votes

I'm writing a smart contract where the user sends a hashed string : the answer of an asked question (because I don"t want it to be public in the blockchain). It is compared to the correct hashed answer:

function answerQuestion(bytes32 _answer) notAnswered returns (string){
    if(_answer == keccak256(answer)){
        isAnswered = true;
        winner = msg.sender;
        return pos;
    }
    return "WRONG";
}

It gives me something like 57315cf71be5ffcaf957b9cc196b322e1c4d5a1832396abcee71d05d8caf41a6 and I parse it as the parameter in the browser solidity. But it returns:

Error encoding arguments: SyntaxError: Unexpected token c in JSON at position 6

Any idea how should I fix this?

Oct 8, 2018 in Blockchain by digger
• 26,740 points
713 views

1 answer to this question.

0 votes

I am developing a smart contract using the Remix IDE and I ran into the same issue. I solved this issue by appending 0x to the beginning of the hash.

0x57315cf71be5ffcaf957b9cc196b322e1c4d5a1832396abcee71d05d8caf41a6
answered Oct 8, 2018 by Omkar
• 69,230 points

Related Questions In Blockchain

+1 vote
1 answer

Can a data be altered in a blockchain without changing its hash?

Yes, it should work. The authentication practice ...READ MORE

answered Apr 8, 2018 in Blockchain by Shashank
• 10,400 points
800 views
+1 vote
5 answers

Difference between internal-external, private-public in function

External: These functions are part of the ...READ MORE

answered Apr 8, 2018 in Blockchain by Shashank
• 10,400 points
9,015 views
0 votes
1 answer

How feasible is it to use one way cryptographic hash function?

you can use the ouput hash function ...READ MORE

answered May 8, 2018 in Blockchain by Johnathon
• 9,090 points
577 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,879 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,396 views
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points
1,266 views
0 votes
3 answers
0 votes
1 answer

How to choose which function is called first in Node Js

You can do something like: infuraProvider.getBlockNumber().then(function(blockNumber) { ...READ MORE

answered Oct 8, 2018 in Blockchain by Omkar
• 69,230 points
575 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP