I have contract which require input in bytes32, so I need convert address to bytes32, but no see this method in web3.
Ethereum addresses are 20 bytes, so you convert hex address to bytes and then pad it to 32 bytes from left.
web3.utils.padLeft(web3.utils.hexToBytes(yourAddressString), 32);
                        If you read the PadLeft 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With