Guest User

Untitled

a guest
Jan 21st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. import rlp
  2. from eth_utils import keccak, to_checksum_address, to_bytes
  3.  
  4. def predict_address(sender: str, nonce: int) -> str:
  5. sender_bytes = to_bytes(hexstr=sender)
  6. raw = rlp.encode([sender_bytes, nonce])
  7. h = keccak(raw)
  8. address_bytes = h[12:]
  9. return to_checksum_address(address_bytes)
Add Comment
Please, Sign In to add comment