Skip to content

Instantly share code, notes, and snippets.

@Aviksaikat
Last active May 19, 2024 18:42
Show Gist options
  • Save Aviksaikat/fd22f2441172b8ce7e613e04a310b5e4 to your computer and use it in GitHub Desktop.
Save Aviksaikat/fd22f2441172b8ce7e613e04a310b5e4 to your computer and use it in GitHub Desktop.
Get the public address of an EOA from private key(randomly generated)
from eth_account import Account
# Generate a new Ethereum private key
private_key = Account.create()._private_key.hex()
# Print the private key
print("Private Key:", private_key)
# Derive the Ethereum address from the private key
address = Account.from_key(private_key).address
# Print the Ethereum address
print("Address:", address)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment