### Get TON Wallet Balance in Python Source: https://ton.org/en/docs/en/dev This Python snippet shows how to initialize a TON LiteClient, set up a wallet using a mnemonic phrase, and fetch the wallet's balance. It depends on the 'ton' library and requires a valid mnemonic list. The output is the wallet's balance in nano-toncoins. ```python # get client client = LsClient(ls_index=2, default_timeout=20) await client.init_tonlib() # init wallet my_wallet_mnemonics = [...] # mnemonics my_wallet = Wallet(provider=client, mnemonics=my_wallet_mnemonics, version='v4r2') # get balance my_wallet_nano_balance = await my_wallet.get_balance() print(my_wallet_nano_balance) ``` -------------------------------- ### Get TON Wallet Balance in Java/Kotlin Source: https://ton.org/en/docs/en/dev This Java/Kotlin snippet shows how to get an account's state and extract the balance using the TON LiteClient. It requires a LiteClient configuration and an account address. The output is the balance in coins as a string. ```java try (LiteClient liteClient = new LiteClient(context, liteClientConfigGlobal)) { String address = "EQDhfNEHdK06MNRjGyx5h0Pao5NgqFTE8ug2SrZ14c6bJnJF"; AddrStd addrStd = AddrStd.parse(address); Future future = callSuspend((c) -> liteClient.getAccountState(addrStd, c)); FullAccountState fullAccountState = future.get(); Account account = fullAccountState.account().getValue(); if (account instanceof AccountInfo) { String balance = ((AccountInfo) account).storage().balance().coins().toString(); System.out.println(balance); // balance } } catch (Exception e) { e.printStackTrace(); } ``` -------------------------------- ### Get TON Wallet Balance in Go Source: https://ton.org/en/docs/en/dev This Go snippet demonstrates connecting to a TON LiteServer, initializing a wallet from seed words, and retrieving the wallet's balance. It uses the 'go-ton' library and requires a seed phrase and LiteServer connection details. The output is the wallet's balance. ```go // connect to mainnet lite server client := liteclient.NewConnectionPool() err := client.AddConnection(context.Background(), "135.181.140.212:13206", "K0t3+IWLOXHYMvMcrGZDPs+pn58a17LFbnXoQkKc2xw=") api := ton.NewAPIClient(client) ctx := client.StickyContext(context.Background()) // ini wallet words := strings.Split("birth ... then", " ") w, err := wallet.FromSeed(api, words, wallet.V3) // get balance block, err := api.CurrentMasterchainInfo(ctx) balance, err := w.GetBalance(ctx, block) log.Println("Balance:", balance) ``` -------------------------------- ### Get TON Wallet Balance in JavaScript Source: https://ton.org/en/docs/en/dev This Javascript snippet demonstrates how to connect to the TON network, generate a new wallet using mnemonics, and retrieve the wallet's balance. It utilizes libraries like '@ton/ton' and '@orbs-network/ton-access'. The input is a generated mnemonic phrase, and the output is the wallet's balance in nano-toncoins. ```javascript import { TonClient, WalletContractV4 } from "@ton/ton"; import { mnemonicNew, mnemonicToPrivateKey } from "@ton/crypto"; import { getHttpEndpoint } from "@orbs-network/ton-access"; // get the decentralized RPC endpoint const endpoint = await getHttpEndpoint(); const client = new TonClient({ endpoint }); // Generate new key let mnemonics = await mnemonicNew(); let keyPair = await mnemonicToPrivateKey(mnemonics); let wallet = WalletContractV4.create({ 0, publicKey: keyPair.publicKey }); let walletContract = client.open(wallet); let balance: bigint = await walletContract.getBalance(); console.log(balance) // Get balance ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.