As suggest in What is topics[0] in Event logs? I am trying to find out 'Event hash' but it's not matching the output for below transaction.

Input Data

Function: transfer(address _to, uint256 _value) ***

MethodID: 0xa9059cbb

Event Logs

[0] 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
[1] 0x0000000000000000000000004dc8f417d4eb731d179a0f08b1feaf25216cefd0
[2] 0x0000000000000000000000000d2b2fb39b10cd50cab7aa8e834879069ab1a8d4

However when I try to find the keccak hash it's showing different hash.

  from Crypto.Hash import keccak
  keccak_hash = keccak.new(digest_bits=256)
  print keccak_hash.hexdigest()


3 Answers 3


is exactly sha3 hashing of event signature Transfer(address,address,uint256) - an ERC20 token event signature. Give a try to use sha3 hashing utility of web3 to verify this. Besides, topics[1] and topics[2] are indexed params of events, in this case, they're your from address value and to address value.

Each contract may define a list of different events. However, if the contract is written based on ERC20 standard, it will contain standard events of ERC20 and these events give the same signatures for all contracts and certainly give the same event signature hashing value.

Back to this input:

MethodID: 0xa9059cbb

0000000000000000000000000000000000000000000000000000010e6a06cb00 is logs data as known as token amount in this transfer. and 0000000000000000000000000d2b2fb39b10cd50cab7aa8e834879069ab1a8d4 is clearly to address in this transaction.


topics[0] is the hash of the event signature, which in your case is Transfer(address,address,uint256) for an ERC20 Transfer event. If you take the keccak hash of that you can confirm.

You've taken the hash of the transfer() function signature. Its first four bytes a9059cbb correctly give you the MethodID of the transfer() function, but that's something different and not related in any way to the Transfer EventID that is topics[0].

  • thx, it matches now, but how you got to know the Event signature given that it is not defined and input data only shows the transfer function.
    – garg10may
    Commented Sep 19, 2017 at 7:26
  • For ERC20 the event signatures are defined by the standard. For other event types you need access to the source code to calculate the EventID or to find out what the event means. Commented Sep 19, 2017 at 7:49
  • oh ok, so for all contracts the transfer topics will have same hashes. Actually I wanted topic signature so that can filter events bcoz event logs are huge, but still they will be huge bcoz tranfer events would be large in number.
    – garg10may
    Commented Sep 19, 2017 at 7:54



provide input Transfer(address,address,uint256)

you will get output ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

  • Spent the whole morning looking for this. Does web3 have a helper for creating this?
    – P i
    Commented Jun 18, 2021 at 6:47

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.