From de04cde6525936e5f8e02fad28bd49e095acc7b4 Mon Sep 17 00:00:00 2001 From: Emanuele Bellocchia <54482000+ebellocchia@users.noreply.github.com> Date: Sat, 4 May 2024 21:27:40 +0200 Subject: [PATCH] Add example for Ethereum with Atomic wallet --- examples/eth_atomic.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/eth_atomic.py diff --git a/examples/eth_atomic.py b/examples/eth_atomic.py new file mode 100644 index 00000000..9df8caa7 --- /dev/null +++ b/examples/eth_atomic.py @@ -0,0 +1,19 @@ +""" +Example of how to get Ethereum address like Atomic wallet. + +Atomic Wallet doesn't actually derive a BIP44 path for Ethereum, but it directly uses the master key for getting the address. +""" + +from bip_utils import Bip39SeedGenerator, Bip44, Bip44Coins + + +# Mnemonic +mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" +# Generate seed from mnemonic +seed_bytes = Bip39SeedGenerator(mnemonic).Generate() + +# Construct from seed +bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.ETHEREUM) +# Print master key +print(f"Private key: {bip44_mst_ctx.PrivateKey().Raw().ToHex()}") +print(f"Address: {bip44_mst_ctx.PublicKey().ToAddress()}")