I’ve been reviewing the ARC-04 Algorand Transaction Calling Conventions (which is awesome by the way). I was hoping for some clarification around transaction order in atomic transactions. The convention states:
Arguments of these types are encoded as consecutive transactions in the same transaction group as the Application call, placed in the position immediately preceding the Application call.
I have some TEAL code that checks the balance of the contract account of the same contract that is being called, as part of its validation logic. If I place the pay
transaction before the appl
transaction in the group, I get an incorrect reading on the balance (presumably because that transaction has occurred first). I don’t get the same issue when I switch the order.
This is the same case for axfer
transactions. So I have been placing my axfer
and pay
transactions at the end of the atomic transaction array, but I am now seeing that this is not best practice.
What should I do in this case without submitting two consecutive transactions? Ideally I’d like the pay
or axfer
transactions to fail if the logic in the appl
transaction fails.