psylopunk / pytonlib Goto Github PK
View Code? Open in Web Editor NEWSimple python client for The Open Network
Home Page: https://pydocs.xton.me/
License: MIT License
Simple python client for The Open Network
Home Page: https://pydocs.xton.me/
License: MIT License
This method caused an error
client.init_tonlib()
Error log:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/ton/ton/sync.py", line 18, in syncified
return loop.run_until_complete(coro)
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/ton/ton/client.py", line 71, in init_tonlib
self.config_info = r.config_info
AttributeError: 'TLObject' object has no attribute 'config_info'
Hello!
I would like to report about a problem with function wallet.transfer()
I am testing a new update of a library, have cloned repo from source.
When I am trying to transfer coins to another address from which I have received funds, function is freezes with no response. I have tried to pass different timeouts with no luck
>>> wallet.get_balance()
109999978
>>> # I have tried to pass different timeouts here
>>> response = wallet.transfer(<TonKeeper address>, to_nano(0.01), comment="with", timeout=10)
Maybe the issue can be caused due to increased transaction fee?
Am I correctly understand that fee is hardcoded and equals to 1000000 nano? Is there a way to change a fee (calculate&set)?
Hi, friends, I'm researching TON
ecosystems via pytonlib
and here is my code snippet about coin transferring from one wallet to another inside testnet
:
import asyncio
from ton import TonlibClient
OTHER_WALLET = 'EQBFOvCfYbwqHa0wgynfp420irRQXehxYIgoxPQSUYj69BmL'
async def main():
client = TonlibClient()
TonlibClient.enable_unaudited_binaries()
await client.init_tonlib()
mnemonics = ['boost', 'federal', 'immense', 'youth', 'kind', 'depart', 'search', 'axis', 'scissors', 'accuse',
'trade', 'pink', 'blue', 'year', 'screen', 'luggage', 'core', 'dentist', 'wool', 'congress', 'seminar',
'diamond', 'either', 'fish']
mnemonics = ' '.join(mnemonics)
wallet = await client.import_wallet(mnemonics)
address = wallet.address
account = await client.find_account(address)
balance = await account.get_balance()
print(f'{account.account_address} balance = {balance}')
# await wallet.transfer(OTHER_WALLET, client.to_nano(0.01), comment='test', allow_send_to_uninited=True)
await wallet.transfer(OTHER_WALLET, client.to_nano(0.01), comment='test')
# View account
account = await client.find_account( wallet.address)
# View transactions of an account
txs = await account.get_transactions() # Returns a list of TL Objects (transactions)
print(txs)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
Active wallet source
with non zero balance is here:
Other wallet destination
with non zero balance is here:
Both wallets are active and each has a non zero balance.
testnet
, e.g.:ton.tonlibjson.TonlibError: DANGEROUS_TRANSACTION: Transfer to uninited wallet
-1
and it's not true...More details:
C:\Users\sorlyanskiy\AppData\Local\anaconda3\python.exe C:\repositories\ton-research\wallet-3.py
C:\repositories\ton-research\wallet-3.py:42: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
[ 4][t 1][2024-06-11 09:05:14.8409833][TonlibClient.cpp:1479][!Tonlib][&tonlib_query] Tonlib got query [id:1] init {
options = options {
config = config {
config = "{"@type": "config.global", "dht": {"@type": "dht.config.global", "k": 6, "a": 3, "static_nodes": {"@type": "dht.nodes", "nodes": [{"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "6PGkPQSbyFp12esf1NqmDOaLoFA8i9+Mp5+cAx5wtTU="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -1185526007, "port": 22096}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "L4N1+dzXLlkmT5iPnvsmsixzXU0L6kPKApqMdcrGP5d9ssMhn69SzHFK+yIzvG6zQ9oRb4TnqPBaKShjjj2OBg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "4R0C/zU56k+x2HGMsLWjX2rP/SpoTPIHSSAmidGlsb8="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -1952265919, "port": 14395}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "0uwWyCFn2KjPnnlbSFYXLZdwIakaSgI9WyRo87J3iCGwb5TvJSztgA224A9kNAXeutOrXMIPYv1b8Zt8ImsrCg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "/YDNd+IwRUgL0mq21oC0L3RxrS8gTu0nciSPUrhqR78="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -1402455171, "port": 14432}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "6+oVk6HDtIFbwYi9khCc8B+fTFceBUo1PWZDVTkb4l84tscvr5QpzAkdK7sS5xGzxM7V7YYQ6gUQPrsP9xcLAw=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "DA0H568bb+LoO2LGY80PgPee59jTPCqqSJJzt1SH+KE="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -1402397332, "port": 14583}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "cL79gDTrixhaM9AlkCdZWccCts7ieQYQBmPxb/R7d7zHw3bEHL8Le96CFJoB1KHu8C85iDpFK8qlrGl1Yt/ZDg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "MJr8xja0xpu9DoisFXBrkNHNx1XozR7HHw9fJdSyEdo="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -2018147130, "port": 6302}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "XcR5JaWcf4QMdI8urLSc1zwv5+9nCuItSE1EDa0dSwYF15R/BtJoKU5YHA4/T8SiO18aVPQk2SL1pbhevuMrAQ=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "Fhldu4zlnb20/TUj9TXElZkiEmbndIiE/DXrbGKu+0c="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -2018147075, "port": 6302}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "nUGB77UAkd2+ZAL5PgInb3TvtuLLXJEJ2icjAUKLv4qIGB3c/O9k/v0NKwSzhsMP0ljeTGbcIoMDw24qf3goCg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "gzUNJnBJhdpooYCE8juKZo2y4tYDIQfoCvFm0yBr7y0="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": 89013260, "port": 54390}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "LCrCkjmkMn6AZHW2I+oRm1gHK7CyBPfcb6LwsltskCPpNECyBl1GxZTX45n0xZtLgyBd/bOqMPBfawpQwWt1BA=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "jXiLaOQz1HPayilWgBWhV9xJhUIqfU95t+KFKQPIpXg="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": 94452896, "port": 12485}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "fKSZh9nXMx+YblkQXn3I/bndTD0JZ1yAtK/tXPIGruNglpe9sWMXR+8fy3YogPhLJMdjNiMom1ya+tWG7qvBAQ=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "vhFPq+tgjJi+4ZbEOHBo4qjpqhBdSCzNZBdgXyj3NK8="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": 85383775, "port": 36752}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "kBwAIgJVkz8AIOGoZcZcXWgNmWq8MSBWB2VhS8Pd+f9LLPIeeFxlDTtwAe8Kj7NkHDSDC+bPXLGQZvPv0+wHCg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "sbsuMcdyYFSRQ0sG86/n+ZQ5FX3zOWm1aCVuHwXdgs0="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": 759132846, "port": 50187}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "9FJwbFw3IECRFkb9bA54YaexjDmlNBArimWkh+BvW88mjm3K2i5V2uaBPS3GubvXWOwdHLE2lzQBobgZRGMyCg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "aeMgdMdkkbkfAS4+n4BEGgtqhkf2/zXrVWWECOJ/h3A="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -1481887565, "port": 25975}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "z5ogivZWpQchkS4UR4wB7i2pfOpMwX9Nd/USxinL9LvJPa+/Aw3F1AytR9FX0BqDftxIYvblBYAB5JyAmlj+AA=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "rNzhnAlmtRn9rTzW6o2568S6bbOXly7ddO1olDws5wM="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -2134428422, "port": 45943}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "sn/+ZfkfCSw2bHnEnv04AXX/Goyw7+StHBPQOdPr+wvdbaJ761D7hyiMNdQGbuZv2Ep2cXJpiwylnZItrwdUDg=="}]}}, "liteservers": [{"ip": 84478511, "port": 19949, "id": {"@type": "pub.ed25519", "key": "n4VDnSCUuSpjnCyUk9e3QOOd6o0ItSWYbTnW3Wnn8wk="}}], "validator": {"@type": "validator.config.global", "zero_state": {"workchain": -1, "shard": -9223372036854775808, "seqno": 0, "root_hash": "F6OpKZKqvqeFp6CQmFomXNMfMj2EnaUSOXN+Mh+wVWk=", "file_hash": "XplPz01CXAps5qeSWUtxcyBfdAo5zVb1N979KLSKD24="}, "init_block": {"root_hash": "VpWyfNOLm8Rqt6CZZ9dZGqJRO3NyrlHHYN1k1oLbJ6g=", "seqno": 34835953, "file_hash": "8o12KX54BtJM8RERD1J97Qe1ZWk61LIIyXydlBnixK8=", "workchain": -1, "shard": -9223372036854775808}, "hardforks": [{"file_hash": "t/9VBPODF7Zdh4nsnA49dprO69nQNMqYL+zk5bCjV/8=", "seqno": 8536841, "root_hash": "08Kpc9XxrMKC6BF/FeNHPS3MEL1/Vi/fQU/C9ELUrkc=", "workchain": -1, "shard": -9223372036854775808}]}}"
blockchain_name = ""
use_callbacks_for_network = false
ignore_cache = false
}
keystore_type = keyStoreTypeDirectory {
directory = ".keystore"
}
}
}
[ 4][t 0][2024-06-11 09:05:14.8410403][Client.cpp:78][&tonlib_requests] Begin to wait for updates with timeout 0.100000
[ 4][t 1][2024-06-11 09:05:14.8462842][TonlibClient.cpp:4376][!Tonlib] loading libraries from disk cache
[ 3][t 1][2024-06-11 09:05:14.8511325][TonlibClient.cpp:2093][!Tonlib] Use blockchain name from MASTER config: 'mainnet' (was '')
[ 4][t 1][2024-06-11 09:05:14.8512053][LastBlockStorage.cpp:54][!Tonlib][&last_block] Save to cache: [last_block:(-1,8000000000000000,38297676):7BA50CEA643B51B4823744080C41173CED6C9837B428CB7CAC1F98A87596F21C:981DF1B6A95EF21959455D95600DB5E5CBFF879FB2D9C533D3D9690189685114][last_key_block:(-1,8000000000000000,38286476):B32CE94EE9EF8A515AF2C30745405D2A58444AFDA64C63BB533EA59E56E2F0C0:547E79257649A91013323D633AD37813CEF0079524FD6E7F7C97987295FE4F7C][utime:1718094240][init_block:(-1,8000000000000000,34835953):5695B27CD38B9BC46AB7A09967D7591AA2513B7372AE51C760DD64D682DB27A8:F28D76297E7806D24CF111110F527DED07B565693AD4B208C97C9D9419E2C4AF]
[ 4][t 1][2024-06-11 09:05:14.8547038][LastBlock.cpp:58][!Tonlib][&last_block] State: [last_block:(-1,8000000000000000,38286476):B32CE94EE9EF8A515AF2C30745405D2A58444AFDA64C63BB533EA59E56E2F0C0:547E79257649A91013323D633AD37813CEF0079524FD6E7F7C97987295FE4F7C][last_key_block:(-1,8000000000000000,38286476):B32CE94EE9EF8A515AF2C30745405D2A58444AFDA64C63BB533EA59E56E2F0C0:547E79257649A91013323D633AD37813CEF0079524FD6E7F7C97987295FE4F7C][utime:1718094240][init_block:(-1,8000000000000000,34835953):5695B27CD38B9BC46AB7A09967D7591AA2513B7372AE51C760DD64D682DB27A8:F28D76297E7806D24CF111110F527DED07B565693AD4B208C97C9D9419E2C4AF]
[ 4][t 1][2024-06-11 09:05:14.8547688][LastConfig.cpp:44][!Tonlib][&last_block] State:
[ 4][t 1][2024-06-11 09:05:14.8548044][TonlibClient.cpp:1456][!Tonlib][&tonlib_query id != 0] Tonlib answer query [id:1] options_info {
config_info = options_configInfo {
default_wallet_id = 698983191
default_rwallet_init_public_key = "Puasxr0QfFZZnYISRphVse7XHKfW7pZU5SJarVHXvQ+rpzkD"
}
}
[ 4][t 0][2024-06-11 09:05:14.8548180][Client.cpp:84][&tonlib_requests] End to wait for updates, returning object 1 000001ECFD6844A0
[ 4][t 1][2024-06-11 09:05:14.8556418][TonlibClient.cpp:1479][!Tonlib][&tonlib_query] Tonlib got query [id:2] setLogVerbosityLevel {
new_verbosity_level = 0
}
[ 4][t 0][2024-06-11 09:05:14.8556436][Client.cpp:78][&tonlib_requests] Begin to wait for updates with timeout 0.100000
[ 4][t 1][2024-06-11 09:05:14.8556662][TonlibClient.cpp:1518][!Tonlib][&tonlib_query] Tonlib got static query setLogVerbosityLevel {
new_verbosity_level = 0
}
{
"@type": "accountAddress",
"account_address": "EQDux15PgHF1MzuOqtF0v3oJ-GSClp4ogr7uQDqauK57L9xn"
} balance = -1
Traceback (most recent call last):
File "C:\repositories\ton-research\wallet-3.py", line 43, in <module>
loop.run_until_complete(main())
File "C:\Users\sorlyanskiy\AppData\Local\anaconda3\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "C:\repositories\ton-research\wallet-3.py", line 30, in main
await wallet.transfer(OTHER_WALLET, client.to_nano(0.01), comment='test')
File "C:\Users\sorlyanskiy\AppData\Local\anaconda3\lib\site-packages\ton\account\wallet_methods.py", line 86, in transfer
return await self.send_messages(messages, **kwargs)
File "C:\Users\sorlyanskiy\AppData\Local\anaconda3\lib\site-packages\ton\account\wallet_methods.py", line 51, in send_messages
query_id = (await self.client.execute(query)).id
File "C:\Users\sorlyanskiy\AppData\Local\anaconda3\lib\site-packages\ton\client\tonlib_methods.py", line 36, in execute
result = await self.tonlib_wrapper.execute(query, timeout=(timeout or self.default_timeout))
File "C:\Users\sorlyanskiy\AppData\Local\anaconda3\lib\site-packages\ton\tonlibjson.py", line 175, in execute
result = await self._execute(query, timeout=timeout)
ton.tonlibjson.TonlibError: DANGEROUS_TRANSACTION: Transfer to uninited wallet
Process finished with exit code 1
await wallet.transfer(OTHER_WALLET, client.to_nano(0.01), comment='test', allow_send_to_uninited=True)
with allow_send_to_uninited=True
gives another error ton.tonlibjson.TonlibError: NOT_ENOUGH_FUNDS
:C:\repositories\ton-research\wallet-3.py:42: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
[ 4][t 0][2024-06-11 09:13:30.6743831][Client.cpp:78][&tonlib_requests] Begin to wait for updates with timeout 0.100000
[ 4][t 1][2024-06-11 09:13:30.6832067][TonlibClient.cpp:1479][!Tonlib][&tonlib_query] Tonlib got query [id:1] init {
options = options {
config = config {
config = "{"@type": "config.global", "dht": {"@type": "dht.config.global", "k": 6, "a": 3, "static_nodes": {"@type": "dht.nodes", "nodes": [{"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "6PGkPQSbyFp12esf1NqmDOaLoFA8i9+Mp5+cAx5wtTU="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -1185526007, "port": 22096}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "L4N1+dzXLlkmT5iPnvsmsixzXU0L6kPKApqMdcrGP5d9ssMhn69SzHFK+yIzvG6zQ9oRb4TnqPBaKShjjj2OBg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "4R0C/zU56k+x2HGMsLWjX2rP/SpoTPIHSSAmidGlsb8="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -1952265919, "port": 14395}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "0uwWyCFn2KjPnnlbSFYXLZdwIakaSgI9WyRo87J3iCGwb5TvJSztgA224A9kNAXeutOrXMIPYv1b8Zt8ImsrCg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "/YDNd+IwRUgL0mq21oC0L3RxrS8gTu0nciSPUrhqR78="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -1402455171, "port": 14432}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "6+oVk6HDtIFbwYi9khCc8B+fTFceBUo1PWZDVTkb4l84tscvr5QpzAkdK7sS5xGzxM7V7YYQ6gUQPrsP9xcLAw=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "DA0H568bb+LoO2LGY80PgPee59jTPCqqSJJzt1SH+KE="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -1402397332, "port": 14583}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "cL79gDTrixhaM9AlkCdZWccCts7ieQYQBmPxb/R7d7zHw3bEHL8Le96CFJoB1KHu8C85iDpFK8qlrGl1Yt/ZDg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "MJr8xja0xpu9DoisFXBrkNHNx1XozR7HHw9fJdSyEdo="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -2018147130, "port": 6302}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "XcR5JaWcf4QMdI8urLSc1zwv5+9nCuItSE1EDa0dSwYF15R/BtJoKU5YHA4/T8SiO18aVPQk2SL1pbhevuMrAQ=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "Fhldu4zlnb20/TUj9TXElZkiEmbndIiE/DXrbGKu+0c="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -2018147075, "port": 6302}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "nUGB77UAkd2+ZAL5PgInb3TvtuLLXJEJ2icjAUKLv4qIGB3c/O9k/v0NKwSzhsMP0ljeTGbcIoMDw24qf3goCg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "gzUNJnBJhdpooYCE8juKZo2y4tYDIQfoCvFm0yBr7y0="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": 89013260, "port": 54390}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "LCrCkjmkMn6AZHW2I+oRm1gHK7CyBPfcb6LwsltskCPpNECyBl1GxZTX45n0xZtLgyBd/bOqMPBfawpQwWt1BA=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "jXiLaOQz1HPayilWgBWhV9xJhUIqfU95t+KFKQPIpXg="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": 94452896, "port": 12485}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "fKSZh9nXMx+YblkQXn3I/bndTD0JZ1yAtK/tXPIGruNglpe9sWMXR+8fy3YogPhLJMdjNiMom1ya+tWG7qvBAQ=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "vhFPq+tgjJi+4ZbEOHBo4qjpqhBdSCzNZBdgXyj3NK8="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": 85383775, "port": 36752}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "kBwAIgJVkz8AIOGoZcZcXWgNmWq8MSBWB2VhS8Pd+f9LLPIeeFxlDTtwAe8Kj7NkHDSDC+bPXLGQZvPv0+wHCg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "sbsuMcdyYFSRQ0sG86/n+ZQ5FX3zOWm1aCVuHwXdgs0="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": 759132846, "port": 50187}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "9FJwbFw3IECRFkb9bA54YaexjDmlNBArimWkh+BvW88mjm3K2i5V2uaBPS3GubvXWOwdHLE2lzQBobgZRGMyCg=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "aeMgdMdkkbkfAS4+n4BEGgtqhkf2/zXrVWWECOJ/h3A="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -1481887565, "port": 25975}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "z5ogivZWpQchkS4UR4wB7i2pfOpMwX9Nd/USxinL9LvJPa+/Aw3F1AytR9FX0BqDftxIYvblBYAB5JyAmlj+AA=="}, {"@type": "dht.node", "id": {"@type": "pub.ed25519", "key": "rNzhnAlmtRn9rTzW6o2568S6bbOXly7ddO1olDws5wM="}, "addr_list": {"@type": "adnl.addressList", "addrs": [{"@type": "adnl.address.udp", "ip": -2134428422, "port": 45943}], "version": 0, "reinit_date": 0, "priority": 0, "expire_at": 0}, "version": -1, "signature": "sn/+ZfkfCSw2bHnEnv04AXX/Goyw7+StHBPQOdPr+wvdbaJ761D7hyiMNdQGbuZv2Ep2cXJpiwylnZItrwdUDg=="}]}}, "liteservers": [{"ip": 84478511, "port": 19949, "id": {"@type": "pub.ed25519", "key": "n4VDnSCUuSpjnCyUk9e3QOOd6o0ItSWYbTnW3Wnn8wk="}}], "validator": {"@type": "validator.config.global", "zero_state": {"workchain": -1, "shard": -9223372036854775808, "seqno": 0, "root_hash": "F6OpKZKqvqeFp6CQmFomXNMfMj2EnaUSOXN+Mh+wVWk=", "file_hash": "XplPz01CXAps5qeSWUtxcyBfdAo5zVb1N979KLSKD24="}, "init_block": {"root_hash": "VpWyfNOLm8Rqt6CZZ9dZGqJRO3NyrlHHYN1k1oLbJ6g=", "seqno": 34835953, "file_hash": "8o12KX54BtJM8RERD1J97Qe1ZWk61LIIyXydlBnixK8=", "workchain": -1, "shard": -9223372036854775808}, "hardforks": [{"file_hash": "t/9VBPODF7Zdh4nsnA49dprO69nQNMqYL+zk5bCjV/8=", "seqno": 8536841, "root_hash": "08Kpc9XxrMKC6BF/FeNHPS3MEL1/Vi/fQU/C9ELUrkc=", "workchain": -1, "shard": -9223372036854775808}]}}"
blockchain_name = ""
use_callbacks_for_network = false
ignore_cache = false
}
keystore_type = keyStoreTypeDirectory {
directory = ".keystore"
}
}
}
[ 4][t 1][2024-06-11 09:13:30.6882911][TonlibClient.cpp:4376][!Tonlib] loading libraries from disk cache
[ 3][t 1][2024-06-11 09:13:30.6928515][TonlibClient.cpp:2093][!Tonlib] Use blockchain name from MASTER config: 'mainnet' (was '')
[ 4][t 1][2024-06-11 09:13:30.6929298][LastBlockStorage.cpp:54][!Tonlib][&last_block] Save to cache: [last_block:(-1,8000000000000000,38298321):521BB89D042C03A9C7C81C5CA3269EB6195D28B9755BD7DFAE6FBCD67CDD9BE1:35CA6FDA6E3BD2CAFEE09A1E021FF5D21B48DFAE2EECAEEBCC3EFFD905EDC9AF][last_key_block:(-1,8000000000000000,38286476):B32CE94EE9EF8A515AF2C30745405D2A58444AFDA64C63BB533EA59E56E2F0C0:547E79257649A91013323D633AD37813CEF0079524FD6E7F7C97987295FE4F7C][utime:1718097196][init_block:(-1,8000000000000000,34835953):5695B27CD38B9BC46AB7A09967D7591AA2513B7372AE51C760DD64D682DB27A8:F28D76297E7806D24CF111110F527DED07B565693AD4B208C97C9D9419E2C4AF]
[ 4][t 1][2024-06-11 09:13:30.6962913][LastBlock.cpp:58][!Tonlib][&last_block] State: [last_block:(-1,8000000000000000,38286476):B32CE94EE9EF8A515AF2C30745405D2A58444AFDA64C63BB533EA59E56E2F0C0:547E79257649A91013323D633AD37813CEF0079524FD6E7F7C97987295FE4F7C][last_key_block:(-1,8000000000000000,38286476):B32CE94EE9EF8A515AF2C30745405D2A58444AFDA64C63BB533EA59E56E2F0C0:547E79257649A91013323D633AD37813CEF0079524FD6E7F7C97987295FE4F7C][utime:1718097196][init_block:(-1,8000000000000000,34835953):5695B27CD38B9BC46AB7A09967D7591AA2513B7372AE51C760DD64D682DB27A8:F28D76297E7806D24CF111110F527DED07B565693AD4B208C97C9D9419E2C4AF]
[ 4][t 1][2024-06-11 09:13:30.6963370][LastConfig.cpp:44][!Tonlib][&last_block] State:
[ 4][t 1][2024-06-11 09:13:30.6963662][TonlibClient.cpp:1456][!Tonlib][&tonlib_query id != 0] Tonlib answer query [id:1] options_info {
config_info = options_configInfo {
default_wallet_id = 698983191
default_rwallet_init_public_key = "Puasxr0QfFZZnYISRphVse7XHKfW7pZU5SJarVHXvQ+rpzkD"
}
}
[ 4][t 0][2024-06-11 09:13:30.6963789][Client.cpp:84][&tonlib_requests] End to wait for updates, returning object 1 0000016EE4F6BDF0
[ 4][t 0][2024-06-11 09:13:30.6970119][Client.cpp:78][&tonlib_requests] Begin to wait for updates with timeout 0.100000
[ 4][t 1][2024-06-11 09:13:30.6971345][TonlibClient.cpp:1479][!Tonlib][&tonlib_query] Tonlib got query [id:2] setLogVerbosityLevel {
new_verbosity_level = 0
}
[ 4][t 1][2024-06-11 09:13:30.6971573][TonlibClient.cpp:1518][!Tonlib][&tonlib_query] Tonlib got static query setLogVerbosityLevel {
new_verbosity_level = 0
}
{
"@type": "accountAddress",
"account_address": "EQDux15PgHF1MzuOqtF0v3oJ-GSClp4ogr7uQDqauK57L9xn"
} balance = -1
Traceback (most recent call last):
File "C:\repositories\ton-research\wallet-3.py", line 43, in <module>
loop.run_until_complete(main())
File "C:\Users\sorlyanskiy\AppData\Local\anaconda3\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "C:\repositories\ton-research\wallet-3.py", line 29, in main
await wallet.transfer(OTHER_WALLET, client.to_nano(0.01), comment='test', allow_send_to_uninited=True)
File "C:\Users\sorlyanskiy\AppData\Local\anaconda3\lib\site-packages\ton\account\wallet_methods.py", line 86, in transfer
return await self.send_messages(messages, **kwargs)
File "C:\Users\sorlyanskiy\AppData\Local\anaconda3\lib\site-packages\ton\account\wallet_methods.py", line 51, in send_messages
query_id = (await self.client.execute(query)).id
File "C:\Users\sorlyanskiy\AppData\Local\anaconda3\lib\site-packages\ton\client\tonlib_methods.py", line 36, in execute
result = await self.tonlib_wrapper.execute(query, timeout=(timeout or self.default_timeout))
File "C:\Users\sorlyanskiy\AppData\Local\anaconda3\lib\site-packages\ton\tonlibjson.py", line 175, in execute
result = await self._execute(query, timeout=timeout)
ton.tonlibjson.TonlibError: NOT_ENOUGH_FUNDS
Process finished with exit code 1
Friends, how to fix it? I appreciate any help :)
P.S.: By the way, I also tried python ton sdk for my experiment about coin transferring inside testnet
and it seems python ton sdk aslo doesn't work correct...
from ton.sync import TonlibClient
from ton.utils import wallet
client = TonlibClient()
TonlibClient.enable_unaudited_binaries()
client.init_tonlib()
wallet = client.import_wallet('фраза')
path = wallet.path
wallet = client.find_wallet(path)
wallet.transfer('EQCl1Ug9ZT9ZfGyFH9l4q-bqaUy6kyOzVPmrk7bivmVKJRRZ', client.to_nano(0.01), comment='test')
error
Traceback (most recent call last):
File "/home/ubuntu/egsaa/generate_wallet.py", line 14, in <module>
wallet.transfer('EQCl1Ug9ZT9ZfGyFH9l4q-bqaUy6kyOzVPmrk7bivmVKJRRZ', client.to_nano(0.01), comment='test')
File "/home/ubuntu/.local/lib/python3.10/site-packages/ton/sync.py", line 18, in syncified
return loop.run_until_complete(coro)
File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/home/ubuntu/.local/lib/python3.10/site-packages/ton/account/wallet_methods.py", line 79, in transfer
return await self.send_messages(messages, **kwargs)
File "/home/ubuntu/.local/lib/python3.10/site-packages/ton/account/wallet_methods.py", line 33, in send_messages
state = await self.build_state()
File "/home/ubuntu/.local/lib/python3.10/site-packages/ton/account/wallet_methods.py", line 15, in build_state
assert 'source' in self.__dict__, 'source must be specified'
AssertionError: source must be specified
Traceback (most recent call last):
File "/home/container/main.py", line 5, in
client.init_tonlib()
File "/home/container/.local/lib/python3.10/site-packages/ton/sync.py", line 19, in syncified
return loop.run_until_complete(coro)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/container/.local/lib/python3.10/site-packages/ton/client/tonlib_methods.py", line 67, in init_tonlib
wrapper = TonLib(self.loop, self.ls_index, cdll_path, self.verbosity_level, default_timeout=self.default_timeout)
File "/home/container/.local/lib/python3.10/site-packages/ton/tonlibjson.py", line 92, in init
tonlib = CDLL(cdll_path)
File "/usr/local/lib/python3.10/ctypes/init.py", line 374, in init
self._handle = _dlopen(self._name, mode)
OSError: libcrypto.so.1.1: cannot open shared object file: No such file or directory
Exception in tonlibjson.del: Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/ton/tonlibjson.py", line 133, in del
self._tonlib_json_client_destroy(self._client)
AttributeError: 'TonLib' object has no attribute '_tonlib_json_client_destroy'
Exception ignored in: <function TonLib.del at 0x7ff0c73c6a70>
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/ton/tonlibjson.py", line 136, in del
RuntimeError: Error in tonlibjson.del: 'TonLib' object has no attribute '_tonlib_json_client_destroy'
container@nookure~ Server marked as offline...
Как собрать libtonlibjson в windows?
This error means that the library cannot run the libtonlibjson executable, which is used by the layer between the library and liteservers that process requests.
At the moment, the work of the library "out of the box" is guaranteed only on Ubuntu 20+ and new processors. In the future, we would very much like to increase the list of supported hardware, but I myself am unlikely to do it soon. If possible, I would be very happy to pull requests.
If this error has occurred, you need to find or build an executable file suitable for your conditions. To have an idea of how to build it, check out this Dockerfile. In addition, AT YOUR OWN RISK, you can try to use files from this folder.
When you have the right file, do this:
client.init_tonlib(cdll_path="path_to_binary")
Hi, does it support buy and sell tokens in TON network? Thanks
Is there any way to get balance of token in ton network? Also is it possiblw to send them
from ton.sync import TonlibClient
ModuleNotFoundError: No module named 'ton.sync'; 'ton' is not a package
Hello, I'm trying to understand, why seed phrases is not acceptable by other wallets?
I have tried to put 24 words to "TON Wallet" plugin for Chrome and to "Tonhub" from generated key, also from exported wallet.
# key[1] contains 24 words phrases.
key = client.create_new_key(seed.split(' '))
# _________
# word_list from TL object of exported wallet also do not work.
wallet.export()['word_list']
Library version is 0.14
Thank you!
Can this be run and used on MacOS on an Apple M1 chip?
wallet.transfer(dest,money) works great
1
wallet.transfer_nft(nft,dest) gives error
2
account = await client.find_account('EQCEXDQWeqjLP4BehKzzwbuRBsxQHVwEa9j4MGunBs1Vkg_w')
body = account.create_transfer_nft_body('EQCl1Ug9ZT9ZfGyFH9l4q-bqaUy6kyOzVPmrk7bivmVKJRRZ')
wallet.transfer(account.address, client.to_nano(0.05), data=body.serialize_boc()) gives error too
1 and 2 generate same error:
[ 0][t 2][2022-10-29 16:35:22.0590099][WalletInterface.cpp:66][!GenericSendGrams] Check 'cb.append_cellslice_bool(body)' failed
Hi! Is it possible to change my "inactive" state to "active" state using pytonlib?
raceback (most recent call last):
File "D:\tonTgWallet\main.py", line 6, in <module>
client.init_tonlib()
File "D:\tonTgWallet\venv\lib\site-packages\ton\sync.py", line 19, in syncified
return loop.run_until_complete(coro)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "D:\tonTgWallet\venv\lib\site-packages\ton\client\tonlib_methods.py", line 67, in init_tonlib
wrapper = TonLib(self.loop, self.ls_index, cdll_path, self.verbosity_level, default_timeout=self.default_timeout)
File "D:\tonTgWallet\venv\lib\site-packages\ton\tonlibjson.py", line 92, in __init__
tonlib = CDLL(cdll_path)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'D:\tonTgWallet\venv\lib\site-packages\ton\distlib\windows\tonlibjson.amd64.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Exception in tonlibjson.__del__: Traceback (most recent call last):
File "D:\tonTgWallet\venv\lib\site-packages\ton\tonlibjson.py", line 133, in __del__
self._tonlib_json_client_destroy(self._client)
AttributeError: 'TonLib' object has no attribute '_tonlib_json_client_destroy'
Exception ignored in: <function TonLib.__del__ at 0x000002593A6F0CA0>
Traceback (most recent call last):
File "D:\tonTgWallet\venv\lib\site-packages\ton\tonlibjson.py", line 136, in __del__
RuntimeError: Error in tonlibjson.__del__: 'TonLib' object has no attribute '_tonlib_json_client_destroy'
Getting this issue so can't just start my script
The whole code:
from ton.sync import TonlibClient
client = TonlibClient(ls_index=None)
TonlibClient.enable_unaudited_binaries()
client.init_tonlib()
wallet = client.create_wallet()
print(wallet)
I faced with strange exception, which appears with call get_transactions method of the account object:
account = await self._client.find_account(inv_address)
txs = await account.get_transactions(limit=1000)
In my log:
2022-07-24 21:10:58 - ERROR - Task exception was never retrieved
future: <Task finished name='Task-15' coro=<TonlibMethods.reconnect() done, defined at d:\projects\python\giveme_vpn\env\lib\site-packages\ton\client\tonlib_methods.py:124> exception=AttributeError("'TLObject' object has no attribute 'config_info'")>
Traceback (most recent call last):
File "d:\projects\python\giveme_vpn\env\lib\site-packages\ton\client\tonlib_methods.py", line 135, in reconnect
await self.init_tonlib()
File "d:\projects\python\giveme_vpn\env\lib\site-packages\ton\client\tonlib_methods.py", line 122, in init_tonlib
self.config_info = r.config_info
AttributeError: 'TLObject' object has no attribute 'config_info'
The strangeness in that the exception appears sometimes, not with every method call.
I don't know if it's my fault in my code or not. I will be appreciate any thoughts about that.
File "/usr/local/lib/python3.10/dist-packages/ton/account/wallet_methods.py", line 86, in transfer
return await self.send_messages(messages, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/ton/account/wallet_methods.py", line 51, in send_messages
query_id = (await self.client.execute(query)).id
File "/usr/local/lib/python3.10/dist-packages/ton/client/tonlib_methods.py", line 36, in execute
result = await self.tonlib_wrapper.execute(query, timeout=(timeout or self.default_timeout))
File "/usr/local/lib/python3.10/dist-packages/ton/tonlibjson.py", line 175, in execute
result = await self._execute(query, timeout=timeout)
ton.tonlibjson.TonlibError: ACCOUNT_TYPE_UNKNOWN
I try to run init.py from examples and I see:
Microsoft Windows [Version 10.0.19045.4291]
(c) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.
c:\Temp>python3
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
from ton import TonlibClient
client = TonlibClient()
TonlibClient.enable_unaudited_binaries()
await client.init_tonlib()
File "", line 1
SyntaxError: 'await' outside function
Hello, @psylopunk
First of all, thats a great library.
The only thing that I want to know is how can I test your library to work with my project? In Bitcoin, there is a testnet which is intentended in providing testing platform. I mean, anyways, every project connected with money and exchange should be tested properly, isn't that right?
Waiting for your reply.
hi i can't install this library in python 3.11
this is the error i see same error for every modules don't support python 3.11
DEPRECATION: crc16 is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at pypa/pip#8559
please upgrade this library for python 3.11 thanks!
Get balance wallet method raises an error.
Traceback (most recent call last):
File "/src/errors/handle.py", line 24, in wrapper
ad = func(*args, **kwargs)
File "/src/api/handle.py", line 160, in on_fetched_resource
document[BALANCE_FIELD] = my_wallet.get_balance()
File "/src/payment/ton.py", line 78, in get_balance
nano_balance = self.wallet.get_balance()
File "/usr/local/lib/python3.8/site-packages/ton-0.14-py3.8.egg/ton/sync.py", line 18, in syncified
return loop.run_until_complete(coro)
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/usr/local/lib/python3.8/site-packages/ton-0.14-py3.8.egg/ton/models/contract.py", line 31, in get_balance
return int((await self.get_state()).balance) # in nanocoins
AttributeError: 'TLObject' object has no attribute 'balance'
Hello devs!
I was able to import my Tonkeeper wallet, address and balance are right, but when i try a TON transfer an error is displayed.
Versions
Python 3.11
ton 0.26
Code
await wallet.transfer(
destination='EQDknEVVsW6neTn5w68wvzflkzC9Y--TvcDC7IlSJnWhwzRv',
amount=client.to_nano(0.01),
comment='test'
)
Traceback
future: <Task finished name='Task-1' coro=<main() done, defined at /home/lelzin/Área de trabalho/test-pytonlib/main.py:31> exception=TonlibError({'@type': 'error', 'code': 400, 'message': 'DANGEROUS_TRANSACTION: Transfer to uninited wallet', '@extra': '1687260860.1344755:0:0.5603447335617572'})>
Traceback (most recent call last):
File "/home/lelzin/Área de trabalho/test-pytonlib/main.py", line 41, in main
print(await wallet.transfer(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/lelzin/Área de trabalho/test-pytonlib/.venv/lib/python3.11/site-packages/ton/account/wallet_methods.py", line 86, in transfer
return await self.send_messages(messages, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lelzin/Área de trabalho/test-pytonlib/.venv/lib/python3.11/site-packages/ton/account/wallet_methods.py", line 51, in send_messages
query_id = (await self.client.execute(query)).id
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lelzin/Área de trabalho/test-pytonlib/.venv/lib/python3.11/site-packages/ton/client/tonlib_methods.py", line 36, in execute
result = await self.tonlib_wrapper.execute(query, timeout=(timeout or self.default_timeout))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lelzin/Área de trabalho/test-pytonlib/.venv/lib/python3.11/site-packages/ton/tonlibjson.py", line 175, in execute
result = await self._execute(query, timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ton.tonlibjson.TonlibError: DANGEROUS_TRANSACTION: Transfer to uninited wallet
What does that mean? Could anyone help me? Thanks devs
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.