Unanswered
There is one community led solution called pytonlib that I have found to send a transaction in Python. Please note that I have not tried it myself so I cannot in good faith recommend it, but the community members who work on it are quite active.
Install with:
pip install ton
Here is an example of how it is used to send a transaction.
from .init import client
from .wallet import wallet
# Viewing transactions
txs = await wallet.get_transactions()
in_msg = txs[0].in_msg
in_msg.source.account_address # Sender
in_msg.destination.account_address # Recipient
int(in_msg.amount) # Amount in nanoTONs
client.from_nano(int(in_msg.value)) # Amount in TONs
# Sending transaction with 1 TON
await wallet.transfer('EQCl1Ug9ZT9ZfGyFH9l4q-bqaUy6kyOzVPmrk7bivmVKJRRZ', client.to_nano(1), comment='test')
# Send transaction with multiple outputs
await wallet.transfer(
('EQCl1Ug9ZT9ZfGyFH9l4q-bqaUy6kyOzVPmrk7bivmVKJRRZ', client.to_nano(1), 'test comment'),
('EQCl1Ug9ZT9ZfGyFH9l4q-bqaUy6kyOzVPmrk7bivmVKJRRZ', client.to_nano(0.5), 'test comment 2'),
('EQCl1Ug9ZT9ZfGyFH9l4q-bqaUy6kyOzVPmrk7bivmVKJRRZ', client.to_nano(1))
)
# Sending transaction with raw BOC data
from tvm_valuetypes import Cell
await wallet.transfer('EQCl1Ug9ZT9ZfGyFH9l4q-bqaUy6kyOzVPmrk7bivmVKJRRZ', client.to_nano(1), data=Cell().serialize_boc())
470 Views
0
Answers
one year ago
one year ago
Эта библиотека устанавливается с ошибками ((