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

State Access

Block Access

OPCODEDESCRIPTION
online_stakethe total online stake in the agreement round
logwrite A to log state of the current application
block ffield F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)

Account Access

OPCODEDESCRIPTION
balancebalance for account A, in microalgos. The balance is observed after the effects of previous transactions in the group, and after the fee for the current transaction is deducted. Changes caused by inner transactions are observable immediately following itxn_submit
min_balanceminimum required balance for account A, in microalgos. Required balance is affected by ASA, App, and Box usage. When creating or opting into an app, the minimum balance grows before the app code runs, therefore the increase is visible there. When deleting or closing out, the minimum balance decreases after the app executes. Changes caused by inner transactions or box usage are observable immediately following the opcode effecting the change.
acct_params_get fX is field F from account A. Y is 1 if A owns positive algos, else 0
voter_params_get fX is field F from online account A as of the balance round: 320 rounds before the current round. Y is 1 if A had positive algos online in the agreement round, else Y is 0 and X is a type specific zero-value

Asset Access

OPCODEDESCRIPTION
asset_holding_get fX is field F from account A’s holding of asset B. Y is 1 if A is opted into B, else 0
asset_params_get fX is field F from asset A. Y is 1 if A exists, else 0

Application Access

OPCODEDESCRIPTION
app_opted_in1 if account A is opted in to application B, else 0
app_local_getlocal state of the key B in the current application in account A
app_local_get_exX is the local state of application B, key C in account A. Y is 1 if key existed, else 0
app_global_getglobal state of the key A in the current application
app_global_get_exX is the global state of application A, key B. Y is 1 if key existed, else 0
app_local_putwrite C to key B in account A’s local state of the current application
app_global_putwrite B to key A in the global state of the current application
app_local_deldelete key B from account A’s local state of the current application
app_global_deldelete key A from the global state of the current application
app_params_get fX is field F from app A. Y is 1 if A exists, else 0

Box Access

Box opcodes that create, delete, or resize boxes affect the minimum balance requirement of the calling application’s account. The change is immediate, and can be observed after exection by using min_balance. If the account does not possess the new minimum balance, the opcode fails.

All box related opcodes fail immediately if used in a ClearStateProgram. This behavior is meant to discourage Smart Contract authors from depending upon the availability of boxes in a ClearState transaction, as accounts using ClearState are under no requirement to furnish appropriate Box References. Authors would do well to keep the same issue in mind with respect to the availability of Accounts, Assets, and Apps though State Access opcodes are allowed in ClearState programs because the current application and sender account are sure to be available.

OPCODEDESCRIPTION
box_createcreate a box named A, of length B. Fail if the name A is empty or B exceeds 32,768. Returns 0 if A already existed, else 1
box_extractread C bytes from box A, starting at offset B. Fail if A does not exist, or the byte range is outside A’s size.
box_replacewrite byte-array C into box A, starting at offset B. Fail if A does not exist, or the byte range is outside A’s size.
box_spliceset box A to contain its previous bytes up to index B, followed by D, followed by the original bytes of A that began at index B+C.
box_deldelete box named A if it exists. Return 1 if A existed, 0 otherwise
box_lenX is the length of box A if A exists, else 0. Y is 1 if A exists, else 0.
box_getX is the contents of box A if A exists, else ‘’. Y is 1 if A exists, else 0.
box_putreplaces the contents of box A with byte-array B. Fails if A exists and len(B) != len(box A). Creates A if it does not exist
box_resizechange the size of box named A to be of length B, adding zero bytes to end or removing bytes from the end, as needed. Fail if the name A is empty, A is not an existing box, or B exceeds 32,768.