I have an event defined like this:

event Created(
    address indexed target,
    string indexed name

I do

emit Created(..., _name); // called function with _name = "comment"

which gives




in the Ganache event explorer:

enter image description here

How can I convert this back to comment? web3.toAscii() just returns garbage.

  • Call const x = web3.fromAscii("comment");. What you get in x, is what you should see in Ganache explorer. My guess is that you're looking at the wrong thing, since x should end with something like 50 zeros (while the first 14 characters are gonna be your "comment"). Dec 5, 2019 at 16:48
  • I figured as much but I don't see where I could do anything wrong. If the type / storage requirement were wrong, solidity would complain with warnings and compile errors. The contract is deployed, the decoded signature in Ganache is "Created(target: address, name: string)" and the value is as above. Dec 5, 2019 at 16:54
  • @goodvibration Added screenshot Dec 5, 2019 at 16:55
  • Change that string to bytes32, then run again and tell us what you see. Dec 5, 2019 at 16:56
  • Indexed values of dynamic type like string are not stored directly with the event instead they are replaced by keccak256(value).
    – Ismael
    Dec 5, 2019 at 18:56

1 Answer 1


That happens because all array types (which includes string and bytes) are hashed. See the documentation:

If you use arrays (including string and bytes) as indexed arguments, its Keccak-256 hash is stored as a topic instead, this is because a topic can only hold a single word (32 bytes).

If you need the original value, you will have to remove the option indexed from the event parameter and filter the events yourself.

Your Answer

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

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