Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
How do you send TON transactions in Python?

Are there any examples in Python for signing and sending TON transactions?

For example, sending TON coin from one wallet to another.


This question was imported from Telegram Chat: https://t.me/tondev/41704

Votes Newest

Answers


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())
  
  
Posted one year ago
Edited one year ago
Jeremy
404 × 5 Administrator
  
  

Эта библиотека устанавливается с ошибками ((

Alexandr Karabedyan   8 months ago Report
24K Views
1 Answer
2 years ago
one year ago
Tags