I have a indexed string event.

event productAdd(
        address indexed adder,
        uint256 indexed productId,
        string indexed ipfsHash,
        uint256 addingTime

I am try to get that string. It returns bytes32 but i couldnt convert it to string.

 const ipfsHash =

     ethers.utils.parseBytes32String(ethers.utils.hexStripZeros(ipfsHash, 32)) 

This throws error Error: invalid bytes32 string - no null terminator

1 Answer 1


You can't just convert it from bytes32 to string because that value you're looking at is a keccak hash of the original string

Read this answer to a question someone post.. he was trying to do the same as you so this question might be a duplicate

  • The solution i found for this i added a function to my contract with retrieve that string ,from a mapping by using that productId Jan 19, 2023 at 8:15
  • I actually suggested that In the other response :3 however that guy also mentioned about "not indexing the value would not get the string hashed therefore it's possible to extract the exact string"
    – Casareafer
    Jan 19, 2023 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.