最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论