enter image description here

The above hash data is generated by web3 soliditySha3 with the objects below.

It seems the function generates hashes as I wanted; each object has different hash value. But I am not sure if it's working as I intended. In the official documentation page, and the function works with the object but really not sure about it. Can someone tell me about it?? Am I using it in right way? or should I compact the string values of each key and make the hashes based on it ??

let temp1 = {
    name: "sam smith",
    id: "tomato123123",
    timestamp: "2018/10/27"
let temp2 = {
    name: "sam smith",
    id: "apple123123",
    timestamp: "2018/10/22"
  • 1
    "But I am not sure if it's working as I intended..." How are you intending to use it? – Shawn Tabrizi Nov 15 '18 at 0:53
  • Hash functions are defined over a sequence of bytes. To correctly calculate over more complex data structures you agree over an encoding format. Since solidity doesn't have native support for JSON you might want to use tuples to handle structs instead. – Ismael Nov 18 '18 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.