You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks to the gtxns and gtxnsa opcodes, TEAL programs can dynamically index into the group transaction array to access any transaction's fields.
However, it is not currently possible to dynamically index into the array fields of a specific transaction (ApplicationArgs, Accounts, etc.). This is a useful feature in general, and specifically it needs to be added in order to support foreign arrays like algorandfoundation/ARCs#7 proposes.
Solution
Introduce 3 new opcodes:
txnas like txna, but it takes the array index as a stack arg. Usage: int <array-index>; txnas ApplicationArgs
gtxnas like gtxna, but it takes the array index as a stack arg. Usage: int <array-index>; gtxnas <gtxn-index> ApplicationArgs
gtxnsas like gtxnsa, but it takes the array index as an additional stack arg. Usage: int <gtxn-index>; int <array-index>; gtxnsas ApplicationArgs
Adding all 3 opcodes might be overkill (we may want to drop gtxnas), but I've listing them all for completeness.
Dependencies
This would also require PyTeal support.
Urgency
This should make it into TEAL 5.
The text was updated successfully, but these errors were encountered:
Problem
Thanks to the
gtxns
andgtxnsa
opcodes, TEAL programs can dynamically index into the group transaction array to access any transaction's fields.However, it is not currently possible to dynamically index into the array fields of a specific transaction (
ApplicationArgs
,Accounts
, etc.). This is a useful feature in general, and specifically it needs to be added in order to support foreign arrays like algorandfoundation/ARCs#7 proposes.Solution
Introduce 3 new opcodes:
txnas
liketxna
, but it takes the array index as a stack arg. Usage:int <array-index>; txnas ApplicationArgs
gtxnas
likegtxna
, but it takes the array index as a stack arg. Usage:int <array-index>; gtxnas <gtxn-index> ApplicationArgs
gtxnsas
likegtxnsa
, but it takes the array index as an additional stack arg. Usage:int <gtxn-index>; int <array-index>; gtxnsas ApplicationArgs
Adding all 3 opcodes might be overkill (we may want to drop
gtxnas
), but I've listing them all for completeness.Dependencies
This would also require PyTeal support.
Urgency
This should make it into TEAL 5.
The text was updated successfully, but these errors were encountered: