Skip to main content
This section is a condensed tour of the tonutils library: creating and importing wallets, sending transactions, retrieving contract data, and calling get-methods. The snippets here are fragments for orientation — each topic has a full runnable version under Usage Examples.

Working with Wallets

Creating a Wallet

Result:
  • wallet — an instance of WalletV4R2, ready to use.
  • public_key — the wallet’s public key (PublicKey).
  • private_key — the wallet’s private key (PrivateKey).
  • mnemonic — list of 24 words (list[str]).

Importing a Wallet

From a mnemonic phrase:
Parameters:
  • MNEMONIC — can be provided in one of two formats:
    • a string of space-separated words.
    • a list of words.
Or from an existing private key:
Parameters:
  • private_key — a PrivateKey, constructed from raw bytes, a hex string, a base64 string, or an integer.

Wallet Examples

Full runnable scripts for creating, importing, and inspecting wallets on GitHub.

Sending Transactions

Single Transaction

Parameters:
  • destination — the recipient: a string with the address or an Address object.
  • amount — amount in nanotons (int); use to_nano() to convert from TON (1 TON = 10^9 nanotons).
  • body — comment as a string or custom data as a Cell.
Result: An ExternalMessage. Its normalized_hash is the normalized hash of the signed external message, computed locally before sending — it is not the on-chain transaction hash. Use it to track whether the message was accepted on-chain (via explorers or API queries).

Batch Transfer

Allows sending multiple transfers in a single transaction:
Result: An ExternalMessage (see Single Transaction for the meaning of normalized_hash).
V3 and V4 wallets support up to 4 messages per transaction. For more messages, use WalletV5R1, WalletHighloadV3R1, or WalletPreprocessedV2.

Send Mode

The send_mode parameter controls how the outgoing message is sent — for example, mode 128 carries the entire remaining balance of the wallet.
For more details on available send modes, see the official TON documentation.

Contract Information

Contract Balance

Result: An integer (int) representing the contract balance in nanotons. Use to_amount() to convert nanotons to TON.

Contract Data

Result: A ContractInfo object; see ContractInfo Fields Overview for the full field reference.

Calling a Contract Method

The run_get_method function allows invoking a contract’s get-method.
Parameters:
  • address — contract address as a string or an Address object.
  • method_name — name of the get-method to call (str).
  • stack — list of arguments, or None for no arguments.
Result: A list of values returned from the method’s execution stack.