forked from SecorD0/evm-signer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
23 lines (19 loc) · 938 Bytes
/
generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import qrcode
from eth_account.hdaccount import Mnemonic
from eth_account.signers.local import LocalAccount
from web3 import Web3
from data import config
def generate() -> None:
w3 = Web3()
w3.eth.account.enable_unaudited_hdwallet_features()
mnemonic = Mnemonic().generate()
account: LocalAccount = w3.eth.account.from_mnemonic(mnemonic)
qrcode.make(account.address).save(config.QR_CODE_IMAGE)
wallet = f'''Mnemonic\tPrivate key\tAddress
{mnemonic}\t{account.privateKey.hex()}\t{account.address}'''
with open(config.WALLET_FILE, mode='w') as file:
file.write(wallet)
print(f'''Done!
QR code with the wallet address saved to the {config.LIGHTGREEN_EX}{config.QR_CODE_IMAGE}{config.RESET_ALL} file.
Save the mnemonic and private key from the {config.LIGHTGREEN_EX}{config.WALLET_FILE}{config.RESET_ALL} file to a password manager and {config.RED}DELETE THE FILE{config.RESET_ALL}!'''
)