-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathcreate_wallet.py
More file actions
64 lines (54 loc) · 1.8 KB
/
create_wallet.py
File metadata and controls
64 lines (54 loc) · 1.8 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Wallet version selection:
# Example uses WalletV4Config + WalletV4R2.
# Other wallet versions are listed below — uncomment the pair you need.
from ton_core import (
NetworkGlobalID,
# WalletV1Config,
# WalletV2Config,
# WalletV3Config,
WalletV4Config,
# WalletV5BetaConfig,
# WalletV5Config,
# WalletHighloadV2Config,
# WalletHighloadV3Config,
# WalletPreprocessedV2Config,
)
from tonutils.clients import ToncenterClient
from tonutils.contracts import (
# WalletV1R1,
# WalletV1R2,
# WalletV1R3,
# WalletV2R1,
# WalletV2R2,
# WalletV3R1,
# WalletV3R2,
# WalletV4R1,
WalletV4R2,
# WalletV5Beta,
# WalletV5R1,
# WalletHighloadV2,
# WalletHighloadV3R1,
# WalletPreprocessedV2,
)
def main() -> None:
# Initialize HTTP client for TON blockchain interaction
# NetworkGlobalID.MAINNET (-239) for production
# NetworkGlobalID.TESTNET (-3) for testing
client = ToncenterClient(network=NetworkGlobalID.MAINNET)
# Wallet configuration (default settings)
# Can customize subwallet_id for multiple wallets from same mnemonic
config = WalletV4Config()
# Create new wallet with fresh mnemonic and keypair
# Returns: (wallet, public_key, private_key, mnemonic)
wallet, public_key, private_key, mnemonic = WalletV4R2.create(client, config=config)
# Get wallet address in user-friendly format
# is_bounceable=False: standard for wallet contracts (UQ...)
address = wallet.address.to_str(is_bounceable=False)
# Output wallet credentials
print(f"Address: {address}")
print(f"Mnemonic: {' '.join(mnemonic)}")
print(f"Public Key: {public_key.as_int}")
print(f"Private Key: {private_key.as_b64}")
print(f"Keypair: {private_key.keypair.as_b64}")
if __name__ == "__main__":
main()