Skip to content

Instantly share code, notes, and snippets.

@Jayke770
Created May 13, 2023 11:42
Show Gist options
  • Select an option

  • Save Jayke770/278ebcb0eac8a60789f974f9611b49ae to your computer and use it in GitHub Desktop.

Select an option

Save Jayke770/278ebcb0eac8a60789f974f9611b49ae to your computer and use it in GitHub Desktop.
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