For
Web3.solidityKeccak(['bool'], [True])
, Python Web3 yields: 0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2
This matches the output of keccak256(abi.encodePacked(true))
in Solidity. However, I want the output of keccak256(abi.encode(true))
because my contract has to deal with variably-sized data structures.
In Web3 JS, I could get the correct output (0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6
) using:
web3.utils.soliditySha3(web3.eth.abi.encodeParameters(['bool'], [true]))
How do I get it from Python Web3?
Of course I don't need the hash of a boolean. This just serves as an example for easy verification that the correct encoding was used.
However
makes your entire question unclear, since the expression before it and the expression after it are identical.In Web3 JS, I could get the correct output
- correct according to what (i.e., what scenario other than "web3.js" does this output represent)?