Skip to content

Instantly share code, notes, and snippets.

@kdembler
Last active June 9, 2020 21:21
Show Gist options
  • Save kdembler/599345e0789d7f368c0b62ee494562f8 to your computer and use it in GitHub Desktop.
Save kdembler/599345e0789d7f368c0b62ee494562f8 to your computer and use it in GitHub Desktop.
from web3 import Web3
public_key = bytes.fromhex('04da2bb6a42df116824d7ccb91b09e3f8fa2c0c94a829791468dd10cc63b9c2f9cd8ead4b201a07acc30c4a9b23d77ec9c43f7206a039418b20ae89d395308e76f')
unprefixed_public_key = public_key[1:] # remove the '04' prefix
public_key_hash = Web3.keccak(unprefixed_public_key)
address_bytes = public_key_hash[-20:]
address = address_bytes.hex()
print(address)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment