Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

$$ \newcommand \App {\mathrm{App}} \newcommand \MaxAppTotalTxnReferences {\App_{r,\max}} \newcommand \MaxExtraAppProgramPages {\App_{\mathrm{page},\max}} \newcommand \MaxAppProgramLen {\App_{\mathrm{prog},\max}} \newcommand \MaxGlobalSchemaEntries {\App_{\mathrm{GS},\max}} \newcommand \MaxLocalSchemaEntries {\App_{\mathrm{LS},\max}} \newcommand \MaxAppArgs {\App_{\mathrm{arg},\max}} \newcommand \MaxAppTotalArgLen {\App_{\mathrm{ay},\max}} \newcommand \MaxAppTxnAccounts {\App_{\mathrm{acc},\max}} \newcommand \MaxAppTxnForeignApps {\App_{\mathrm{app},\max}} \newcommand \MaxAppTxnForeignAssets {\App_{\mathrm{asa},\max}} \newcommand \MaxAppAccess {\App_{\mathrm{access},\max}} \newcommand \Box {\mathrm{Box}} \newcommand \MaxAppBoxReferences {\App_{\Box,\max}} \newcommand \MaxAppKeyLen {\App_{\mathrm{k},\max}} $$

Application Call Transaction

Fields

An application call transaction additionally has the following fields:

FIELDCODECTYPEREQUIRED
Application IDapiduint64Yes (except for Creation)
On Completion Actionapanuint64Yes
Approval Programapap[]byteNo
Clear State Programapsu[]byteNo
Reject Versionaprvuint64No
Extra Program Pagesapepuint64No
Global State SchemaapgsstructNo
Local State SchemaaplsstructNo
Argumentsapaa[][]byteNo
Foreign Accountsapat[]addressNo
Foreign Applicationsapfa[]uint64No
Foreign Assetsapas[]uint64No
Box Referencesapbx[]structNo
Access Listal[]structNo

The sum of the elements in foreign accounts (apat), foreign applications (apfa), foreign assets (apas), and box references (apbx) MUST NOT exceed \( \MaxAppTotalTxnReferences \).

Application ID

The application ID identifies the application being called.

If the application ID is omitted (zero), this transaction is creating an application.

On Completion Action

The on completion action specifies an additional effect of this transaction on the application’s state in the sender or application creator’s account data.

The apan field values are enumerated as follows:

ACTIONVALUEEFFECT
NoOpOC0Only execute the Approval Program associated with this application ID, with no additional effects.
OptInOC1Before executing the Approval Program, allocate local state for this application ID into the sender’s account data.
CloseOutOC2After executing the Approval Program, clear any local state for this application ID out of the sender’s account data.
ClearStateOC3Do not execute the Approval Program, and instead execute the Clear State Program (which may not reject this transaction). Additionally, clear any local state for this application ID out of the sender’s account data (as in CloseOutOC).
UpdateApplicationOC4After executing the Approval Program, replace the Approval Program and Clear State Program associated with this application ID with the programs specified in this transaction.
DeleteApplicationOC5After executing the Approval Program, delete the parameters of with this application ID from the account data of the application’s creator.

Approval Program

The approval program (OPTIONAL) contains the approval program bytecode.

This field is used for application creation and updates, and sets the corresponding application’s Approval Program.

Clear State Program

The clear state program (OPTIONAL) contains the clear state program bytecode.

This field is used for application creation and updates, and sets the corresponding application’s Clear State Program.

  • The Approval Program and the Clear State Program MUST have the same version number if either is \( 6 \) or higher.

Reject Version

The reject version (OPTIONAL), if set to a positive number, specifies that the application call MUST fail unless the reject version value exceeds the Application Version.

For further details on Application Versions, refer to the Applications Specifications.

Extra Program Pages

A program page (OPTIONAL) is a chunk of application program bytecode. The extra program pages define the number of program pages besides the first one.

This field is only used during application creation, and requests an increased maximum size for the Approval Program or Clear State Program.

  • There MUST NOT be more than \( \MaxExtraAppProgramPages \) extra program pages,

  • The program page byte length MUST NOT exceed \( \MaxAppProgramLen \).

Global State Schema

The global state schema (OPTIONAL) defines the global state allocated into the creator account that of the application ID.

The global state schema is a structure containing:

FIELDCODECTYPEDESCRIPTION
Number of Uintsnuiuint64The number of global 64-bit unsigned integer variables for the application.
Number of Bytesnbsuint64The number of global byte-array variables for the application.

This field is only used during application creation, and sets bounds on the size of the global state associated with this application.

  • There MUST NOT be more than \( \MaxGlobalSchemaEntries \) global variables for the application.

TODO: Restrictions on key-value lengths

Local State Schema

The local state schema (OPTIONAL) defines the local state allocated into the accounts that opt-in the application ID.

The local state schema is a structure containing:

FIELDCODECTYPEDESCRIPTION
Number of Uintsnuiuint64The number of local 64-bit unsigned integer variables for the application.
Number of Bytesnbsuint64The number of local byte-array variables for the application.

This field is only used during application creation, and sets bounds on the size of the local state for accounts that opt in to this application.

  • There MUST NOT be more than \( \MaxLocalSchemaEntries \) local variables for the application.

TODO: Restrictions on key-value lengths

Arguments

The application arguments (OPTIONAL) list provides byte-array arguments to the application being called.

  • There MUST NOT be more than \( \MaxAppArgs \) entries in this list,

  • The sum of their byte lengths MUST NOT exceed \( \MaxAppTotalArgLen \).

Foreign Accounts

The foreign accounts (OPTIONAL) list specifies the accounts, besides the sender, whose local states MAY be referred to by executing the Approval Program or the Clear State Program. These accounts are referred to by their 32-byte addresses.

  • There MUST NOT be more than \( \MaxAppTxnAccounts \) entries in this list.

Foreign Applications

The foreign applications (OPTIONAL) list specifies the application IDs, besides the application whose Approval Program or Clear State Program is executing, that the executing program MAY read global state from. These applications are referred to by their 64-bit unsigned integer IDs.

  • There MUST NOT be more than \( \MaxAppTxnForeignApps \) entries in this list.

Foreign Assets

The foreign assets (OPTIONAL) list specifies the asset IDs from which the executing Approval Program or Clear State Program MAY read asset parameters. These assets are referred to by their 64-bit unsigned integer IDs.

  • There MUST NOT be more than \( \MaxAppTxnForeignAssets \) entries in this list.

Box References

The box references (OPTIONAL) list specifies the boxes that the executing Approval Program (with AVM Version 9 or later), or any other Approval Program in the same group, MAY access for reading or writing when the box reference matches the running program application IDs.

For further details on AVM resource availability, refer to the AVM Specifications.

Each element of the box reference encodes a structure containing:

FIELDCODECTYPEDESCRIPTION
Indexiuint64A \( 1 \)-based index in the foreign applications (apfa) list.
Namen[]byteThe box identifier.

An omitted index (i) is interpreted as the application ID of this transaction (apid, or the ID allocated for the created application when apid is \( 0 \)).

  • There MUST NOT be more than \( \MaxAppBoxReferences \) entries in this list.

  • The box name byte length MUST NOT exceed \( \MaxAppKeyLen \).

Access List

The access list (OPTIONAL) specifies resources (accounts, application IDs, asset IDs, and box references) that the executing Approval Program (with AVM Version 9 or later), or any other Approval Program in the same group, MAY access for reading or writing.

For further details on AVM resource availability, refer to the AVM Specifications.

Each element of the access list encodes one of the following resources:

FIELDCODECTYPEDESCRIPTION
Addressd[]byteAn Account
Assetsuint64An Asset ID
Applicationpuint64An Application ID
HoldinghstructA Holding contains subfields d and s that refer to the Address and Asset of the Holding, respectively.
LocalslstructA Local contains subfields d and p that refer to the Address and Application of the Local State, respectively.
Box ReferencebstructA Box Reference contains subfields i and n, that refer to the Application and Box Name, respectively.

The subfields of h, l, b refer to Accounts, Assets, and Applications by using an \( 1 \)-based index into the Access List.

An omitted d indicates the sender of the transaction.

An omitted app (p or i) indicates the called Application.

The access list MUST be empty if any of the foreign arrays (apat, apfa, apas), or box reference list (apbx) fields are populated.

  • There MUST NOT be more than \( \MaxAppAccess \) entries in this list.

Validation

TODO

Semantic

TODO