What is state_init? Can't really understand it. Could anyone please explain what it does here? Thanks in advance.
new_wallet = create_wallet()

state_init = new_wallet.create_state_init()['state_init']

wallet = import_wallet(my_mnemonics)

boc = wallet.create_transfer_message(
to_addr=new_wallet.address.to_string(),
amount=to_nano(0.05, 'ton'),
seqno=1,
state_init=state_init
)['message'].to_boc(False)

Oct 1, 2023, 8:04 AM
StateInit contains code and data of smart contract, it is required for the deployment
Oct 1, 2023, 8:05 AM
What if I just want to send money from one wallet to another? Do I still need it?
Oct 1, 2023, 8:05 AM
No, you don’t
Oct 1, 2023, 8:06 AM
Hi I'm getting the error 'TonLib' object has no attribute '_tonlib_json_client_destroy'
The code is pretty basic. Does anyone know how to fix this? Thanks.
from ton import TonlibClient
import asyncio

client = TonlibClient()
TonlibClient.enable_unaudited_binaries()

async def main():
await client.init_tonlib()
wallet = client.create_wallet()
print('Wallet address:', wallet.address)
print('Seed:', wallet.export())

if __name__ == '__main__':
asyncio.run(main())
Oct 1, 2023, 8:47 AM
Is OpenSSL 1.1.1 installed? If this doesn't help, please use search in the chat.
Oct 1, 2023, 9:52 AM
I've searched but didn't really find a fix, have installed OpenSSL 1.1.1
Oct 1, 2023, 12:47 PM
What is the full error message? If it's long, you can post it via gist.github.com.
Oct 1, 2023, 12:48 PM
$ python example.py
Traceback (most recent call last):
File "C:\Users\Rey\tonTest\example.py", line 14, in
asyncio.run(main())
File "C:\Users\Rey\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\Rey\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 647, in run_until_complete
return future.result()
File "C:\Users\Rey\tonTest\example.py", line 8, in main
await client.init_tonlib()
File "C:\Users\Rey\tonTest\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 "C:\Users\Rey\tonTest\venv\lib\site-packages\ton\tonlibjson.py", line 92, in __init__
tonlib = CDLL(cdll_path)
File "C:\Users\Rey\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\Rey\tonTest\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 "C:\Users\Rey\tonTest\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:
Traceback (most recent call last):
File "C:\Users\Rey\tonTest\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'
Oct 1, 2023, 12:50 PM
Could you restart the console and/or launch the program from Windows-native console (cmd/Powershell)?
Oct 1, 2023, 12:54 PM
Have tried that multiple times, still the same error
Do I have to add something to path after installing?
Oct 1, 2023, 12:55 PM
It should've added itself, I guess.
Oct 1, 2023, 12:55 PM
Will try to restart and see
Still not working :(
Do you know any alternatives for TonLibClient?
Oct 1, 2023, 1:00 PM
I use ton-access/tonapi/dton APIs in Python programs, whatever is less buggy or more convenient to do certain request.
Oct 1, 2023, 1:04 PM
I think this is because of the fact that the library only works on intel CPUs :(
Do you know how to do something similar to this in tonapi/other libraries?
boc = wallet.create_transfer_message(
to_addr=new_wallet.address.to_string(),
amount=to_nano(0.05, 'ton'),
seqno=1,
state_init=state_init
)['message'].to_boc(False)

client = await get_client()

await client.raw_send_message(boc)

await client.close()
Oct 1, 2023, 1:27 PM
boc = wallet.create_transfer_message(
to_addr=new_wallet.address.to_string(),
amount=to_nano(0.05, 'ton'),
seqno=1, # TODO: load actual seqno
state_init=state_init
)['message'].to_boc(False) # using tonsdk
requests.post('https://toncenter.com/api/v2/sendBoc', # TODO: replace with ton-access
json={'boc': base64.b64encode(boc).decode('ascii')})
Oct 1, 2023, 1:29 PM
Thanks a lot!
Oct 1, 2023, 1:30 PM
1. Private key instead of await mnemonicNew().
2. No need to include your own address.
Oct 1, 2023, 1:38 PM
Could you please explain what is seqnum?
Oct 1, 2023, 1:41 PM
In a nutshell — number of outgoing transactions that the wallet has done. Used so that single request to send money out is not applied multiple times.
Oct 1, 2023, 1:42 PM
Got it, so each time I mention the number of outgoing transactions there?
Does workchain mean testnet/mainnet?
Oct 1, 2023, 3:31 PM
No, it means basechain (0) / masterchain (-1).
Oct 1, 2023, 3:31 PM

© 2024 Draquery.com All rights reserved.