blockchain - How to send transactions using wallet version v5r1 and implement multi-send in Python? - Stack Overflow

I’m developing a Python application where I need to send transactions using wallet version v5r1 (TON bl

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:

  1. Create transaction messages using the v5r1 wallet format. Send

  2. 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:

  1. Create transaction messages using the v5r1 wallet format. Send

  2. 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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

I 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}")

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742340411a4425512.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信