Created
May 13, 2023 11:42
-
-
Save Jayke770/278ebcb0eac8a60789f974f9611b49ae to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| from ton.sync import TonlibClient | |
| from tonsdk.contract.wallet import WalletVersionEnum, Wallets | |
| from tonsdk.crypto import mnemonic_new | |
| wallet_version = WalletVersionEnum.v3r2 | |
| workchain = 0 | |
| client = TonlibClient(workchain_id=0) | |
| TonlibClient.enable_unaudited_binaries() | |
| client.init_tonlib() | |
| mnemonics = '' | |
| def generateWallet(): | |
| wallet_mnemonics = mnemonic_new() | |
| _mnemonics, _pub_k, _priv_k, wallet = Wallets.from_mnemonics(wallet_mnemonics, wallet_version, workchain) | |
| return ({"mnemonics": _mnemonics, "publicKey": _pub_k, "privateKey": _priv_k, "address": wallet.address.to_string(True, True, True)}) | |
| def getBalance(address): | |
| wallet = client.find_account(address) | |
| balance = wallet.get_balance() | |
| return client.from_nano(balance) | |
| def sendTon(mnemonics, receiver, amount): | |
| wallet = client.import_wallet(word_list=mnemonics, workchain_id=0) | |
| tx = wallet.transfer(receiver, client.to_nano(amount)) | |
| return tx | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment