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
• 27,620 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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.

answered Oct 8, 2018 by Omkar
• 66,880 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 7, 2018 in Blockchain by Shashank
• 10,330 points
+1 vote
5 answers

Difference between internal-external, private-public in function

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

answered Apr 7, 2018 in Blockchain by Shashank
• 10,330 points
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 7, 2018 in Blockchain by Johnathon
• 9,050 points
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
0 votes
1 answer
+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
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
• 66,880 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.