PyTeal transaction fields


I’m wondering about the difference between some of PyTeal’s transaction fields.

PyTeal’s transaction fields include:
Txn.sender() as well as Txn.asset_sender()
Txn.receiver() as well as Txn.asset_receiver()
(and many other almost duplicates)

When the transaction itself is an AssetTransferTxn, is there any difference between these fields? The AssetTransferTxn object has a sender attribute, but not an asset_sender attribute, so what is PyTeal accessing when I call Txn.asset_sender()?

I tried a few tests, and Assert(Txn.sender() == Txn.asset_sender()) always seems to pass. If the transaction itself is an AssetTransferTxn are the fields equivalent?


  • Txn.sender() is defined for all transactions, it is the sender of the transaction, that is the account that signs the transaction.
  • Txn.asset_sender() is only used in case Txn.sender() is the clawback address and the transaction is an ASA clawback/revoking transaction (see Algorand Developer Docs). I am very surprised that Assert(Txn.sender() == Txn.asset_sender()) actually passes. It should almost never pass (the only case where it should pass is a clawback transaction from the clawback address, which is not a useful transaction).
  • Txn.receiver() is only for payment transactions in Algos.
  • Txn.asset_receiver() is for transfer of ASA.
1 Like

Thanks! That’s very helpful.

You’re correct about the Assertion failing. I re-tested the Assert(Txn.sender() == Txn.asset_sender()) and it does fail as you suggested. In some of my earlier tests, I had bypassed the block of code with those Assert statements, so they weren’t being run at all.