2

I would like to create transaction using IotaWallet of wallet.rs containing a message or tag.

Currently I perfectly create a transaction for Alice wallet, using:

from iota_wallet import IotaWallet

# This example sends a transaction.

wallet = IotaWallet('./alice-database', client_options)

account = wallet.get_account('Alice')

# Sync account with the node
response = account.sync()
print(f'Synced: {response}')

wallet.set_stronghold_password("some_hopefully_secure_password")

options = {
        "message": "abc",
        #OR
        "tag": "abc"
}

outputs = [{
        "address": "tst1qprutadk4uc9rp6h7wh7sech42sl0z40ztpgyygr5tf0cn5jrqshg80juhm",
        "amount": "1"
}]


transaction = account.send_micro_transaction(outputs, options)
#OR
#transaction = account.send_amount(outputs, options)

print(f'Sent transaction: {transaction}') 

But there is no trace of "Message" or "Tag" related to the created transaction in the IOTA explorer or starting from account.transacations() or account.pending_transactions() methods.

In documentation examples I don't find anything.

Thank you for your help!

2 Answers 2

2

You can do something like:

outputs = [{
    "address": "rms1qqvnuxck92uwvf2hjpr0m9m0rj565efvchcy0xj9u5w8cwprqealva8g48e",
    "amount": "42600",
}]

tag = '0x'+'custom_tag'.encode('utf-8').hex()
data = '0x'+'custom_data'.encode('utf-8').hex()

transaction = account.send_amount(outputs, options={"taggedDataPayload": {"type": 5, "tag": tag, "data": data}})

This will create a block with a tagged payload. I created the example transaction: https://explorer.shimmer.network/testnet/transaction/0xb04a92b0e8bc52a4a2d85dd538f23c2201aa899d554428925f3ddf94b72a30ee?tab=Payload

And in the related block: https://explorer.shimmer.network/testnet/block/0xa0a69edc125eef56775185cd55a8ef9d96264d79f996047eff8e410aedee3b2b

you can find the added tagged data payload

2
  • 1
    Thank you so much Dr. Electon! Your solution is correctly working. Where can I find any reference about that please? In particular "type": 5. May 16 at 7:26
  • 2
    The payload types are documented in the TIPs: wiki.iota.org/tips/tips/TIP-0024/#payloads But you shouldn't need to know that, that's why we are working on improving the DX there in a future release May 18 at 7:27
2

There are several ways to do this, but please note that tag is not indexed by the core API anymore:

  1. You can write something like this: sendMicroTransaction(outputs, transactionOptions). Reference Wiki. You can add taggedatapayload to transactionOptions and it should tag it. Example in Explorer. Read more about TransactionOptions on wiki.

  2. With Stardust, you can also add data to the outputs now.

2
  • Thanks for answer, but Python Reference Wiki is less simple than yours attached in Node.js. There is not a TransactionOptions interface, but just a parameter and it doesn't work. May 15 at 14:51
  • It should ideally be same with options. If it's not working, please raise an issue in wallet.rs repo.
    – Ani
    May 15 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.