I want to decode this hex to address Is it possible? (EthersJS or Web3Js)


2 Answers 2


if you know its an address: it is just 0 padded, remove the padding and you get your address.

for ethersjs you can look at parsing and go from there: https://docs.ethers.io/v5/api/utils/abi/interface/#Interface--parsing

for web3js: https://web3js.readthedocs.io/en/v1.2.11/web3-eth-abi.html#decodeparameter

web3.eth.abi.decodeParameter("address", "0x0000000000000000000000002d4cffc2a90e28d90d3404a83bfd774294a3970a");


interface.parseLog( log ) 

that will parse the entire log for you


In ethers, you can use the following:

ethers.utils.defaultAbiCoder.decode(['address'], '0x0000000000000000000000002d4cffc2a90e28d90d3404a83bfd774294a3970a')

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.