admin管理员组文章数量:1332724
I’m developing a Python application where I need to send transactions using wallet version v5r1 (TON blockchain). The primary requirement is to implement multi-send transactions, which is supported in this wallet version.
I’m using the tonsdk library, but it doesn’t seem to natively support v5r1. Here’s what I need to achieve:
Create transaction messages using the v5r1 wallet format. Send
multiple transactions in a single batch (multi-send).
What steps or libraries can I use to accomplish this? Are there any examples or alternative approaches? Additionally, I’d appreciate guidance on how to properly handle SEQNO for v5r1 wallets.
Here’s an example of the code I’ve tried (based on other wallet versions):
from tonsdk.contract.wallet import Wallets, WalletVersionEnum
from tonsdk.utils import to_nano
mnemonics = "my seed phrase here".split(" ")
version = WalletVersionEnum.v5r1 # Targeted version
# Key and wallet generation
mnemonics, pub_k, priv_k, wallet = Wallets.from_mnemonics(
mnemonics=mnemonics,
version=version,
workchain=0
)
# Issue: tonsdk does not support WalletVersionEnum.v5r1
What libraries or methods can I use to work with v5r1? If tonsdk doesn’t support it, how can I manually send transactions with the required format?
I’m developing a Python application where I need to send transactions using wallet version v5r1 (TON blockchain). The primary requirement is to implement multi-send transactions, which is supported in this wallet version.
I’m using the tonsdk library, but it doesn’t seem to natively support v5r1. Here’s what I need to achieve:
Create transaction messages using the v5r1 wallet format. Send
multiple transactions in a single batch (multi-send).
What steps or libraries can I use to accomplish this? Are there any examples or alternative approaches? Additionally, I’d appreciate guidance on how to properly handle SEQNO for v5r1 wallets.
Here’s an example of the code I’ve tried (based on other wallet versions):
from tonsdk.contract.wallet import Wallets, WalletVersionEnum
from tonsdk.utils import to_nano
mnemonics = "my seed phrase here".split(" ")
version = WalletVersionEnum.v5r1 # Targeted version
# Key and wallet generation
mnemonics, pub_k, priv_k, wallet = Wallets.from_mnemonics(
mnemonics=mnemonics,
version=version,
workchain=0
)
# Issue: tonsdk does not support WalletVersionEnum.v5r1
What libraries or methods can I use to work with v5r1? If tonsdk doesn’t support it, how can I manually send transactions with the required format?
Share Improve this question asked Nov 20, 2024 at 17:36 koolaa12koolaa12 395 bronze badges1 Answer
Reset to default 0I resolved my issue with sending multi-transactions and using v5 wallets (WalletV5R1) by leveraging the tonutils library. The key was utilizing the batch_transfer method, which supports handling multiple transactions in one operation.
Here’s how I implemented it:
from tonutils.wallet.data import TransferData
from tonutils.client import ToncenterClient
from tonutils.wallet import WalletV5R1
async def main(recipient_address, amount, payload) -> None:
# Initialize Toncenter client
client = ToncenterClient(api_key=settings.API_KEY, is_testnet=False)
# Create a WalletV5R1 instance from mnemonic
wallet, public_key, private_key, mnemonic = WalletV5R1.from_mnemonic(client, [settings.SENDER_SEED_PHRASE])
# Prepare a list of transfer data
data_list = []
data_list.append(
TransferData(
destination=recipient_address,
amount=amount,
body=payload,
)
)
# Send a batch of transactions
tx_hash = await wallet.batch_transfer(
data_list=data_list
)
# Log success
logger.info("Successfully transferred!")
logger.info(f"Transaction hash: {tx_hash}")
本文标签:
版权声明:本文标题:blockchain - How to send transactions using wallet version v5r1 and implement multi-send in Python? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742340411a2456488.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论