Practical overview
When it fits
Use Pytoniq when a Python project needs direct TON blockchain access or native ADNL and DHT protocol workflows, rather than only a general-purpose blockchain interface.
Who it is for
- Python developers building applications that query TON blockchain data.
- Teams implementing TON LiteServer, ADNL or DHT integrations.
Documented uses
- Connect a Python application to a TON LiteServer and retrieve masterchain information.
- Scan blocks and inspect transaction messages.
- Send requests through a LiteBalancer that selects responsive LiteServers.
- Connect to ADNL peers and perform DHT lookups.
Requirements & limits
- The SDK is Python-based and its documented client examples use asynchronous operations.
- LiteClient setup accepts mainnet, testnet or custom configuration and includes trust-level and timeout parameters.
- LiteBalancer's timeout retry behavior must be explicitly enabled; its peer selection considers liveness, masterchain sequence number and average response time.
- The repository describes block-link proofs and a local
.blockstorefor zero-trust-level use. - The block-scanning example imports a helper from the repository examples folder that is not available in the PyPI package.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Connect a LiteClient and read TON masterchain information
Install Pytoniq, connect a LiteClient using mainnet configuration, and request masterchain information.
Before you start
- Python environment capable of installing the
pytoniqpackage. - A LiteServer configuration; the example uses
LiteClient.from_mainnet_config. - An asynchronous Python function for the documented
awaitcalls.
Steps
Install the package with the command below.
pip install pytoniqImport
LiteClientfrompytoniqand create a client withLiteClient.from_mainnet_config(ls_i=0, trust_level=2, timeout=15).Call
await client.connect()and thenawait client.get_masterchain_info().Close the connection with
await client.close(); alternatively, use the documentedasync withclient context manager to request masterchain information.
Expected outcome
The client connects and requests TON masterchain information, then closes the connection or exits its context manager.
Guide limitations
- The timeout setting does not include key-block synchronization.
- The documented example shows mainnet configuration; it notes testnet or a custom configuration dictionary as alternatives but does not provide their setup details.
Start an ADNL transport and connect to a peer
Initialize Pytoniq's ADNL receiving server, connect to the documented peer, and shut the server down.
Before you start
- Pytoniq installed in a Python environment.
- An asynchronous function for the documented
awaitcalls. - The peer address, port, and public key shown in the example.
Steps
Create an
AdnlTransportwithtimeout=3and callawait adnl.start().Create a
Nodeusing the example peer values and the transport:Node('172.104.59.125', 14432, "/YDNd+IwRUgL0mq21oC0L3RxrS8gTu0nciSPUrhqR78=", adnl).Connect with
await adnl.connect_to_peer(peer).Disconnect with
await peer.disconnect()and stop the receiving server withawait adnl.close().
Expected outcome
The example starts an ADNL receiving server, connects to the specified peer, and then disconnects and closes the server.
Guide limitations
- The example specifies a particular peer; it does not describe how to obtain or validate other peer details.
- The sample's optional ping delay is omitted because it is not required to establish and close the documented connection.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 11 October 2026
- Original website title
- yungwine/pytoniq · Official homepage title · retained in its source language

