Constants - Algorand Specifications

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

Algorand Specifications

Constants can be pushed onto the Stack in two different ways:

  1. Constants can be pushed directly with pushint or pushbytes opcodes. This method is more efficient for constants that are only used once.

  2. Constants can be loaded into storage separate from the Stack and Scratch Space, with intcblock or bytecblock opcodes. Then, constants from this storage can be pushed onto the Stack by referring to the type and index using intc, intc_[0123], bytec, and bytec_[0123]. This method is more efficient for constants that are used multiple times.

The opcodes intcblock and bytecblock use proto-buf style variable length unsigned int, reproduced in the varuint section.

The intcblock opcode is followed by a varuint specifying the number of integer constants, and then that number of varuint.

The bytecblock opcode is followed by a varuint specifying the number of byte constants, and then that number of pairs of (varuint, bytes) length prefixed byte strings.

The Assembler will hide most of this, for example, allowing simple use of int 1234 and byte 0xcafed00d. Constants introduced via int and byte will be assembled into appropriate uses of pushint|pushbytes and {int|byte}c, {int|byte}c_[0123] to minimize program bytecode size.

An application call transaction MUST indicate the action to be taken following the execution of its Approval Program or Clear State Program.

The constants below describe the available actions.

ACTION VALUE DESCRIPTION
NoOp 0 Only execute the Approval Program associated with the application ID, with no additional effects.
OptIn 1 Before executing the Approval Program, allocate local state for this application ID into the sender’s account data.
CloseOut 2 After executing the Approval Program, clear any local state for this application ID out of the sender’s account data.
ClearState 3 Do not execute the Approval Program, and instead execute the Clear State Program (which may not reject this transaction). Additionally, clear any local state for the application ID out of the sender’s account data (as in CloseOutOC).
UpdateApplication 4 After executing the Approval Program, replace the Approval Program and Clear State Program associated with the application ID with the programs specified in this transaction.
DeleteApplication 5 After executing the Approval Program, delete the parameters of with the application ID from the account data of the application’s creator.
TYPE VALUE DESCRIPTION
unknown 0 Unknown type, invalid transaction
pay 1 ALGO transfers (payment)
keyreg 2 Consensus keys registration
acfg 3 Asset creation and configuration
axfer 4 Asset transfer
afrz 5 Asset freeze and unfreeze
appl 6 Application calls
stpf 7 State Proof
hb 8 Consensus heartbeat