Applications - Algorand Specifications

Algorand Specifications

Each account can create applications, each named by a globally-unique 64-bit unsigned integer (the application ID).

Applications are associated with a set of application parameters, which can be encoded as a msgpack struct:

Each application created increases the minimum balance requirement of the creator by Appcreate,bmin×(1+ExtraProgramPages)Appcreate,bmin×(1+ExtraProgramPages) μALGO, plus the GlobalStateSchema minimum balance contribution.

Each application opted in to increases the minimum balance requirements of the opting-in account by Appoptin,bminAppoptin,bmin μALGO plus the LocalStateSchema minimum balance contribution.

A Key/Value Store, or KV, is an associative array mapping keys of type byte-array to values of type byte-array or 64-bit unsigned integer.

The values in a KV are either:

The maximum length of a key in a KV is Appk,maxAppk,max bytes.

A state schema represents limits on the number of each value type that may appear in a Key/Value Store.

State schemas control the maximum size of global and local state KVs.

A state schema is composed of two fields:

When an account opts in to an application or creates an application, the minimum balance requirements for that account increases. The minimum balance requirement is decreased equivalently when an account closes out or deletes an app.

When opting in to an application, there is a base minimum balance increase of Appoptin,bminAppoptin,bmin μALGO. There is an additional minimum balance increase, in μALGO, based on the LocalStateSchema for that application, described by the following formula:

(Apps,bmin+Appu,bmin)×NumUint+(Apps,bmin+Appb,bmin)×NumByteSlice(Apps,bmin+Appu,bmin)×NumUint+(Apps,bmin+Appb,bmin)×NumByteSlice

When creating an application, there is a base minimum balance increase of Appcreate,bminAppcreate,bmin μALGO. There is an additional minimum balance increase of Appcreate,bmin×ExtraProgramPagesAppcreate,bmin×ExtraProgramPages μALGO. Finally, there is an additional minimum balance increase, in μALGO, based on the GlobalStateSchema for that application, described by the following formula:

(Apps,bmin+Appu,bmin)×NumUint+(Apps,bmin+Appb,bmin)×NumByteSlice(Apps,bmin+Appu,bmin)×NumUint+(Apps,bmin+Appb,bmin)×NumByteSlice

The Box store is an associative array mapping keys of type: (uint64 x []byte) to values of type []byte.

When an application executes an opcode that creates, resizes, or destroys a box, the minimum balance of the associated application account (whose address is the hash of the application ID) is modified.

When a box with name nn and size ss is created, the minimum balance requirement is raised by Boxflat,bmin+Boxbyte,bmin×(len(n)+s)Boxflat,bmin+Boxbyte,bmin×(len(n)+s). The same amount is decremented from the minimum balance when the box is destroyed.