2

This question already has an answer here:

When we invoke an event as follows :

event MyEvent(uint256 indexed _id, bytes32 _action, bytes32 _player, bytes32 _actionState,  address _owner);

emit MyEvent(uint256(_public_id), bytes32(_action), bytes32(_player), bytes32(_actionState), _owner);

In EtherScan, we see an output as follows :

EtherScan Event Log

What does Topics [0] 0x22b8025a23f25c3f52cdbc1f53a831dbd4e3b4aaeebe121d36c858abea974bc7 mean ?

In case of MyEvent, [1] 0x0000000000000000000000000000000000000000000000000000000000000001 means _public_id = 1

However, I do not know 0x22b8025a23f25c3f52cdbc1f53a831dbd4e3b4aaeebe121d36c858abea974bc7 comes from where ? and in general, the term of Topics what does it mean ?

marked as duplicate by Ismael, Achala Dissanayake, mirg, Richard Horrocks, CPereez19 May 25 '18 at 6:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @Ismael, Yeah u'r right, I did not see that question .... Sorry.... – Questioner May 24 '18 at 13:15
  • @Ismael However, I think the answer of user Lbrth_BoC is more related to what I expected. Thanks – Questioner May 24 '18 at 13:30
  • @Ismael If you want to delete this question you can do it, but i think it would be better to keep answer of user Lbrth_BoC. Thanks – Questioner May 24 '18 at 13:38
5

In a transaction receipt the fied topics correspond to your event arguments which are indexed in your smart contract. For all events you will find as first argument the hash of the event name, and then the data which are indexed in hexabytes.

So in your case, in topics you will find

'topics':[hash_event_name,// w3.sha3(text='myEvent(uint256)').hex() where Event name without input argumentsname
         0x000000...000000001//your first argument '_id' because is indexed 
         ]

All of your event arguments which are not indexed are stored in the data part of the transaction receipt

  • Are you sure about this part? sha('MyEvent(uint256')) – mesqueeb May 25 '18 at 8:29
  • With web3.py the correct thing is : event_signature_hash = w3.sha3(text='MyEvent(uint256)').hex() #Event name without input arguments – Lbrth_BoC May 25 '18 at 8:33
  • I'm trying to use web3js 1.0 to get the sha of my event: web3.utils.sha3('TokenSold(uint256 tokenId,uint256 oldPrice,uint256 newPrice,address prevOwner,address winner,string name)') This gave me the wrong hash... – mesqueeb May 25 '18 at 8:35
  • 1
    Yes because you input the name of your arguments inside the sha3 functions. So, you should get the correct hash with : web3.utils.sha3('TokenSold(uint256, uint256, uint256, address, address, string)'). Add only the type of your variable – Lbrth_BoC May 25 '18 at 8:38
  • Thanks so much! I got the correct hash with your solution but without the spaces! Cheers mate!! – mesqueeb May 25 '18 at 8:39

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