Skip to content

Wallet Operations

This section provides a complete guide to managing wallets using the tonutils library. It covers key operations such as:

  • Creating and deploying wallets
  • Importing wallets from mnemonic or private key
  • Sending transactions (TON, NFTs, Jettons)
  • Performing batch transfers
  • Executing Jetton swaps (via STON.fi and DeDust.io)

Supported Wallet

The library supports multiple wallet versions and types:

  • Standard wallets: WalletV2R1, WalletV2R2, WalletV3R1, WalletV3R2, WalletV4R1, WalletV4R2, WalletV5R1
  • Highload wallets (for services and exchanges): HighloadWalletV2, HighloadWalletV3
  • Preprocessed wallets (for economical batch operations): PreprocessedWalletV2, PreprocessedWalletV2R1

Recommendations

  • For general use, it’s recommended to work with wallet versions v3r2 to v5r1, preferably v5r1 for full feature support.
  • For service and exchange integrations, use HighloadWalletV3.
  • For large-scale batch transfers where gas optimization is critical, use PreprocessedWallet types.

Create Wallet

To create a new wallet, use the .create() method provided by the wallet class you select. This generates a wallet instance along with its public key, private key, and mnemonic phrase.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import (
    # Uncomment the following lines to use different wallet versions:
    # WalletV2R1,
    # WalletV2R2,
    # WalletV3R1,
    # WalletV3R2,
    # WalletV4R1,
    WalletV4R2,
    # WalletV5R1,
    # HighloadWalletV2,
    # HighloadWalletV3,
    # PreprocessedWalletV2,
    # PreprocessedWalletV2R1,
)

# Set to True for test network, False for main network
IS_TESTNET = True


def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, public_key, private_key, mnemonic = WalletV4R2.create(client)

    # Uncomment and use the following lines to create different wallet versions:
    # wallet, public_key, private_key, mnemonic = WalletV3R2.create(client)
    # wallet, public_key, private_key, mnemonic = WalletV4R1.create(client)
    # wallet, public_key, private_key, mnemonic = WalletV4R2.create(client)
    # wallet, public_key, private_key, mnemonic = WalletV5R1.create(client)
    # wallet, public_key, private_key, mnemonic = HighloadWalletV2.create(client)
    # wallet, public_key, private_key, mnemonic = HighloadWalletV3.create(client)
    # wallet, public_key, private_key, mnemonic = PreprocessedWalletV2.create(client)
    # wallet, public_key, private_key, mnemonic = PreprocessedWalletV2R1.create(client)

    print("Wallet has been successfully created!")
    print(f"Address: {wallet.address.to_str()}")
    print(f"Mnemonic: {mnemonic}")


if __name__ == "__main__":
    main()

Import Wallet

You can import a wallet either from a mnemonic phrase or directly from a private key.


From Mnemonic

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


def main() -> None:
    client = ToncenterV3Client()
    wallet, public_key, private_key, mnemonic = WalletV4R2.from_mnemonic(client, MNEMONIC)

    print(f"Wallet address: {wallet.address.to_str()}")


if __name__ == "__main__":
    main()

From Private Key

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2

# Private key (32 or 64 bytes)
PRIVATE_KEY: bytes = b"your_private_key_bytes"


def main() -> None:
    client = ToncenterV3Client()
    wallet = WalletV4R2.from_private_key(client, PRIVATE_KEY)

    print(f"Wallet address: {wallet.address.to_str()}")


if __name__ == "__main__":
    main()

Deploy Wallet

To deploy a wallet, reconstruct it from a mnemonic and call the .deploy() method. This will publish the wallet contract on-chain.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import (
    # Uncomment the following lines to use different wallet versions:
    # WalletV2R1,
    # WalletV2R2,
    # WalletV3R1,
    # WalletV3R2,
    # WalletV4R1,
    WalletV4R2,
    # WalletV5R1,
    # HighloadWalletV2,
    # HighloadWalletV3,
    # PreprocessedWalletV2,
    # PreprocessedWalletV2R1,
)

