I'm trying to get a list of unique addresses that have interacted with a contract. As well as some data included in the events of each transaction. In order to do this, I use the action=getLogs query when using the etherscan API. Everything is returned in hex value it seems, and while I can decode one portion of the data I need, the address will not cooperate.

What it is returning is 0x[0(x24)]address.

My questions:

What is the purpose of adding in the 24 0's?

Do I use regex to strip the 0's, or is there a more consistent approach, perphaps using web3?

I've attemped using web3.eth.abi.decodeLog, but no matter how many times I adjust, it results in "property not found".


I think it's a right-padded 32-byte word.

  • 20 bytes for the address (0x[hex(x40)])
  • 12 bytes padding (0x[0(x24)])
  • Altogether, a 32-byte word

You get 40 chars representing 20 bytes in hex format, and 24 chars representing 12 zero bytes in hex format.

Hope it helps.

  • It definitely spells it out a little clearer. Thanks. Do you know the purpose for doing it this way? – joben0813 Feb 4 '19 at 17:53
  • 32-byte words are the native chunk size. Can never be too sure about motivation. I guess they opted to send the raw bytes instead of an interpretation. Thanks for accepting my answer. – Rob Hitchens Feb 4 '19 at 18:15

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.