Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import rlp
- from eth_utils import keccak, to_checksum_address, to_bytes
- def predict_address(sender: str, nonce: int) -> str:
- sender_bytes = to_bytes(hexstr=sender)
- raw = rlp.encode([sender_bytes, nonce])
- h = keccak(raw)
- address_bytes = h[12:]
- return to_checksum_address(address_bytes)
Add Comment
Please, Sign In to add comment