# Set to True for test network, False for main network
IS_TESTNET = True

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, public_key, private_key, mnemonic = WalletV4R2.from_mnemonic(client, MNEMONIC)

    # Uncomment and use the following lines to create different wallet versions from mnemonic:
    # wallet, public_key, private_key, mnemonic = WalletV2R1.from_mnemonic(client, MNEMONIC)
    # wallet, public_key, private_key, mnemonic = WalletV2R2.from_mnemonic(client, MNEMONIC)
    # wallet, public_key, private_key, mnemonic = WalletV3R2.from_mnemonic(client, MNEMONIC)
    # wallet, public_key, private_key, mnemonic = WalletV4R1.from_mnemonic(client, MNEMONIC)
    # wallet, public_key, private_key, mnemonic = WalletV4R2.from_mnemonic(client, MNEMONIC)
    # wallet, public_key, private_key, mnemonic = WalletV5R1.from_mnemonic(client, MNEMONIC)
    # wallet, public_key, private_key, mnemonic = HighloadWalletV2.from_mnemonic(client, MNEMONIC)
    # wallet, public_key, private_key, mnemonic = HighloadWalletV3.from_mnemonic(client, MNEMONIC)
    # wallet, public_key, private_key, mnemonic = PreprocessedWalletV2.from_mnemonic(client, MNEMONIC)
    # wallet, public_key, private_key, mnemonic = PreprocessedWalletV2R1.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.deploy()

    print(f"Wallet deployed successfully!")
    print(f"Wallet address: {wallet.address.to_str()}")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Transfers

Send TON

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2

# Set to True for test network, False for main network
IS_TESTNET = True

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."

# The address of the recipient
DESTINATION_ADDRESS = "UQ..."

# Optional comment to include in the forward payload
COMMENT = "Hello from tonutils!"

