-
Notifications
You must be signed in to change notification settings - Fork 5
/
01_wallet.py
41 lines (32 loc) · 1014 Bytes
/
01_wallet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import json
import os
from eth_account import Account
root_dir = os.path.dirname(os.path.abspath(__file__))
def saveETHWallet(jsonData):
file_path = root_dir + '/accounts/wallets.json'
if os.path.exists(file_path):
raise RuntimeError("Wallets existed")
with open(file_path, 'w') as f:
json.dump(jsonData, f, indent=4)
def createNewETHWallet(number):
wallets = []
for id in range(number):
# 添加一些随机性
account = Account.create('zksync Random Seed' + str(id))
# 私钥
privateKey = account._key_obj
# 公钥
publicKey = privateKey.public_key
# 地址
address = publicKey.to_checksum_address()
wallet = {
"index": id,
"address": address,
"privateKey": str(privateKey)
}
wallets.append(wallet)
return wallets
# https://eth.antcave.club/1000
if __name__ == '__main__':
wallets = createNewETHWallet(10)
saveETHWallet(wallets)