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
>>>
>>> # Initiate module
>>> client = TonlibClient()
>>> client.init_tonlib()
>>> 
>>> # Wallet generation
>>> wallet = client.create_wallet()
>>> wallet
Wallet<EQCi-D5OSmueD61_ZCw7D_tcMMjB8E5e5AECZT7lCM2Gm6O1>
>>>
>>> # Get a word list
>>> seed = wallet.export()
>>>
>>> # Importing wallet
>>> wallet = client.import_wallet(seed)
>>>
>>> # Get saved wallet from Keystore
>>> path = wallet.path
>>> wallet = client.find_wallet(path)
>>>
>>> # 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.15.tar.gz (2.1 MB view hashes)

Uploaded Source

Built Distribution

ton-0.15-py3-none-any.whl (2.2 MB view hashes)

Uploaded Python 3

Supported by

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