Skip to main content

Python client for The Open Network

Project description

Introduction

This library is built entirely according to the standards of the selected language in order to admire the functionality.

Install TON using pip:

$ pip install ton

Now, let's get started:

>>> from ton.sync import TonlibClient
>>> import asyncio

>>> # Initiate module
>>> client = TonlibClient(asyncio.get_event_loop(), keystore='/Keystore')
>>> client.init_tonlib()
>>> 
>>> # Creating a wallet passphrase
>>> from mnemonic import Mnemonic
>>> seed = Mnemonic('english').generate(256)
>>> 
>>> # Wallet generation
>>> key = client.create_new_key(seed.split(' '))
>>> wallet = client.init_wallet(key)
>>>
>>> # Getting an address
>>> wallet.account_address.account_address
EQCi-D5OSmueD61_ZCw7D_tcMMjB8E5e5AECZT7lCM2Gm6O1
>>>
>>> # Viewing transactions
>>> txs = wallet.get_transactions()
>>> in_msg = txs[0].in_msg
>>> in_msg.source.account_address # Sender
EQBPhcJanCxCYc-eiSxUVcm7I4-PfHODzBNhY1Cd3R5IP041
>>> in_msg.destination.account_address # Recipient
EQCi-D5OSmueD61_ZCw7D_tcMMjB8E5e5AECZT7lCM2Gm6O1
>>> from ton.utils import from_nano
>>> from_nano(int(in_msg.value)) # Amount
0.6
>>> 
>>> # Sending transaction
>>> from ton.utils import to_nano
>>> wallet.transfer('EQBPhcJanCxCYc-eiSxUVcm7I4-PfHODzBNhY1Cd3R5IP041', to_nano(0.3), comment='test')
{
    "@type": "ok",
    "@extra": "1648032761.9897776:0:0.6654941473285754"
}

Documentation

To get acquainted with all the basics, go to Developer Interface

Dependencies

The TON library relies on these excellent libraries:

  • crc16 - Library for calculating CRC16
  • poetry - Python packaging and dependency management made easy
  • httpx - A next-generation HTTP client for Python
  • ujson - Ultra fast JSON encoder and decoder
  • ed25519 - Public-key signature system
  • mnemonic - Mnemonic code for generating deterministic keys

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ton-0.13.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ton-0.13-py3-none-any.whl (2.2 MB view details)

Uploaded Python 3

File details

Details for the file ton-0.13.tar.gz.

File metadata

  • Download URL: ton-0.13.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.9

File hashes

Hashes for ton-0.13.tar.gz
Algorithm Hash digest
SHA256 ed1165a57675c07d7b4006032b8dec4545590eee442e49b7ea42f95a6c5c51f7
MD5 82b44990bd07f136ad3c40fe374bb3b5
BLAKE2b-256 a28a3383662d07da96334f5bc76d611be84854af7bca59a3ee4211eb6a86e09b

See more details on using hashes here.

File details

Details for the file ton-0.13-py3-none-any.whl.

File metadata

  • Download URL: ton-0.13-py3-none-any.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.9

File hashes

Hashes for ton-0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 89a016a76cdf355ee11fa8120b2a14affba8caf3ed0f9e4029ea7ad5320062d3
MD5 a3778999999750b823c1538d39170f9a
BLAKE2b-256 16a40dcf94f2af65a0949566219a951b1a45738c3ac5c1c219a523a74e23867a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page