I have created this demo contract. It has a function called convertText which converts a string text into bytes32 and stores it into bytes32[] public storedData.

You can see when you call convertText() it emits an event called SingleEvent which emits the bytes32 value of the text but when you call emitEvents() function it emits a function called MyEvent which should emit the array of previous bytes32 value. But here this event doesn't have the first parameter as an array, also it doesn't have the value of byte32 text we saved earlier.

I want to know how can I get the byte32 value of the previous saved byte32 into array from the MyEvent event?

  • I think you would need to parse the event, check this code snippet ethereum.stackexchange.com/a/156480/104252 Commented Nov 18, 2023 at 14:20
  • @ZartajAfser It's giving me error that new ethers.Interface(abi); is not a constructor Commented Nov 19, 2023 at 6:44
  • For understand better your question, in "myEvent" event do you want visualize the last value inserted into array through "convertText" method? Commented Nov 25, 2023 at 19:06

1 Answer 1


You cannot emit an array automatically in an indexed topic unless you manually loop through its values. This is because an array is a reference type, not a value.

From the Solidity documentation about events:

[...] A topic can only hold a single word (32 bytes) so if you use a reference type for an indexed argument, the Keccak-256 hash of the value is stored as a topic instead.

If you want those values automatically, you must remove the indexed keyword from your event definition, losing the ability to easily filter those events by their value.

So you should use

event MyEvent(bytes32[] data);

instead of

event MyEvent(bytes32[] indexed data);

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.