Skip to content

Commit 0a2371a

Browse files
artemki2077fselmo
authored andcommitted
validate bytes length for salt in get_create2_address:
- Validate that the salt for ``get_create2_address`` is 32 bytes in length.
1 parent 323e6e9 commit 0a2371a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

web3/utils/address.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def get_create2_address(
3030
Determine the resulting `CREATE2` opcode contract address for a sender, salt and
3131
bytecode.
3232
"""
33+
if len(to_bytes(hexstr=salt)) != 32:
34+
raise TypeError(f"`salt` must be 32 bytes, {len(to_bytes(hexstr=salt))} != 32")
35+
3336
contract_address = keccak(
3437
b"\xff"
3538
+ to_bytes(hexstr=sender)

0 commit comments

Comments
 (0)