Question related to group transactions

Hi everyone, I wonder if the transaction order of a group orders is based on the groupIndex. Also, if I used txn Fee in the contract for a group order function, does it refer to the txn 0? Or does the txn refer to the first transaction that sender is lsig.

TYSM!

Welcome to Algorand!

When you create a group, you specify the order of the transactions.
The groupIndex is implicitly derived from this order.

For example, if you group txA, txB, txC in this order. Then txA has groupIndex 0, txB has groupIndex 1, and txC has groupIndex 2.

txn always refers to the current transaction executing the smart contract/smart signature.
So if you have a group of 3 application call transactions tx0, tx1, tx2:

  • in the application call tx0, then txn corresponds to tx0
  • in the application call tx1, then txn corresponds to tx1
  • in the application call tx2, then txn corresponds to tx2

No.

But also note that lsig or smart signatures are really reserved for advanced use cases nowadays. Most dApps would only use smart contracts and the sender can be any account (including a smart signature account but this is another story).

Thank you for the detailed response, Fabrice. Iā€™m still having some questions about the field Fee and pay . The doc says ā€™ Pooled transaction fees - One transaction pays the fees of others.ā€™, but how can we specify which transaction in the group pays all fee. Also, if I would like to make sure that all transactions sent by lsig never pays fees, what checks can I made to ensure that? Your help is really appreciated.

The only thing that matters is that the sum of all the fees of all the transactions is sufficient.
See the thread Cannot calculate suggested fees for inner transactions for details

Disclaimer: I did not test the code below.

In TEAL:

txn Fee
int 0
==
assert

in PyTEAL:

Assert(Txn.fee() == Int(0))