Created
April 24, 2024 07:42
-
-
Save root-tanishq/79c8ef4c126c118ae6d4ef4dfc7d67c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rlp | |
from eth_utils import keccak, to_checksum_address, to_bytes | |
def mk_contract_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) | |
print(mk_contract_address('0xaDb67e10Fa330db49e98201B4c5F19356CfA3f59',0)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment