0

I am running into an error for:

TypeError: Type address payable is not implicitly convertible to expected type bytes32.

Due to the fact that I am using my address 0x0D81d9E21BD7C5bB095535624DcB0759E64B3899

I tried web3.utils.padLeft(web3.utils.hexToBytes(yourAddressString, 32); from https://stackoverflow.com/questions/58101282/how-to-convert-address-type-to-bytes32-via-web3 but had no avail. If somebody can convert my address 0x0D81d9E21BD7C5bB095535624DcB0759E64B3899 to bytes32 and tell me how they did it, I would greatly appreciate it. Thank you!

1
  • 1
    But why would you do that? Jul 22, 2021 at 8:13

2 Answers 2

1

Fixed, answer is use padding

example -> 0x0000000000000000000000000D81d9E21BD7C5bB095535624DcB0759E64B3899

Sometimes the simplest answers are right infront of you

0

If you read the Pad Left documentation, you'd see that you don't need to do any conversion. You simply should do a web3.utils.padLeft(address, 64). Given that you want bytes32, that is a total of 64 hex digits, you just need to fill the difference in 0s for in order to have 64 digits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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