Skip to main content

📦 aiogram TON Connect

TON Python Versions PyPI License Donate

Image

Downloads Downloads Downloads

TON Connect for aiogram bots

Wallet connection, transactions, and data signing in Telegram bots.
The library shows the screens of each request and passes the results to your handlers as aiogram events.
See the example bot or try the demo bot in Telegram.

Built on ton-connect, the Python SDK for TON Connect.

Features

  • Wallet Connection — QR code, wallet list with pages, and a button that opens the chosen wallet
  • Requests — send transactions, sign messages for gasless relays, sign text, binary, and cell data
  • TON Proof — wallet ownership and data signature verification
  • Events — results come to router handlers with status, error, and the wallet answer
  • Restarts — sessions and pending requests live in the FSM storage and resume after a restart
  • Screens — texts in any language, button styles, or your own screens

Support this project — TON: donate.ness.ton
UQCZq3_Vd21-4y4m7Wc-ej9NFOhh_qvdfAkAYAOHoQ__Ness

Installation

pip install aiogram-tonconnect

Usage

import asyncio

from aiogram import Bot, Dispatcher
from aiogram.filters import CommandStart
from aiogram.types import Message
from ton_connect.models import Wallet

from aiogram_tonconnect import TonConnectContext, TonConnectEvent, TonConnectRouter, setup_tonconnect

BOT_TOKEN = "12345:qwerty"
MANIFEST_URL = "https://raw.githubusercontent.com/nessshon/aiogram-tonconnect/main/public/tonconnect-manifest.json"

dp = Dispatcher()
router = TonConnectRouter()


@dp.message(CommandStart())
async def start(message: Message, tc: TonConnectContext) -> None:
    # Shows the connect screen: QR code, wallet list, Back
    await tc.connect()


@router.connect()
async def connected(event: TonConnectEvent, wallet: Wallet | None) -> None:
    text = f"Connected: {wallet.account.address.to_str()}" if wallet else "Not connected"
    await event.message.edit_text(text)


async def main() -> None:
    bot = Bot(BOT_TOKEN)
    dp.include_router(router)
    setup_tonconnect(dp, bot, manifest_url=MANIFEST_URL)
    await dp.start_polling(bot)


if __name__ == "__main__":
    asyncio.run(main())

Notes

  • Manifest — the example uses a public one; host your own tonconnect-manifest.json for a real bot
  • Storage — sessions and pending requests live in the FSM storage; use RedisStorage to keep them after a restart
  • TON Proof — pass TonProof to setup_tonconnect to verify wallet ownership and signed data
  • Screens — subclass View to change texts, language, the QR code, or whole screens
  • Cancel — call tc.cancel() to end an operation before replacing its screen

License

This repository is distributed under the MIT License.

Metadata

Release files for aiogram-tonconnect 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiogram-tonconnect 1.0.0
File Size Uploaded Provenance Actions
aiogram_tonconnect-1.0.0.tar.gz 28.8 kB Without provenance Details for aiogram_tonconnect-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiogram-tonconnect 1.0.0
File Interpreter ABI Platform Actions
aiogram_tonconnect-1.0.0-py3-none-any.whl Python 3 none any Details for aiogram_tonconnect-1.0.0-py3-none-any.whl

Total release size: 64.4 kB

Release files / aiogram_tonconnect-1.0.0.tar.gz

Download URL aiogram_tonconnect-1.0.0.tar.gz
Size 28.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3ac26221af68a7340ca1e3cdc18f3b653fa30230eb2d7c7e16dc8db4847b84e2
BLAKE2b-256 checksum
How to use checksums
1059a2e97c0f5181b394b5fb912fa3feb5fb2fab7bf403a78ef7b488af104bf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / aiogram_tonconnect-1.0.0-py3-none-any.whl

Download URL aiogram_tonconnect-1.0.0-py3-none-any.whl
Size 35.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f96dde18bd401bb8760a6dba2bed1d142e618638aad0811fc14be190a2ad95d5
BLAKE2b-256 checksum
How to use checksums
b6061a3c30edbdf1397f2c31625572e4d670fb5cc3c6be93d16098e5c498ce14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for aiogram-tonconnect 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page