# Amount to transfer in TON
AMOUNT = 0.01


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, public_key, private_key, mnemonic = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.transfer(
        destination=DESTINATION_ADDRESS,
        amount=AMOUNT,
        body=COMMENT,
    )

    print(f"Successfully transferred {AMOUNT} TON!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Send NFT

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import TransferNFTMessage

# Set to True for test network, False for main network
IS_TESTNET = True

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."

# Address of the NFT to be transferred and the new owner address
NFT_ADDRESS = "EQ..."
NEW_OWNER_ADDRESS = "UQ..."

# Optional comment to include in the forward payload
COMMENT = "Hello from tonutils!"


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, public_key, private_key, mnemonic = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.transfer_message(
        message=TransferNFTMessage(
            destination=NEW_OWNER_ADDRESS,
            nft_address=NFT_ADDRESS,
            forward_payload=COMMENT,
        ),
    )

    print("Successfully transferred!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Send Jetton

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import TransferJettonMessage

# Set to True for the test network, False for the main network
IS_TESTNET = True

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."

# The address of the Jetton Master contract
JETTON_MASTER_ADDRESS = "EQ..."

# Number of decimal places for the Jetton
JETTON_DECIMALS = 9

# Amount of Jettons to transfer (in base units, considering decimals)
JETTON_AMOUNT = 0.01

# The address of the recipient
DESTINATION_ADDRESS = "UQ..."

# Comment to include in the transfer payload
COMMENT = "Hello from tonutils!"


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, public_key, private_key, mnemonic = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.transfer_message(
        message=TransferJettonMessage(
            destination=DESTINATION_ADDRESS,
            jetton_master_address=JETTON_MASTER_ADDRESS,
            jetton_amount=JETTON_AMOUNT,
            jetton_decimals=JETTON_DECIMALS,
            forward_payload=COMMENT,
        ),
    )

    print(f"Successfully transferred {JETTON_AMOUNT} jettons!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Batch Transfers

Batch Send TON

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import TransferMessage

# Set to True for test network, False for main network
IS_TESTNET = True

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, public_key, private_key, mnemonic = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.batch_transfer_messages(
        messages=[
            TransferMessage(
                destination="UQ...",
                amount=0.01,
                body="Hello from tonutils!",
            ),
            TransferMessage(
                destination="UQ...",
                amount=0.01,
                body="Hello from tonutils!",
            ),
            TransferMessage(
                destination="UQ...",
                amount=0.01,
                body="Hello from tonutils!",
            ),
            TransferMessage(
                destination="UQ...",
                amount=0.01,
                body="Hello from tonutils!",
            ),
        ]
    )

    print("Successfully transferred!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Batch Send NFT

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import TransferNFTMessage

# Set to True for test network, False for main network
IS_TESTNET = True

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, public_key, private_key, mnemonic = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.batch_transfer_messages(
        messages=[
            TransferNFTMessage(
                destination="UQ...",
                nft_address="EQ..",
                forward_payload="Hello from tonutils!",
            ),
            TransferNFTMessage(
                destination="UQ...",
                nft_address="EQ..",
                forward_payload="Hello from tonutils!",
            ),
            TransferNFTMessage(
                destination="UQ...",
                nft_address="EQ..",
                forward_payload="Hello from tonutils!",
            ),
            TransferNFTMessage(
                destination="UQ...",
                nft_address="EQ..",
                forward_payload="Hello from tonutils!",
            )
        ]
    )

    print("Successfully transferred!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Batch Send Jetton

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import TransferJettonMessage

# Set to True for test network, False for main network
IS_TESTNET = True

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, public_key, private_key, mnemonic = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.batch_transfer_messages(
        messages=[
            TransferJettonMessage(
                destination="UQ...",
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
                forward_payload="Hello from tonutils!",
            ),
            TransferJettonMessage(
                destination="UQ...",
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
                forward_payload="Hello from tonutils!",
            ),
            TransferJettonMessage(
                destination="UQ...",
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
                forward_payload="Hello from tonutils!",
            ),
            TransferJettonMessage(
                destination="UQ...",
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
                forward_payload="Hello from tonutils!",
            ),
        ]
    )

    print("Successfully transferred!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Jetton Swaps

Using STON.fi

Swap TON → Jetton

Note

Before using these instructions, please consult the official documentation of STON.fi. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import StonfiSwapTONToJettonMessage

# Set to True for the test network, False for the main network
IS_TESTNET = False

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."

# Address of the Jetton Master for swapping (TON > USD₮)
TO_JETTON_MASTER_ADDRESS = "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs"  # noqa

# Number of decimal places for the Jetton
JETTON_DECIMALS = 9

# Amount of TON to swap (in TON)
SWAP_TON_AMOUNT = 1


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.transfer_message(
        message=StonfiSwapTONToJettonMessage(
            jetton_master_address=TO_JETTON_MASTER_ADDRESS,
            ton_amount=SWAP_TON_AMOUNT,
            jetton_decimals=JETTON_DECIMALS,
        ),
    )

    print("Successfully swapped TON to Jetton!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Swap Jetton → TON

Note

Before using these instructions, please consult the official documentation of STON.fi. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import StonfiSwapJettonToTONMessage

# Set to True for the test network, False for the main network
IS_TESTNET = False

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."

# Address of the Jetton Master for swapping (TON > USD₮)
TO_JETTON_MASTER_ADDRESS = "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs"  # noqa

# Number of decimal places for the Jetton
JETTON_DECIMALS = 9

# Amount of Jettons to swap (in base units, considering decimals)
JETTON_AMOUNT = 1


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.transfer_message(
        message=StonfiSwapJettonToTONMessage(
            jetton_master_address=TO_JETTON_MASTER_ADDRESS,
            jetton_amount=JETTON_AMOUNT,
            jetton_decimals=JETTON_DECIMALS,
        ),
    )

    print("Successfully swapped Jetton to TON!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Swap Jetton → Jetton

Note

Before using these instructions, please consult the official documentation of STON.fi. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import StonfiSwapJettonToJettonMessage

# Set to True for the test network, False for the main network
IS_TESTNET = False

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."

# Addresses of the Jetton Masters for swapping
FROM_JETTON_MASTER_ADDRESS = "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs"  # noqa
TO_JETTON_MASTER_ADDRESS = "EQAvlWFDxGF2lXm67y4yzC17wYKD9A0guwPkMs1gOsM__NOT"  # noqa

# Number of decimal places for the Jetton
FROM_JETTON_DECIMALS = 6
TO_JETTON_DECIMALS = 9

# Amount of Jettons to swap (in base units, considering decimals)
JETTON_AMOUNT = 1


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.transfer_message(
        message=StonfiSwapJettonToJettonMessage(
            from_jetton_master_address=FROM_JETTON_MASTER_ADDRESS,
            to_jetton_master_address=TO_JETTON_MASTER_ADDRESS,
            jetton_amount=JETTON_AMOUNT,
            from_jetton_decimals=FROM_JETTON_DECIMALS,
            to_jetton_decimals=TO_JETTON_DECIMALS,
        ),
    )

    print("Successfully swapped Jetton to Jetton!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Batch Swap TON → Jetton

Note

Before using these instructions, please consult the official documentation of STON.fi. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import StonfiSwapTONToJettonMessage

# Set to True for the test network, False for the main network
IS_TESTNET = False

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.batch_transfer_messages(
        messages=[
            StonfiSwapTONToJettonMessage(
                jetton_master_address="EQ...",
                ton_amount=0.01,
                jetton_decimals=9,
            ),
            StonfiSwapTONToJettonMessage(
                jetton_master_address="EQ...",
                ton_amount=0.01,
                jetton_decimals=9,
            ),
            StonfiSwapTONToJettonMessage(
                jetton_master_address="EQ...",
                ton_amount=0.01,
                jetton_decimals=9,
            ),
            StonfiSwapTONToJettonMessage(
                jetton_master_address="EQ...",
                ton_amount=0.01,
                jetton_decimals=9,
            ),
        ],
    )

    print("Successfully swapped TON to Jetton!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Batch Swap Jetton → TON

Note

Before using these instructions, please consult the official documentation of STON.fi. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import StonfiSwapJettonToTONMessage

# Set to True for the test network, False for the main network
IS_TESTNET = False

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


async def main() -> None:
    client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=1, max_retries=1)
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.batch_transfer_messages(
        messages=[
            StonfiSwapJettonToTONMessage(
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
            ),
            StonfiSwapJettonToTONMessage(
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
            ),
            StonfiSwapJettonToTONMessage(
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
            ),
            StonfiSwapJettonToTONMessage(
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
            ),
        ],
    )

    print("Successfully swapped TON to Jetton!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Batch Swap Jetton → Jetton

Note

Before using these instructions, please consult the official documentation of STON.fi. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import StonfiSwapJettonToJettonMessage

# Set to True for the test network, False for the main network
IS_TESTNET = False

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


async def main() -> None:
    client = ToncenterV3Client()
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.batch_transfer_messages(
        messages=[
            StonfiSwapJettonToJettonMessage(
                from_jetton_master_address="EQ...",
                to_jetton_master_address="EQ...",
                jetton_amount=0.01,
                from_jetton_decimals=9,
                to_jetton_decimals=9,
            ),
            StonfiSwapJettonToJettonMessage(
                from_jetton_master_address="EQ...",
                to_jetton_master_address="EQ...",
                jetton_amount=0.01,
                from_jetton_decimals=9,
                to_jetton_decimals=9,
            ),
            StonfiSwapJettonToJettonMessage(
                from_jetton_master_address="EQ...",
                to_jetton_master_address="EQ...",
                jetton_amount=0.01,
                from_jetton_decimals=9,
                to_jetton_decimals=9,
            ),
            StonfiSwapJettonToJettonMessage(
                from_jetton_master_address="EQ...",
                to_jetton_master_address="EQ...",
                jetton_amount=0.01,
                from_jetton_decimals=9,
                to_jetton_decimals=9,
            ),
        ],
    )

    print("Successfully swapped TON to Jetton!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Using DeDust.io

Swap TON → Jetton

Note

Before using these instructions, please consult the official documentation of DeDust.io. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import DedustSwapTONToJettonMessage

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."

# Address of the Jetton Master contract
JETTON_MASTER_ADDRESS = "EQ..."

# Number of decimal places for the Jetton
JETTON_DECIMALS = 9

# Amount of TON to swap (in TON)
SWAP_TON_AMOUNT = 1


async def main() -> None:
    client = ToncenterV3Client()
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.transfer_message(
        message=DedustSwapTONToJettonMessage(
            jetton_master_address=JETTON_MASTER_ADDRESS,
            ton_amount=SWAP_TON_AMOUNT,
            jetton_decimals=JETTON_DECIMALS,
        ),
    )

    print("Successfully swapped TON to Jetton!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Swap Jetton → TON

Note

Before using these instructions, please consult the official documentation of DeDust.io. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import DedustSwapJettonToTONMessage

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."

# Address of the Jetton Master contract
JETTON_MASTER_ADDRESS = "EQ..."

# Number of decimal places for the Jetton
JETTON_DECIMALS = 9

# Amount of Jettons to swap (in base units, considering decimals)
JETTON_AMOUNT = 1


async def main() -> None:
    client = ToncenterV3Client()
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.transfer_message(
        message=DedustSwapJettonToTONMessage(
            jetton_master_address=JETTON_MASTER_ADDRESS,
            jetton_amount=JETTON_AMOUNT,
            jetton_decimals=JETTON_DECIMALS,
        ),
    )

    print("Successfully swapped Jetton to TON!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Swap Jetton → Jetton

Note

Before using these instructions, please consult the official documentation of DeDust.io. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import DedustSwapJettonToJettonMessage

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."

# Addresses of the Jetton Masters for swapping
FROM_JETTON_MASTER_ADDRESS = "EQ..."
TO_JETTON_MASTER_B_ADDRESS = "EQ..."

# Number of decimal places for the Jetton
FROM_JETTON_DECIMALS = 9
TO_JETTON_DECIMALS = 9

# Amount of Jettons to swap (in base units, considering decimals)
JETTON_AMOUNT = 1


async def main() -> None:
    client = ToncenterV3Client()
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.transfer_message(
        message=DedustSwapJettonToJettonMessage(
            from_jetton_master_address=FROM_JETTON_MASTER_ADDRESS,
            to_jetton_master_address=TO_JETTON_MASTER_B_ADDRESS,
            jetton_amount=JETTON_AMOUNT,
            from_jetton_decimals=FROM_JETTON_DECIMALS,
            to_jetton_decimals=TO_JETTON_DECIMALS,
        ),
    )

    print("Successfully swapped Jetton to Jetton!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Batch Swap TON → Jetton

Note

Before using these instructions, please consult the official documentation of DeDust.io. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import DedustSwapTONToJettonMessage

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


async def main() -> None:
    client = ToncenterV3Client()
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.batch_transfer_messages(
        messages=[
            DedustSwapTONToJettonMessage(
                jetton_master_address="EQ...",
                ton_amount=0.01,
                jetton_decimals=9,
            ),
            DedustSwapTONToJettonMessage(
                jetton_master_address="EQ...",
                ton_amount=0.01,
                jetton_decimals=9,
            ),
            DedustSwapTONToJettonMessage(
                jetton_master_address="EQ...",
                ton_amount=0.01,
                jetton_decimals=9,
            ),
            DedustSwapTONToJettonMessage(
                jetton_master_address="EQ...",
                ton_amount=0.01,
                jetton_decimals=9,
            ),
        ]
    )

    print("Successfully swapped TON to Jetton!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Batch Swap Jetton → TON

Note

Before using these instructions, please consult the official documentation of DeDust.io. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import DedustSwapJettonToTONMessage

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


async def main() -> None:
    client = ToncenterV3Client()
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.batch_transfer_messages(
        messages=[
            DedustSwapJettonToTONMessage(
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
            ),
            DedustSwapJettonToTONMessage(
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
            ),
            DedustSwapJettonToTONMessage(
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
            ),
            DedustSwapJettonToTONMessage(
                jetton_master_address="EQ...",
                jetton_amount=0.01,
                jetton_decimals=9,
            ),
        ]
    )

    print("Successfully swapped TON to Jetton!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Batch Swap Jetton → Jetton

Note

Before using these instructions, please consult the official documentation of DeDust.io. Use with caution and always test carefully on a testnet first. I take no responsibility for any lost funds. If you find errors or have suggestions for improvement, feel free to open a pull request — let’s make this better together.

from tonutils.client import ToncenterV3Client
from tonutils.wallet import WalletV4R2
from tonutils.wallet.messages import DedustSwapJettonToJettonMessage

# Mnemonic phrase
MNEMONIC = "word1 word2 word3 ..."


async def main() -> None:
    client = ToncenterV3Client()
    wallet, _, _, _ = WalletV4R2.from_mnemonic(client, MNEMONIC)

    tx_hash = await wallet.batch_transfer_messages(
        messages=[
            DedustSwapJettonToJettonMessage(
                from_jetton_master_address="EQ...",
                to_jetton_master_address="EQ...",
                jetton_amount=0.01,
                from_jetton_decimals=9,
                to_jetton_decimals=9,
            ),
            DedustSwapJettonToJettonMessage(
                from_jetton_master_address="EQ...",
                to_jetton_master_address="EQ...",
                jetton_amount=0.01,
                from_jetton_decimals=9,
                to_jetton_decimals=9,
            ),
            DedustSwapJettonToJettonMessage(
                from_jetton_master_address="EQ...",
                to_jetton_master_address="EQ...",
                jetton_amount=0.01,
                from_jetton_decimals=9,
                to_jetton_decimals=9,
            ),
            DedustSwapJettonToJettonMessage(
                from_jetton_master_address="EQ...",
                to_jetton_master_address="EQ...",
                jetton_amount=0.01,
                from_jetton_decimals=9,
                to_jetton_decimals=9,
            ),
        ]
    )

    print("Successfully swapped TON to Jetton!")
    print(f"Transaction hash: {tx_hash}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())