TON Connect - Python library for using TON Connect 2.
Project description
TON Connect for Python
Library for connecting TON Connect to Python apps.
Description
At this moment you can connect wallets to apps using HTTP Bridge.
Getting Started
Dependencies
- PyNaCl
- tonsdk (will be removed in the future)
- aiohttp
- requests
Installing
git clone https://github.com/ClickoTON-Foundation/tonconnect.git
pip install -e tonconnect
Using
Example of connecting wallet.
from tonconnect.connector import Connector
connector = Connector('https://tonclick.online/ton-connect.json')
url = connector.connect('tonkeeper', 'test')
print(f'Universal connect url for Tonkeeper: {url}')
address = connector.get_address()
print(f'Successfuly connected {address}.')
Example of connecting wallet with help of tonapi.io. tonapi.io it's used to obtain a public key, which adds support for more versions of the wallet that have the get_public_key method..
from tonconnect.connector import Connector
connector = Connector('https://tonclick.online/ton-connect.json', use_tonapi=True, tonapi_token=None)
url = connector.connect('tonkeeper', 'test')
print(f'Universal connect url for Tonkeeper: {url}')
address = connector.get_address()
print(f'Successfuly connected {address}.')
Example of asynchronous connecting wallet.
import asyncio
from tonconnect.connector import AsyncConnector
async def main():
connector = AsyncConnector('https://tonclick.online/ton-connect.json')
url = await connector.connect('tonkeeper', 'test')
print(f'Universal connect url for Tonkeeper: {url}')
address = await connector.get_address()
print(f'Successfuly connected {address}.')
if __name__ == '__main__':
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main())
More examples can be found in examples folder.
Authors
Version History
- 0.2.1
- Added ConnectErrorEvent
- Minor changes
- 0.2.0
- Added support of custom timeout
- Added tonhub support
- Changed from using get_public_key method to /v2/tonconnect/stateinit (tonapi.io)
- 0.1.3
- License change
- Python 3.11 support
- Small changes
- 0.1.2
- Bug fix
- 0.1.1
- Added tonapi.io support
- 0.1.0
- Async wrapper
- 0.0.2 & 0.0.3
- pyproject.toml fix
- 0.0.1
- Initial Beta
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Donate
If you like the library, I will be glad to accept donations.
- TON: EQCgphx8rTI0PukwmgpVqiPgqguTujhQscg2h7jgc4U0t347
Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tonconnect-0.2.1.tar.gz
.
File metadata
- Download URL: tonconnect-0.2.1.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7e5b54126f08590053b1209f2505a45e23c7e9eb2d8b7d51d6d82e43b049a31 |
|
MD5 | 3b8f37bb331393ab01381c9d384499b0 |
|
BLAKE2b-256 | 6b6adea7acab8e5f69820ea920893bf7b859505948a0539e8997fa95380f2471 |
File details
Details for the file tonconnect-0.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: tonconnect-0.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2841e03127b868905542a46f0a38ac72ffef26898fdd84ef299c526c142d0df |
|
MD5 | 5edf1236ef56a95950c90ca4d5543f43 |
|
BLAKE2b-256 | d963c2ffc0fde03119ec3b873a03c6ce11043125959ef9ad0e720401e1df667c |