logic

package
v0.0.0-...-adf39d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 45 Imported by: 5

README

The Algorand Virtual Machine (AVM) and TEAL.

The AVM is a bytecode based stack interpreter that executes programs associated with Algorand transactions. TEAL is an assembly language syntax for specifying a program that is ultimately converted to AVM bytecode. These programs can be used to check the parameters of the transaction and approve the transaction as if by a signature. This use is called a Smart Signature. Starting with v2, these programs may also execute as Smart Contracts, which are often called Applications. Contract executions are invoked with explicit application call transactions.

Programs have read-only access to the transaction they are attached to, the other transactions in their atomic transaction group, and a few global values. In addition, Smart Contracts have access to limited state that is global to the application, per-account local state for each account that has opted-in to the application, and additional per-application arbitrary state in named boxes. For both types of program, approval is signaled by finishing with the stack containing a single non-zero uint64 value, though return can be used to signal an early approval which approves based only upon the top stack value being a non-zero uint64 value.

The Stack

The stack starts empty and can contain values of either uint64 or byte-arrays (byte-arrays may not exceed 4096 bytes in length). Most operations act on the stack, popping arguments from it and pushing results to it. Some operations have immediate arguments that are encoded directly into the instruction, rather than coming from the stack.

The maximum stack depth is 1000. If the stack depth is exceeded or if a byte-array element exceeds 4096 bytes, the program fails. If an opcode is documented to access a position in the stack that does not exist, the operation fails. Most often, this is an attempt to access an element below the stack -- the simplest example is an operation like concat which expects two arguments on the stack. If the stack has fewer than two elements, the operation fails. Some operations, like frame_dig and proto could fail because of an attempt to access above the current stack.

Stack Types

While every element of the stack is restricted to the types uint64 and bytes, the values of these types may be known to be bounded. The more common bounded types are named to provide more semantic information in the documentation. They're also used during assembly time to do type checking and to provide more informative error messages.

Definitions
Name Bound AVM Type
[]byte len(x) <= 4096 []byte
address len(x) == 32 []byte
any any
bigint len(x) <= 64 []byte
bool x <= 1 uint64
boxName 1 <= len(x) <= 64 []byte
method len(x) == 4 []byte
none none
stateKey len(x) <= 64 []byte
uint64 x <= 18446744073709551615 uint64

Scratch Space

In addition to the stack there are 256 positions of scratch space. Like stack values, scratch locations may be uint64s or byte-arrays. Scratch locations are initialized as uint64 zero. Scratch space is accessed by the load(s) and store(s) opcodes which move data from or to scratch space, respectively. Application calls may inspect the final scratch space of earlier application calls in the same group using gload(s)(s)

Versions

In order to maintain existing semantics for previously written programs, AVM code is versioned. When new opcodes are introduced, or behavior is changed, a new version is introduced. Programs carrying old versions are executed with their original semantics. In the AVM bytecode, the version is an incrementing integer, currently 6, and denoted vX throughout this document.

Execution Modes

Starting from v2, the AVM can run programs in two modes:

  1. LogicSig or stateless mode, used to execute Smart Signatures
  2. Application or stateful mode, used to execute Smart Contracts

Differences between modes include:

  1. Max program length (consensus parameters LogicSigMaxSize, MaxAppTotalProgramLen & MaxExtraAppProgramPages)
  2. Max program cost (consensus parameters LogicSigMaxCost, MaxAppProgramCost)
  3. Opcode availability. Refer to opcodes document for details.
  4. Some global values, such as LatestTimestamp, are only available in stateful mode.
  5. Only Applications can observe transaction effects, such as Logs or IDs allocated to ASAs or new Applications.

Execution Environment for Smart Signatures

Smart Signatures execute as part of testing a proposed transaction to see if it is valid and authorized to be committed into a block. If an authorized program executes and finishes with a single non-zero uint64 value on the stack then that program has validated the transaction it is attached to.

The program has access to data from the transaction it is attached to (txn op), any transactions in a transaction group it is part of (gtxn op), and a few global values like consensus parameters (global op). Some "Args" may be attached to a transaction being validated by a program. Args are an array of byte strings. A common pattern would be to have the key to unlock some contract as an Arg. Be aware that Smart Signature Args are recorded on the blockchain and publicly visible when the transaction is submitted to the network, even before the transaction has been included in a block. These Args are not part of the transaction ID nor of the TxGroup hash. They also cannot be read from other programs in the group of transactions.

A program can either authorize some delegated action on a normal signature-based or multisignature-based account or be wholly in charge of a contract account.

  • If the account has signed the program (by providing a valid ed25519 signature or valid multisignature for the authorizer address on the string "Program" concatenated with the program bytecode) then: if the program returns true the transaction is authorized as if the account had signed it. This allows an account to hand out a signed program so that other users can carry out delegated actions which are approved by the program. Note that Smart Signature Args are not signed.

  • If the SHA512_256 hash of the program (prefixed by "Program") is equal to authorizer address of the transaction sender then this is a contract account wholly controlled by the program. No other signature is necessary or possible. The only way to execute a transaction against the contract account is for the program to approve it.

The bytecode plus the length of all Args must add up to no more than 1000 bytes (consensus parameter LogicSigMaxSize). Each opcode has an associated cost, usually 1, but a few slow operations have higher costs. Prior to v4, the program's cost was estimated as the static sum of all the opcode costs in the program (whether they were actually executed or not). Beginning with v4, the program's cost is tracked dynamically, while being evaluated. If the program exceeds its budget, it fails.

The total program cost of all Smart Signatures in a group must not exceed 20,000 (consensus parameter LogicSigMaxCost) times the number of transactions in the group.

Execution Environment for Smart Contracts (Applications)

Smart Contracts are executed in ApplicationCall transactions. Like Smart Signatures, contracts indicate success by leaving a single non-zero integer on the stack. A failed Smart Contract call to an ApprovalProgram is not a valid transaction, thus not written to the blockchain. An ApplicationCall with OnComplete set to ClearState invokes the ClearStateProgram, rather than the usual ApprovalProgram. If the ClearStateProgram fails, application state changes are rolled back, but the transaction still succeeds, and the Sender's local state for the called application is removed.

Smart Contracts have access to everything a Smart Signature may access (see previous section), as well as the ability to examine blockchain state such as balances and contract state (their own state and the state of other contracts). They also have access to some global values that are not visible to Smart Signatures because the values change over time. Since smart contracts access changing state, nodes must rerun their code to determine if the ApplicationCall transactions in their pool would still succeed each time a block is added to the blockchain.

Smart contracts have limits on their execution cost (700, consensus parameter MaxAppProgramCost). Before v4, this was a static limit on the cost of all the instructions in the program. Starting in v4, the cost is tracked dynamically during execution and must not exceed MaxAppProgramCost. Beginning with v5, programs costs are pooled and tracked dynamically across app executions in a group. If n application invocations appear in a group, then the total execution cost of all such calls must not exceed n*MaxAppProgramCost. In v6, inner application calls become possible, and each such call increases the pooled budget by MaxAppProgramCost at the time the inner group is submitted with itxn_submit.

Executions of the ClearStateProgram are more stringent, in order to ensure that applications may be closed out, but that applications also are assured a chance to clean up their internal state. At the beginning of the execution of a ClearStateProgram, the pooled budget available must be MaxAppProgramCost or higher. If it is not, the containing transaction group fails without clearing the app's state. During the execution of the ClearStateProgram, no more than MaxAppProgramCost may be drawn. If further execution is attempted, the ClearStateProgram fails, and the app's state is cleared.

Resource availability

Smart contracts have limits on the amount of blockchain state they may examine. Opcodes may only access blockchain resources such as Accounts, Assets, Boxes, and contract state if the given resource is available.

  • A resource in the "foreign array" fields of the ApplicationCall transaction (txn.Accounts, txn.ForeignAssets, and txn.ForeignApplications) is available.

  • The txn.Sender, global CurrentApplicationID, and global CurrentApplicationAddress are available.

  • Prior to v4, all assets were considered available to the asset_holding_get opcode, and all applications were available to the app_local_get_ex opcode.

  • Since v6, any asset or contract that was created earlier in the same transaction group (whether by a top-level or inner transaction) is available. In addition, any account that is the associated account of a contract that was created earlier in the group is available.

  • Since v7, the account associated with any contract present in the txn.ForeignApplications field is available.

  • Since v9, there is group-level resource sharing. Any resource that is available in some top-level transaction in a transaction group is available in all v9 or later application calls in the group, whether those application calls are top-level or inner.

  • When considering whether an asset holding or application local state is available by group-level resource sharing, the holding or local state must be available in a top-level transaction without considering group sharing. For example, if account A is made available in one transaction, and asset X is made available in another, group resource sharing does not make A's X holding available.

  • Top-level transactions that are not application calls also make resources available to group-level resource sharing. The following resources are made available by other transaction types.

    1. pay - txn.Sender, txn.Receiver, and txn.CloseRemainderTo (if set).

    2. keyreg - txn.Sender

    3. acfg - txn.Sender, txn.ConfigAsset, and the txn.ConfigAsset holding of txn.Sender.

    4. axfer - txn.Sender, txn.AssetReceiver, txn.AssetSender (if set), txnAssetCloseTo (if set), txn.XferAsset, and the txn.XferAsset holding of each of those accounts.

    5. afrz - txn.Sender, txn.FreezeAccount, txn.FreezeAsset, and the txn.FreezeAsset holding of txn.FreezeAccount. The txn.FreezeAsset holding of txn.Sender is not made available.

  • A Box is available to an Approval Program if any transaction in the same group contains a box reference (txn.Boxes) that denotes the box. A box reference contains an index i, and name n. The index refers to the ith application in the transaction's ForeignApplications array, with the usual convention that 0 indicates the application ID of the app called by that transaction. No box is ever available to a ClearStateProgram.

Regardless of availability, any attempt to access an Asset or Application with an ID less than 256 from within a Contract will fail immediately. This avoids any ambiguity in opcodes that interpret their integer arguments as resource IDs or indexes into the txn.ForeignAssets or txn.ForeignApplications arrays.

It is recommended that contract authors avoid supplying array indexes to these opcodes, and always use explicit resource IDs. By using explicit IDs, contracts will better take advantage of group resource sharing. The array indexing interpretation may be deprecated in a future version.

Constants

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

  1. Constants can be pushed directly with pushint or pushbytes. 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, using two opcodes intcblock and bytecblock. 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 assembler will hide most of this, 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 size.

The opcodes intcblock and bytecblock use proto-buf style variable length unsigned int, reproduced here. The intcblock opcode is followed by a varuint specifying the number of integer constants and then that number of varuints. 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.

Named Integer Constants
OnComplete

An application transaction must indicate the action to be taken following the execution of its approvalProgram or clearStateProgram. The constants below describe the available actions.

Value Name Description
0 NoOp Only execute the ApprovalProgram associated with this application ID, with no additional effects.
1 OptIn Before executing the ApprovalProgram, allocate local state for this application into the sender's account data.
2 CloseOut After executing the ApprovalProgram, clear any local state for this application out of the sender's account data.
3 ClearState Don't execute the ApprovalProgram, and instead execute the ClearStateProgram (which may not reject this transaction). Additionally, clear any local state for this application out of the sender's account data as in CloseOutOC.
4 UpdateApplication After executing the ApprovalProgram, replace the ApprovalProgram and ClearStateProgram associated with this application ID with the programs specified in this transaction.
5 DeleteApplication After executing the ApprovalProgram, delete the application parameters from the account data of the application's creator.
TypeEnum constants
Value Name Description
0 unknown Unknown type. Invalid transaction
1 pay Payment
2 keyreg KeyRegistration
3 acfg AssetConfig
4 axfer AssetTransfer
5 afrz AssetFreeze
6 appl ApplicationCall

Operations

Most operations work with only one type of argument, uint64 or bytes, and fail if the wrong type value is on the stack.

Many instructions accept values to designate Accounts, Assets, or Applications. Beginning with v4, these values may be given as an offset in the corresponding Txn fields (Txn.Accounts, Txn.ForeignAssets, Txn.ForeignApps) or as the value itself (a byte-array address for Accounts, or a uint64 ID). The values, however, must still be present in the Txn fields. Before v4, most opcodes required the use of an offset, except for reading account local values of assets or applications, which accepted the IDs directly and did not require the ID to be present in the corresponding Foreign array. (Note that beginning with v4, those IDs are required to be present in their corresponding Foreign array.) See individual opcodes for details. In the case of account offsets or application offsets, 0 is specially defined to Txn.Sender or the ID of the current application, respectively.

This summary is supplemented by more detail in the opcodes document.

Some operations immediately fail the program. A transaction checked by a program that fails is not valid. An account governed by a buggy program might not have a way to get assets back out of it. Code carefully.

In the documentation for each opcode, the stack arguments that are popped are referred to alphabetically, beginning with the deepest argument as A. These arguments are shown in the opcode description, and if the opcode must be of a specific type, it is noted there. All opcodes fail if a specified type is incorrect.

If an opcode pushes more than one result, the values are named for ease of exposition and clarity concerning their stack positions. When an opcode manipulates the stack in such a way that a value changes position but is otherwise unchanged, the name of the output on the return stack matches the name of the input value.

Arithmetic and Logic Operations
Opcode Description
+ A plus B. Fail on overflow.
- A minus B. Fail if B > A.
/ A divided by B (truncated division). Fail if B == 0.
* A times B. Fail on overflow.
< A less than B => {0 or 1}
> A greater than B => {0 or 1}
<= A less than or equal to B => {0 or 1}
>= A greater than or equal to B => {0 or 1}
&& A is not zero and B is not zero => {0 or 1}
|| A is not zero or B is not zero => {0 or 1}
shl A times 2^B, modulo 2^64
shr A divided by 2^B
sqrt The largest integer I such that I^2 <= A
bitlen The highest set bit in A. If A is a byte-array, it is interpreted as a big-endian unsigned integer. bitlen of 0 is 0, bitlen of 8 is 4
exp A raised to the Bth power. Fail if A == B == 0 and on overflow
== A is equal to B => {0 or 1}
!= A is not equal to B => {0 or 1}
! A == 0 yields 1; else 0
itob converts uint64 A to big-endian byte array, always of length 8
btoi converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8.
% A modulo B. Fail if B == 0.
| A bitwise-or B
& A bitwise-and B
^ A bitwise-xor B
~ bitwise invert value A
mulw A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low
addw A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.
divw A,B / C. Fail if C == 0 or if result overflows.
divmodw W,X = (A,B / C,D); Y,Z = (A,B modulo C,D)
expw A raised to the Bth power as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low. Fail if A == B == 0 or if the results exceeds 2^128-1
Byte Array Manipulation
Opcode Description
getbit Bth bit of (byte-array or integer) A. If B is greater than or equal to the bit length of the value (8*byte length), the program fails
setbit Copy of (byte-array or integer) A, with the Bth bit set to (0 or 1) C. If B is greater than or equal to the bit length of the value (8*byte length), the program fails
getbyte Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails
setbyte Copy of A with the Bth byte set to small integer (between 0..255) C. If B is greater than or equal to the array length, the program fails
concat join A and B
len yields length of byte value A
substring s e A range of bytes from A starting at S up to but not including E. If E < S, or either is larger than the array length, the program fails
substring3 A range of bytes from A starting at B up to but not including C. If C < B, or either is larger than the array length, the program fails
extract s l A range of bytes from A starting at S up to but not including S+L. If L is 0, then extract to the end of the string. If S or S+L is larger than the array length, the program fails
extract3 A range of bytes from A starting at B up to but not including B+C. If B+C is larger than the array length, the program fails
extract3 can be called using extract with no immediates.
extract_uint16 A uint16 formed from a range of big-endian bytes from A starting at B up to but not including B+2. If B+2 is larger than the array length, the program fails
extract_uint32 A uint32 formed from a range of big-endian bytes from A starting at B up to but not including B+4. If B+4 is larger than the array length, the program fails
extract_uint64 A uint64 formed from a range of big-endian bytes from A starting at B up to but not including B+8. If B+8 is larger than the array length, the program fails
replace2 s Copy of A with the bytes starting at S replaced by the bytes of B. Fails if S+len(B) exceeds len(A)
replace2 can be called using replace with 1 immediate.
replace3 Copy of A with the bytes starting at B replaced by the bytes of C. Fails if B+len(C) exceeds len(A)
replace3 can be called using replace with no immediates.
base64_decode e decode A which was base64-encoded using encoding E. Fail if A is not base64 encoded with encoding E
json_ref r key B's value, of type R, from a valid utf-8 encoded json object A

The following opcodes take byte-array values that are interpreted as big-endian unsigned integers. For mathematical operators, the returned values are the shortest byte-array that can represent the returned value. For example, the zero value is the empty byte-array. For comparison operators, the returned value is a uint64.

Input lengths are limited to a maximum length of 64 bytes, representing a 512 bit unsigned integer. Output lengths are not explicitly restricted, though only b* and b+ can produce a larger output than their inputs, so there is an implicit length limit of 128 bytes on outputs.

Opcode Description
b+ A plus B. A and B are interpreted as big-endian unsigned integers
b- A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.
b/ A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.
b* A times B. A and B are interpreted as big-endian unsigned integers.
b< 1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers
b> 1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers
b<= 1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers
b>= 1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers
b== 1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers
b!= 0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers
b% A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.
bsqrt The largest integer I such that I^2 <= A. A and I are interpreted as big-endian unsigned integers

These opcodes operate on the bits of byte-array values. The shorter input array is interpreted as though left padded with zeros until it is the same length as the other input. The returned values are the same length as the longer input. Therefore, unlike array arithmetic, these results may contain leading zero bytes.

Opcode Description
b| A bitwise-or B. A and B are zero-left extended to the greater of their lengths
b& A bitwise-and B. A and B are zero-left extended to the greater of their lengths
b^ A bitwise-xor B. A and B are zero-left extended to the greater of their lengths
b~ A with all bits inverted
Cryptographic Operations
Opcode Description
sha256 SHA256 hash of value A, yields [32]byte
keccak256 Keccak256 hash of value A, yields [32]byte
sha512_256 SHA512_256 hash of value A, yields [32]byte
sha3_256 SHA3_256 hash of value A, yields [32]byte
ed25519verify for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1}
ed25519verify_bare for (data A, signature B, pubkey C) verify the signature of the data against the pubkey => {0 or 1}
ecdsa_verify v for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1}
ecdsa_pk_recover v for (data A, recovery id B, signature C, D) recover a public key
ecdsa_pk_decompress v decompress pubkey A into components X, Y
vrf_verify s Verify the proof B of message A against pubkey C. Returns vrf output and verification flag.
ec_add g for curve points A and B, return the curve point A + B
ec_scalar_mul g for curve point A and scalar B, return the curve point BA, the point A multiplied by the scalar B.
ec_pairing_check g 1 if the product of the pairing of each point in A with its respective point in B is equal to the identity element of the target group Gt, else 0
ec_multi_scalar_mul g for curve points A and scalars B, return curve point B0A0 + B1A1 + B2A2 + ... + BnAn
ec_subgroup_check g 1 if A is in the main prime-order subgroup of G (including the point at infinity) else 0. Program fails if A is not in G at all.
ec_map_to g maps field element A to group G
Loading Values

Opcodes for getting data onto the stack.

Some of these have immediate data in the byte or bytes after the opcode.

Opcode Description
intcblock uint ... prepare block of uint64 constants for use by intc
intc i Ith constant from intcblock
intc_0 constant 0 from intcblock
intc_1 constant 1 from intcblock
intc_2 constant 2 from intcblock
intc_3 constant 3 from intcblock
pushint uint immediate UINT
pushints uint ... push sequence of immediate uints to stack in the order they appear (first uint being deepest)
bytecblock bytes ... prepare block of byte-array constants for use by bytec
bytec i Ith constant from bytecblock
bytec_0 constant 0 from bytecblock
bytec_1 constant 1 from bytecblock
bytec_2 constant 2 from bytecblock
bytec_3 constant 3 from bytecblock
pushbytes bytes immediate BYTES
pushbytess bytes ... push sequences of immediate byte arrays to stack (first byte array being deepest)
bzero zero filled byte-array of length A
arg n Nth LogicSig argument
arg_0 LogicSig argument 0
arg_1 LogicSig argument 1
arg_2 LogicSig argument 2
arg_3 LogicSig argument 3
args Ath LogicSig argument
txn f field F of current transaction
gtxn t f field F of the Tth transaction in the current group
txna f i Ith value of the array field F of the current transaction
txna can be called using txn with 2 immediates.
txnas f Ath value of the array field F of the current transaction
gtxna t f i Ith value of the array field F from the Tth transaction in the current group
gtxna can be called using gtxn with 3 immediates.
gtxnas t f Ath value of the array field F from the Tth transaction in the current group
gtxns f field F of the Ath transaction in the current group
gtxnsa f i Ith value of the array field F from the Ath transaction in the current group
gtxnsa can be called using gtxns with 2 immediates.
gtxnsas f Bth value of the array field F from the Ath transaction in the current group
global f global field F
load i Ith scratch space value. All scratch spaces are 0 at program start.
loads Ath scratch space value. All scratch spaces are 0 at program start.
store i store A to the Ith scratch space
stores store B to the Ath scratch space
gload t i Ith scratch space value of the Tth transaction in the current group
gloads i Ith scratch space value of the Ath transaction in the current group
gloadss Bth scratch space value of the Ath transaction in the current group
gaid t ID of the asset or application created in the Tth transaction of the current group
gaids ID of the asset or application created in the Ath transaction of the current group
Transaction Fields
Scalar Fields
Index Name Type In Notes
0 Sender address 32 byte address
1 Fee uint64 microalgos
2 FirstValid uint64 round number
3 FirstValidTime uint64 v7 UNIX timestamp of block before txn.FirstValid. Fails if negative
4 LastValid uint64 round number
5 Note []byte Any data up to 1024 bytes
6 Lease [32]byte 32 byte lease value
7 Receiver address 32 byte address
8 Amount uint64 microalgos
9 CloseRemainderTo address 32 byte address
10 VotePK [32]byte 32 byte address
11 SelectionPK [32]byte 32 byte address
12 VoteFirst uint64 The first round that the participation key is valid.
13 VoteLast uint64 The last round that the participation key is valid.
14 VoteKeyDilution uint64 Dilution for the 2-level participation key
15 Type []byte Transaction type as bytes
16 TypeEnum uint64 Transaction type as integer
17 XferAsset uint64 Asset ID
18 AssetAmount uint64 value in Asset's units
19 AssetSender address 32 byte address. Source of assets if Sender is the Asset's Clawback address.
20 AssetReceiver address 32 byte address
21 AssetCloseTo address 32 byte address
22 GroupIndex uint64 Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1
23 TxID [32]byte The computed ID for this transaction. 32 bytes.
24 ApplicationID uint64 v2 ApplicationID from ApplicationCall transaction
25 OnCompletion uint64 v2 ApplicationCall transaction on completion action
27 NumAppArgs uint64 v2 Number of ApplicationArgs
29 NumAccounts uint64 v2 Number of Accounts
30 ApprovalProgram []byte v2 Approval program
31 ClearStateProgram []byte v2 Clear state program
32 RekeyTo address v2 32 byte Sender's new AuthAddr
33 ConfigAsset uint64 v2 Asset ID in asset config transaction
34 ConfigAssetTotal uint64 v2 Total number of units of this asset created
35 ConfigAssetDecimals uint64 v2 Number of digits to display after the decimal place when displaying the asset
36 ConfigAssetDefaultFrozen bool v2 Whether the asset's slots are frozen by default or not, 0 or 1
37 ConfigAssetUnitName []byte v2 Unit name of the asset
38 ConfigAssetName []byte v2 The asset name
39 ConfigAssetURL []byte v2 URL
40 ConfigAssetMetadataHash [32]byte v2 32 byte commitment to unspecified asset metadata
41 ConfigAssetManager address v2 32 byte address
42 ConfigAssetReserve address v2 32 byte address
43 ConfigAssetFreeze address v2 32 byte address
44 ConfigAssetClawback address v2 32 byte address
45 FreezeAsset uint64 v2 Asset ID being frozen or un-frozen
46 FreezeAssetAccount address v2 32 byte address of the account whose asset slot is being frozen or un-frozen
47 FreezeAssetFrozen bool v2 The new frozen value, 0 or 1
49 NumAssets uint64 v3 Number of Assets
51 NumApplications uint64 v3 Number of Applications
52 GlobalNumUint uint64 v3 Number of global state integers in ApplicationCall
53 GlobalNumByteSlice uint64 v3 Number of global state byteslices in ApplicationCall
54 LocalNumUint uint64 v3 Number of local state integers in ApplicationCall
55 LocalNumByteSlice uint64 v3 Number of local state byteslices in ApplicationCall
56 ExtraProgramPages uint64 v4 Number of additional pages for each of the application's approval and clear state programs. An ExtraProgramPages of 1 means 2048 more total bytes, or 1024 for each program.
57 Nonparticipation bool v5 Marks an account nonparticipating for rewards
59 NumLogs uint64 v5 Number of Logs (only with itxn in v5). Application mode only
60 CreatedAssetID uint64 v5 Asset ID allocated by the creation of an ASA (only with itxn in v5). Application mode only
61 CreatedApplicationID uint64 v5 ApplicationID allocated by the creation of an application (only with itxn in v5). Application mode only
62 LastLog []byte v6 The last message emitted. Empty bytes if none were emitted. Application mode only
63 StateProofPK []byte v6 64 byte state proof public key
65 NumApprovalProgramPages uint64 v7 Number of Approval Program pages
67 NumClearStateProgramPages uint64 v7 Number of ClearState Program pages
Array Fields
Index Name Type In Notes
26 ApplicationArgs []byte v2 Arguments passed to the application in the ApplicationCall transaction
28 Accounts address v2 Accounts listed in the ApplicationCall transaction
48 Assets uint64 v3 Foreign Assets listed in the ApplicationCall transaction
50 Applications uint64 v3 Foreign Apps listed in the ApplicationCall transaction
58 Logs []byte v5 Log messages emitted by an application call (only with itxn in v5). Application mode only
64 ApprovalProgramPages []byte v7 Approval Program as an array of pages
66 ClearStateProgramPages []byte v7 ClearState Program as an array of pages

Additional details in the opcodes document on the txn op.

Global Fields

Global fields are fields that are common to all the transactions in the group. In particular it includes consensus parameters.

Index Name Type In Notes
0 MinTxnFee uint64 microalgos
1 MinBalance uint64 microalgos
2 MaxTxnLife uint64 rounds
3 ZeroAddress address 32 byte address of all zero bytes
4 GroupSize uint64 Number of transactions in this atomic transaction group. At least 1
5 LogicSigVersion uint64 v2 Maximum supported version
6 Round uint64 v2 Current round number. Application mode only.
7 LatestTimestamp uint64 v2 Last confirmed block UNIX timestamp. Fails if negative. Application mode only.
8 CurrentApplicationID uint64 v2 ID of current application executing. Application mode only.
9 CreatorAddress address v3 Address of the creator of the current application. Application mode only.
10 CurrentApplicationAddress address v5 Address that the current application controls. Application mode only.
11 GroupID [32]byte v5 ID of the transaction group. 32 zero bytes if the transaction is not part of a group.
12 OpcodeBudget uint64 v6 The remaining cost that can be spent by opcodes in this program.
13 CallerApplicationID uint64 v6 The application ID of the application that called this application. 0 if this application is at the top-level. Application mode only.
14 CallerApplicationAddress address v6 The application address of the application that called this application. ZeroAddress if this application is at the top-level. Application mode only.
15 AssetCreateMinBalance uint64 v10 The additional minimum balance required to create (and opt-in to) an asset.
16 AssetOptInMinBalance uint64 v10 The additional minimum balance required to opt-in to an asset.
17 GenesisHash [32]byte v10 The Genesis Hash for the network.

Asset Fields

Asset fields include AssetHolding and AssetParam fields that are used in the asset_holding_get and asset_params_get opcodes.

Index Name Type Notes
0 AssetBalance uint64 Amount of the asset unit held by this account
1 AssetFrozen bool Is the asset frozen or not
Index Name Type In Notes
0 AssetTotal uint64 Total number of units of this asset
1 AssetDecimals uint64 See AssetParams.Decimals
2 AssetDefaultFrozen bool Frozen by default or not
3 AssetUnitName []byte Asset unit name
4 AssetName []byte Asset name
5 AssetURL []byte URL with additional info about the asset
6 AssetMetadataHash [32]byte Arbitrary commitment
7 AssetManager address Manager address
8 AssetReserve address Reserve address
9 AssetFreeze address Freeze address
10 AssetClawback address Clawback address
11 AssetCreator address v5 Creator address

App Fields

App fields used in the app_params_get opcode.

Index Name Type Notes
0 AppApprovalProgram []byte Bytecode of Approval Program
1 AppClearStateProgram []byte Bytecode of Clear State Program
2 AppGlobalNumUint uint64 Number of uint64 values allowed in Global State
3 AppGlobalNumByteSlice uint64 Number of byte array values allowed in Global State
4 AppLocalNumUint uint64 Number of uint64 values allowed in Local State
5 AppLocalNumByteSlice uint64 Number of byte array values allowed in Local State
6 AppExtraProgramPages uint64 Number of Extra Program Pages of code space
7 AppCreator address Creator address
8 AppAddress address Address for which this application has authority

Account Fields

Account fields used in the acct_params_get opcode.

Index Name Type In Notes
0 AcctBalance uint64 Account balance in microalgos
1 AcctMinBalance uint64 Minimum required balance for account, in microalgos
2 AcctAuthAddr address Address the account is rekeyed to.
3 AcctTotalNumUint uint64 v8 The total number of uint64 values allocated by this account in Global and Local States.
4 AcctTotalNumByteSlice uint64 v8 The total number of byte array values allocated by this account in Global and Local States.
5 AcctTotalExtraAppPages uint64 v8 The number of extra app code pages used by this account.
6 AcctTotalAppsCreated uint64 v8 The number of existing apps created by this account.
7 AcctTotalAppsOptedIn uint64 v8 The number of apps this account is opted into.
8 AcctTotalAssetsCreated uint64 v8 The number of existing ASAs created by this account.
9 AcctTotalAssets uint64 v8 The numbers of ASAs held by this account (including ASAs this account created).
10 AcctTotalBoxes uint64 v8 The number of existing boxes created by this account's app.
11 AcctTotalBoxBytes uint64 v8 The total number of bytes used by this account's app's box keys and values.
Flow Control
Opcode Description
err Fail immediately.
bnz target branch to TARGET if value A is not zero
bz target branch to TARGET if value A is zero
b target branch unconditionally to TARGET
return use A as success value; end
pop discard A
popn n remove N values from the top of the stack
dup duplicate A
dup2 duplicate A and B
dupn n duplicate A, N times
dig n Nth value from the top of the stack. dig 0 is equivalent to dup
bury n replace the Nth value from the top of the stack with A. bury 0 fails.
cover n remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth <= N.
uncover n remove the value at depth N in the stack and shift above items down so the Nth deep value is on top of the stack. Fails if stack depth <= N.
frame_dig i Nth (signed) value from the frame pointer.
frame_bury i replace the Nth (signed) value from the frame pointer in the stack with A
swap swaps A and B on stack
select selects one of two values based on top-of-stack: B if C != 0, else A
assert immediately fail unless A is a non-zero number
callsub target branch unconditionally to TARGET, saving the next instruction on the call stack
proto a r Prepare top call frame for a retsub that will assume A args and R return values.
retsub pop the top instruction from the call stack and branch to it
switch target ... branch to the Ath label. Continue at following instruction if index A exceeds the number of labels.
match target ... given match cases from A[1] to A[N], branch to the Ith label where A[I] = B. Continue to the following instruction if no matches are found.
State Access
Opcode Description
balance balance 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_balance minimum 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.
app_opted_in 1 if account A is opted in to application B, else 0
app_local_get local state of the key B in the current application in account A
app_local_get_ex X is the local state of application B, key C in account A. Y is 1 if key existed, else 0
app_global_get global state of the key A in the current application
app_global_get_ex X is the global state of application A, key B. Y is 1 if key existed, else 0
app_local_put write C to key B in account A's local state of the current application
app_global_put write B to key A in the global state of the current application
app_local_del delete key B from account A's local state of the current application
app_global_del delete key A from the global state of the current application
asset_holding_get f X 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 f X is field F from asset A. Y is 1 if A exists, else 0
app_params_get f X is field F from app A. Y is 1 if A exists, else 0
acct_params_get f X is field F from account A. Y is 1 if A owns positive algos, else 0
log write A to log state of the current application
block f field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)
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.

Opcode Description
box_create create 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_extract read 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_replace write 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_splice set 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_del delete box named A if it exists. Return 1 if A existed, 0 otherwise
box_len X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0.
box_get X is the contents of box A if A exists, else ''. Y is 1 if A exists, else 0.
box_put replaces 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_resize change 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.
Inner Transactions

The following opcodes allow for "inner transactions". Inner transactions allow stateful applications to have many of the effects of a true top-level transaction, programmatically. However, they are different in significant ways. The most important differences are that they are not signed, duplicates are not rejected, and they do not appear in the block in the usual away. Instead, their effects are noted in metadata associated with their top-level application call transaction. An inner transaction's Sender must be the SHA512_256 hash of the application ID (prefixed by "appID"), or an account that has been rekeyed to that hash.

In v5, inner transactions may perform pay, axfer, acfg, and afrz effects. After executing an inner transaction with itxn_submit, the effects of the transaction are visible beginning with the next instruction with, for example, balance and min_balance checks. In v6, inner transactions may also perform keyreg and appl effects. Inner appl calls fail if they attempt to invoke a program with version less than v4, or if they attempt to opt-in to an app with a ClearState Program less than v4.

In v5, only a subset of the transaction's header fields may be set: Type/TypeEnum, Sender, and Fee. In v6, header fields Note and RekeyTo may also be set. For the specific (non-header) fields of each transaction type, any field may be set. This allows, for example, clawback transactions, asset opt-ins, and asset creates in addition to the more common uses of axfer and acfg. All fields default to the zero value, except those described under itxn_begin.

Fields may be set multiple times, but may not be read. The most recent setting is used when itxn_submit executes. For this purpose Type and TypeEnum are considered to be the same field. When using itxn_field to set an array field (ApplicationArgs Accounts, Assets, or Applications) each use adds an element to the end of the array, rather than setting the entire array at once.

itxn_field fails immediately for unsupported fields, unsupported transaction types, or improperly typed values for a particular field. itxn_field makes acceptance decisions entirely from the field and value provided, never considering previously set fields. Illegal interactions between fields, such as setting fields that belong to two different transaction types, are rejected by itxn_submit.

Opcode Description
itxn_begin begin preparation of a new inner transaction in a new transaction group
itxn_next begin preparation of a new inner transaction in the same transaction group
itxn_field f set field F of the current inner transaction to A
itxn_submit execute the current inner transaction group. Fail if executing this group would exceed the inner transaction limit, or if any transaction in the group fails.
itxn f field F of the last inner transaction
itxna f i Ith value of the array field F of the last inner transaction
itxnas f Ath value of the array field F of the last inner transaction
gitxn t f field F of the Tth transaction in the last inner group submitted
gitxna t f i Ith value of the array field F from the Tth transaction in the last inner group submitted
gitxnas t f Ath value of the array field F from the Tth transaction in the last inner group submitted

Assembler Syntax

The assembler parses line by line. Ops that only take stack arguments appear on a line by themselves. Immediate arguments follow the opcode on the same line, separated by whitespace.

The first line may contain a special version pragma #pragma version X, which directs the assembler to generate bytecode targeting a certain version. For instance, #pragma version 2 produces bytecode targeting v2. By default, the assembler targets v1.

Subsequent lines may contain other pragma declarations (i.e., #pragma <some-specification>), pertaining to checks that the assembler should perform before agreeing to emit the program bytes, specific optimizations, etc. Those declarations are optional and cannot alter the semantics as described in this document.

"//" prefixes a line comment.

Constants and Pseudo-Ops

A few pseudo-ops simplify writing code. int and byte and addr and method followed by a constant record the constant to a intcblock or bytecblock at the beginning of code and insert an intc or bytec reference where the instruction appears to load that value. addr parses an Algorand account address base32 and converts it to a regular bytes constant. method is passed a method signature and takes the first four bytes of the hash to convert it to the standard method selector defined in ARC4

byte constants are:

byte base64 AAAA...
byte b64 AAAA...
byte base64(AAAA...)
byte b64(AAAA...)
byte base32 AAAA...
byte b32 AAAA...
byte base32(AAAA...)
byte b32(AAAA...)
byte 0x0123456789abcdef...
byte "\x01\x02"
byte "string literal"

int constants may be 0x prefixed for hex, 0o or 0 prefixed for octal, 0b for binary, or decimal numbers.

intcblock may be explicitly assembled. It will conflict with the assembler gathering int pseudo-ops into a intcblock program prefix, but may be used if code only has explicit intc references. intcblock should be followed by space separated int constants all on one line.

bytecblock may be explicitly assembled. It will conflict with the assembler if there are any byte pseudo-ops but may be used if only explicit bytec references are used. bytecblock should be followed with byte constants all on one line, either 'encoding value' pairs (b64 AAA...) or 0x prefix or function-style values (base64(...)) or string literal values.

Labels and Branches

A label is defined by any string not some other opcode or keyword and ending in ':'. A label can be an argument (without the trailing ':') to a branching instruction.

Example:

int 1
bnz safe
err
safe:
pop

Encoding and Versioning

A compiled program starts with a varuint declaring the version of the compiled code. Any addition, removal, or change of opcode behavior increments the version. For the most part opcode behavior should not change, addition will be infrequent (not likely more often than every three months and less often as the language matures), and removal should be very rare.

For version 1, subsequent bytes after the varuint are program opcode bytes. Future versions could put other metadata following the version identifier.

It is important to prevent newly-introduced transaction types and fields from breaking assumptions made by programs written before they existed. If one of the transactions in a group will execute a program whose version predates a transaction type or field that can violate expectations, that transaction type or field must not be used anywhere in the transaction group.

Concretely, the above requirement is translated as follows: A v1 program included in a transaction group that includes a ApplicationCall transaction or a non-zero RekeyTo field will fail regardless of the program itself.

This requirement is enforced as follows:

  • For every transaction, compute the earliest version that supports all the fields and values in this transaction.

  • Compute the largest version number across all the transactions in a group (of size 1 or more), call it maxVerNo. If any transaction in this group has a program with a version smaller than maxVerNo, then that program will fail.

In addition, applications must be v4 or greater to be called in an inner transaction.

Varuint

A 'proto-buf style variable length unsigned int' is encoded with 7 data bits per byte and the high bit is 1 if there is a following byte and 0 for the last byte. The lowest order 7 bits are in the first byte, followed by successively higher groups of 7 bits.

What AVM Programs Cannot Do

Design and implementation limitations to be aware of with various versions.

  • Stateless programs cannot lookup balances of Algos or other assets. (Standard transaction accounting will apply after the Smart Signature has authorized a transaction. A transaction could still be invalid by other accounting rules just as a standard signed transaction could be invalid. e.g. I can't give away money I don't have.)
  • Programs cannot access information in previous blocks. Programs cannot access information in other transactions in the current block, unless they are a part of the same atomic transaction group.
  • Smart Signatures cannot know exactly what round the current transaction will commit in (but it is somewhere in FirstValid through LastValid).
  • Programs cannot know exactly what time its transaction is committed.
  • Programs cannot loop prior to v4. In v3 and prior, the branch instructions bnz "branch if not zero", bz "branch if zero" and b "branch" can only branch forward.
  • Until v4, the AVM had no notion of subroutines (and therefore no recursion). As of v4, use callsub and retsub.
  • Programs cannot make indirect jumps. b, bz, bnz, and callsub jump to an immediately specified address, and retsub jumps to the address currently on the top of the call stack, which is manipulated only by previous calls to callsub and retsub.

Documentation

Index

Constants

View Source
const (
	// NoOp = transactions.NoOpOC
	NoOp = OnCompletionConstType(transactions.NoOpOC)
	// OptIn = transactions.OptInOC
	OptIn = OnCompletionConstType(transactions.OptInOC)
	// CloseOut = transactions.CloseOutOC
	CloseOut = OnCompletionConstType(transactions.CloseOutOC)
	// ClearState = transactions.ClearStateOC
	ClearState = OnCompletionConstType(transactions.ClearStateOC)
	// UpdateApplication = transactions.UpdateApplicationOC
	UpdateApplication = OnCompletionConstType(transactions.UpdateApplicationOC)
	// DeleteApplication = transactions.DeleteApplicationOC
	DeleteApplication = OnCompletionConstType(transactions.DeleteApplicationOC)
)
View Source
const AssemblerDefaultVersion = 1

AssemblerDefaultVersion what version of code do we emit by default AssemblerDefaultVersion is set to 1 on purpose to prevent accidental building of v1 official templates with version 2 because these templates are not aware of rekeying.

View Source
const AssemblerMaxVersion = LogicVersion

AssemblerMaxVersion is a maximum supported assembler version

View Source
const LogicVersion = 11

LogicVersion defines default assembler and max eval versions

View Source
const OnCompletionPreamble = "" /* 184-byte string literal not displayed */

OnCompletionPreamble describes what the OnCompletion constants represent.

Variables

View Source
var (
	// StackUint64 is any valid uint64
	StackUint64 = NewStackType(avmUint64, bound(0, math.MaxUint64))
	// StackBytes is any valid bytestring
	StackBytes = NewStackType(avmBytes, bound(0, maxStringSize))
	// StackAny could be Bytes or Uint64
	StackAny = StackType{
		Name:    avmAny.String(),
		AVMType: avmAny,
		Bound:   [2]uint64{0, 0},
	}
	// StackNone is used when there is no input or output to
	// an opcode
	StackNone = StackType{
		Name:    avmNone.String(),
		AVMType: avmNone,
	}

	// StackBoolean constrains the int to 1 or 0, representing True or False
	StackBoolean = NewStackType(avmUint64, bound(0, 1), "bool")
	// StackAddress represents an address
	StackAddress = NewStackType(avmBytes, static(32), "address")
	// StackBytes32 represents a bytestring that should have exactly 32 bytes
	StackBytes32 = NewStackType(avmBytes, static(32), "[32]byte")
	// StackBytes64 represents a bytestring that should have exactly 64 bytes
	StackBytes64 = NewStackType(avmBytes, static(64), "[64]byte")
	// StackBytes80 represents a bytestring that should have exactly 80 bytes
	StackBytes80 = NewStackType(avmBytes, static(80), "[80]byte")
	// StackBigInt represents a bytestring that should be treated like an int
	StackBigInt = NewStackType(avmBytes, bound(0, maxByteMathSize), "bigint")
	// StackMethodSelector represents a bytestring that should be treated like a method selector
	StackMethodSelector = NewStackType(avmBytes, static(4), "method")
	// StackStateKey represents a bytestring that can be used as a key to some storage (global/local/box)
	StackStateKey = NewStackType(avmBytes, bound(0, 64), "stateKey")
	// StackBoxName represents a bytestring that can be used as a key to a box
	StackBoxName = NewStackType(avmBytes, bound(1, 64), "boxName")

	// StackZeroUint64 is a StackUint64 with a minimum value of 0 and a maximum value of 0
	StackZeroUint64 = NewStackType(avmUint64, bound(0, 0), "0")
	// StackZeroBytes is a StackBytes with a minimum length of 0 and a maximum length of 0
	StackZeroBytes = NewStackType(avmUint64, bound(0, 0), "''")

	// AllStackTypes is a map of all the stack types we recognize
	// so that we can iterate over them in doc prep
	// and use them for opcode proto shorthand
	AllStackTypes = map[byte]StackType{
		'a': StackAny,
		'b': StackBytes,
		'i': StackUint64,
		'x': StackNone,
		'A': StackAddress,
		'I': StackBigInt,
		'T': StackBoolean,
		'M': StackMethodSelector,
		'K': StackStateKey,
		'N': StackBoxName,
	}
)
View Source
var AcctParamsFields = FieldGroup{
	"acct_params", "Fields",
	acctParamsFieldNames[:],
	acctParamsFieldSpecByName,
}

AcctParamsFields describes acct_params_get's immediates

View Source
var AppParamsFields = FieldGroup{
	"app_params", "Fields",
	appParamsFieldNames[:],
	appParamsFieldSpecByName,
}

AppParamsFields describes app_params_get's immediates

View Source
var AssetHoldingFields = FieldGroup{
	"asset_holding", "Fields",
	assetHoldingFieldNames[:],
	assetHoldingFieldSpecByName,
}

AssetHoldingFields describes asset_holding_get's immediates

View Source
var AssetParamsFields = FieldGroup{
	"asset_params", "Fields",
	assetParamsFieldNames[:],
	assetParamsFieldSpecByName,
}

AssetParamsFields describes asset_params_get's immediates

View Source
var Base64Encodings = FieldGroup{
	"base64", "Encodings",
	base64EncodingNames[:],
	base64EncodingSpecByName,
}

Base64Encodings describes the base64_encode immediate

View Source
var BlockFields = FieldGroup{
	"block", "Fields",
	blockFieldNames[:],
	blockFieldSpecByName,
}

BlockFields describes the json_ref immediate

View Source
var EcGroups = FieldGroup{
	"EC", "Groups",
	ecGroupNames[:],
	ecGroupSpecByName,
}

EcGroups collects details about the constants used to describe EcGroups

View Source
var EcdsaCurves = FieldGroup{
	"ECDSA", "Curves",
	ecdsaCurveNames[:],
	ecdsaCurveSpecByName,
}

EcdsaCurves collects details about the constants used to describe EcdsaCurves

View Source
var GlobalFieldNames [invalidGlobalField]string

GlobalFieldNames are arguments to the 'global' opcode

View Source
var GlobalFields = FieldGroup{
	"global", "Fields",
	GlobalFieldNames[:],
	globalFieldSpecByName,
}

GlobalFields has info on the global opcode's immediate

View Source
var ItxnSettableFields = FieldGroup{
	"itxn_field", "",
	itxnSettableFieldNames(),
	txnFieldSpecByName,
}

ItxnSettableFields collects info for itxn_field opcode

View Source
var JSONRefTypes = FieldGroup{
	"json_ref", "Types",
	jsonRefTypeNames[:],
	jsonRefSpecByName,
}

JSONRefTypes describes the json_ref immediate

View Source
var OnCompletionNames [invalidOnCompletionConst]string

OnCompletionNames is the string names of Txn.OnCompletion, array index is the const value

View Source
var OpGroups = map[string][]string{
	"Arithmetic":              {"+", "-", "/", "*", "<", ">", "<=", ">=", "&&", "||", "shl", "shr", "sqrt", "bitlen", "exp", "==", "!=", "!", "itob", "btoi", "%", "|", "&", "^", "~", "mulw", "addw", "divw", "divmodw", "expw"},
	"Byte Array Manipulation": {"getbit", "setbit", "getbyte", "setbyte", "concat", "len", "substring", "substring3", "extract", "extract3", "extract_uint16", "extract_uint32", "extract_uint64", "replace2", "replace3", "base64_decode", "json_ref"},
	"Byte Array Arithmetic":   {"b+", "b-", "b/", "b*", "b<", "b>", "b<=", "b>=", "b==", "b!=", "b%", "bsqrt"},
	"Byte Array Logic":        {"b|", "b&", "b^", "b~"},
	"Cryptography":            {"sha256", "keccak256", "sha512_256", "sha3_256", "sumhash512", "falcon_verify", "ed25519verify", "ed25519verify_bare", "ecdsa_verify", "ecdsa_pk_recover", "ecdsa_pk_decompress", "vrf_verify", "ec_add", "ec_scalar_mul", "ec_pairing_check", "ec_multi_scalar_mul", "ec_subgroup_check", "ec_map_to"},
	"Loading Values":          {"intcblock", "intc", "intc_0", "intc_1", "intc_2", "intc_3", "pushint", "pushints", "bytecblock", "bytec", "bytec_0", "bytec_1", "bytec_2", "bytec_3", "pushbytes", "pushbytess", "bzero", "arg", "arg_0", "arg_1", "arg_2", "arg_3", "args", "txn", "gtxn", "txna", "txnas", "gtxna", "gtxnas", "gtxns", "gtxnsa", "gtxnsas", "global", "load", "loads", "store", "stores", "gload", "gloads", "gloadss", "gaid", "gaids"},
	"Flow Control":            {"err", "bnz", "bz", "b", "return", "pop", "popn", "dup", "dup2", "dupn", "dig", "bury", "cover", "uncover", "frame_dig", "frame_bury", "swap", "select", "assert", "callsub", "proto", "retsub", "switch", "match"},
	"State Access":            {"balance", "min_balance", "app_opted_in", "app_local_get", "app_local_get_ex", "app_global_get", "app_global_get_ex", "app_local_put", "app_global_put", "app_local_del", "app_global_del", "asset_holding_get", "asset_params_get", "app_params_get", "acct_params_get", "log", "block"},
	"Box Access":              {"box_create", "box_extract", "box_replace", "box_splice", "box_del", "box_len", "box_get", "box_put", "box_resize"},
	"Inner Transactions":      {"itxn_begin", "itxn_next", "itxn_field", "itxn_submit", "itxn", "itxna", "itxnas", "gitxn", "gitxna", "gitxnas"},
}

OpGroups is groupings of ops for documentation purposes. The order here is the order args opcodes are presented, so place related opcodes consecutively, even if their opcode values are not.

View Source
var OpSpecs = []OpSpec{}/* 195 elements not displayed */

OpSpecs is the table of operations that can be assembled and evaluated.

Any changes should be reflected in README_in.md which serves as the language spec.

Note: assembly can specialize an Any return type if known at assembly-time, with ops.returns()

View Source
var OpsByName [LogicVersion + 1]map[string]OpSpec

OpsByName map for each version, mapping opcode name to OpSpec

View Source
var TxnArrayFields = FieldGroup{
	"txna", "Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/))",
	txnaFieldNames(),
	txnFieldSpecByName,
}

TxnArrayFields narows TxnFields to only have the names of array fetching opcodes

View Source
var TxnFieldNames [invalidTxnField]string

TxnFieldNames are arguments to the 'txn' family of opcodes.

View Source
var TxnFields = FieldGroup{
	"txn", "",
	TxnFieldNames[:],
	txnFieldSpecByName,
}

TxnFields contains info on the arguments to the txn* family of opcodes

View Source
var TxnScalarFields = FieldGroup{
	"txn", "Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/))",
	txnScalarFieldNames(),
	txnFieldSpecByName,
}

TxnScalarFields narrows TxnFields to only have the names of scalar fetching opcodes

TxnTypeNames is the values of Txn.Type in enum order

View Source
var TypeNameDescriptions = map[string]string{
	string(protocol.UnknownTx):         "Unknown type. Invalid transaction",
	string(protocol.PaymentTx):         "Payment",
	string(protocol.KeyRegistrationTx): "KeyRegistration",
	string(protocol.AssetConfigTx):     "AssetConfig",
	string(protocol.AssetTransferTx):   "AssetTransfer",
	string(protocol.AssetFreezeTx):     "AssetFreeze",
	string(protocol.ApplicationCallTx): "ApplicationCall",
}

TypeNameDescriptions contains extra description about a low level protocol transaction Type string, and provide a friendlier type constant name in assembler.

View Source
var VrfStandards = FieldGroup{
	"vrf_verify", "Standards",
	vrfStandardNames[:],
	vrfStandardSpecByName,
}

VrfStandards describes the json_ref immediate

Functions

func AppStateQuerying

func AppStateQuerying(
	cx *EvalContext,
	appState AppStateEnum, stateOp AppStateOpEnum,
	appID basics.AppIndex, account basics.Address, key string) basics.TealValue

AppStateQuerying is used for simulation endpoint exec trace export: it reads *new* app state after opcode that writes to app-state. Since it is collecting new/updated app state, we don't have to error again here, and thus we omit the error or non-existence case, just returning empty TealValue. Otherwise, we find the updated new state value, and wrap up with new TealValue.

func CheckContract

func CheckContract(program []byte, params *EvalParams) error

CheckContract should be faster than EvalContract. It can perform static checks and reject programs that are invalid. Prior to v4, these static checks include a cost estimate that must be low enough (controlled by params.Proto).

func CheckSignature

func CheckSignature(gi int, params *EvalParams) error

CheckSignature should be faster than EvalSignature. It can perform static checks and reject programs that are invalid. Prior to v4, these static checks include a cost estimate that must be low enough (controlled by params.Proto).

func Disassemble

func Disassemble(program []byte) (text string, err error)

Disassemble produces a text form of program bytes. AssembleString(Disassemble()) should result in the same program bytes.

func EvalApp

func EvalApp(program []byte, gi int, aid basics.AppIndex, params *EvalParams) (bool, error)

EvalApp is a lighter weight interface that doesn't return the EvalContext

func EvalSignature

func EvalSignature(gi int, params *EvalParams) (bool, error)

EvalSignature evaluates the logicsig of the ith transaction in params. A program passes successfully if it finishes with one int element on the stack that is non-zero.

func GetProgramID

func GetProgramID(program []byte) string

GetProgramID returns program or execution ID that is string representation of sha256 checksum. It is used later to link program on the user-facing side of the debugger with TEAL evaluator.

func HasStatefulOps

func HasStatefulOps(program []byte) (bool, error)

HasStatefulOps checks if the program has stateful opcodes

func HashProgram

func HashProgram(program []byte) crypto.Digest

HashProgram takes program bytes and returns the Digest This Digest can be used as an Address for a logic controlled account.

func MakeSourceMapLine

func MakeSourceMapLine(tcol, sindex, sline, scol int) string

MakeSourceMapLine creates source map mapping's line entry

func OnCompletionDescription

func OnCompletionDescription(value uint64) string

OnCompletionDescription returns extra description about OnCompletion constants

func OpDoc

func OpDoc(opName string) string

OpDoc returns a description of the op

func OpDocExtra

func OpDocExtra(opName string) string

OpDocExtra returns extra documentation text about an op

func TxnFieldToTealValue

func TxnFieldToTealValue(txn *transactions.Transaction, groupIndex int, field TxnField, arrayFieldIdx uint64, inner bool) (basics.TealValue, error)

TxnFieldToTealValue is a thin wrapper for txnFieldToStack for external use

Types

type AcctParamsField

type AcctParamsField int

AcctParamsField is an enum for `acct_params_get` opcode

const (
	// AcctBalance is the balance, with pending rewards
	AcctBalance AcctParamsField = iota
	// AcctMinBalance is algos needed for this accounts apps and assets
	AcctMinBalance
	// AcctAuthAddr is the rekeyed address if any, else ZeroAddress
	AcctAuthAddr

	// AcctTotalNumUint is the count of all uints from created global apps or opted in locals
	AcctTotalNumUint
	// AcctTotalNumByteSlice is the count of all byte slices from created global apps or opted in locals
	AcctTotalNumByteSlice

	// AcctTotalExtraAppPages is the extra code pages across all apps
	AcctTotalExtraAppPages

	// AcctTotalAppsCreated is the number of apps created by this account
	AcctTotalAppsCreated
	// AcctTotalAppsOptedIn is the number of apps opted in by this account
	AcctTotalAppsOptedIn
	// AcctTotalAssetsCreated is the number of ASAs created by this account
	AcctTotalAssetsCreated
	// AcctTotalAssets is the number of ASAs opted in by this account (always includes AcctTotalAssetsCreated)
	AcctTotalAssets
	// AcctTotalBoxes is the number of boxes created by the app this account is associated with
	AcctTotalBoxes
	// AcctTotalBoxBytes is the number of bytes in all boxes of this app account
	AcctTotalBoxBytes
)

func (AcctParamsField) String

func (i AcctParamsField) String() string

type AppParamsField

type AppParamsField int

AppParamsField is an enum for `app_params_get` opcode

const (
	// AppApprovalProgram AppParams.ApprovalProgram
	AppApprovalProgram AppParamsField = iota
	// AppClearStateProgram AppParams.ClearStateProgram
	AppClearStateProgram
	// AppGlobalNumUint AppParams.StateSchemas.GlobalStateSchema.NumUint
	AppGlobalNumUint
	// AppGlobalNumByteSlice AppParams.StateSchemas.GlobalStateSchema.NumByteSlice
	AppGlobalNumByteSlice
	// AppLocalNumUint AppParams.StateSchemas.LocalStateSchema.NumUint
	AppLocalNumUint
	// AppLocalNumByteSlice AppParams.StateSchemas.LocalStateSchema.NumByteSlice
	AppLocalNumByteSlice
	// AppExtraProgramPages AppParams.ExtraProgramPages
	AppExtraProgramPages

	// AppCreator is not *in* the Params, but it is uniquely determined.
	AppCreator

	// AppAddress is also not *in* the Params, but can be derived
	AppAddress
)

func (AppParamsField) String

func (i AppParamsField) String() string

type AppStateEnum

type AppStateEnum uint64

AppStateEnum stands for the enum of app state type, should be one of global/local/box.

const (
	// GlobalState stands for global state of an app.
	GlobalState AppStateEnum = iota + 1

	// LocalState stands for local state of an app.
	LocalState

	// BoxState stands for box storage of an app.
	BoxState
)

type AppStateOpEnum

type AppStateOpEnum uint64

AppStateOpEnum stands for the operation enum to app state, should be one of create, write, read, delete.

const (
	// AppStateWrite stands for writing to an app state.
	AppStateWrite AppStateOpEnum = iota + 1

	// AppStateDelete stands for deleting an app state.
	AppStateDelete

	// AppStateRead stands for reading from an app state.
	AppStateRead
)

type AssetHoldingField

type AssetHoldingField int

AssetHoldingField is an enum for `asset_holding_get` opcode

const (
	// AssetBalance AssetHolding.Amount
	AssetBalance AssetHoldingField = iota
	// AssetFrozen AssetHolding.Frozen
	AssetFrozen
)

func (AssetHoldingField) String

func (i AssetHoldingField) String() string

type AssetParamsField

type AssetParamsField int

AssetParamsField is an enum for `asset_params_get` opcode

const (
	// AssetTotal AssetParams.Total
	AssetTotal AssetParamsField = iota
	// AssetDecimals AssetParams.Decimals
	AssetDecimals
	// AssetDefaultFrozen AssetParams.AssetDefaultFrozen
	AssetDefaultFrozen
	// AssetUnitName AssetParams.UnitName
	AssetUnitName
	// AssetName AssetParams.AssetName
	AssetName
	// AssetURL AssetParams.URL
	AssetURL
	// AssetMetadataHash AssetParams.MetadataHash
	AssetMetadataHash
	// AssetManager AssetParams.Manager
	AssetManager
	// AssetReserve AssetParams.Reserve
	AssetReserve
	// AssetFreeze AssetParams.Freeze
	AssetFreeze
	// AssetClawback AssetParams.Clawback
	AssetClawback

	// AssetCreator is not *in* the Params, but it is uniquely determined.
	AssetCreator
)

func (AssetParamsField) String

func (i AssetParamsField) String() string

type Base64Encoding

type Base64Encoding int

Base64Encoding is an enum for the `base64decode` opcode

const (
	// URLEncoding represents the base64url encoding defined in https://www.rfc-editor.org/rfc/rfc4648.html
	URLEncoding Base64Encoding = iota
	// StdEncoding represents the standard encoding of the RFC
	StdEncoding
)

func (Base64Encoding) String

func (i Base64Encoding) String() string

type BlockField

type BlockField int

BlockField is an enum for the `block` opcode

const (
	// BlkSeed is the Block's vrf seed
	BlkSeed BlockField = iota
	// BlkTimestamp is the Block's timestamp, seconds from epoch
	BlkTimestamp
	// BlkProposer is the Block's proposer, or ZeroAddress, pre Payouts.Enabled
	BlkProposer
	// BlkFeesCollected is the sum of fees for the block, or 0, pre Payouts.Enabled
	BlkFeesCollected
	// BlkBonus is the extra amount to be paid for the given block (from FeeSink)
	BlkBonus
)

func (BlockField) String

func (i BlockField) String() string

type BoxOperation

type BoxOperation int

BoxOperation is an enum of box operation types

const (
	// BoxCreateOperation creates a box
	BoxCreateOperation BoxOperation = iota
	// BoxReadOperation reads a box
	BoxReadOperation
	// BoxWriteOperation writes to a box
	BoxWriteOperation
	// BoxDeleteOperation deletes a box
	BoxDeleteOperation
	// BoxResizeOperation resizes a box
	BoxResizeOperation
)

type BoxRef

type BoxRef struct {
	App  basics.AppIndex
	Name string
}

BoxRef is the "hydrated" form of a transactions.BoxRef - it has the actual app id, not an index

type CallFrame

type CallFrame struct {
	FrameLine int    `codec:"frameLine"`
	LabelName string `codec:"labelname"`
}

CallFrame stores the label name and the line of the subroutine. An array of CallFrames form the CallStack.

type DebugState

type DebugState struct {
	// fields set once on Register
	ExecID      string                         `codec:"execid"`
	Disassembly string                         `codec:"disasm"`
	PCOffset    []PCOffset                     `codec:"pctooffset"`
	TxnGroup    []transactions.SignedTxnWithAD `codec:"txngroup"`
	GroupIndex  int                            `codec:"gindex"`
	Proto       *config.ConsensusParams        `codec:"proto"`
	Globals     []basics.TealValue             `codec:"globals"`

	// fields updated every step
	PC           int                `codec:"pc"`
	Line         int                `codec:"line"`
	Stack        []basics.TealValue `codec:"stack"`
	Scratch      []basics.TealValue `codec:"scratch"`
	Error        string             `codec:"error"`
	OpcodeBudget int                `codec:"budget"`
	CallStack    []CallFrame        `codec:"callstack"`

	// global/local state changes are updated every step. Stateful TEAL only.
	transactions.EvalDelta
}

DebugState is a representation of the evaluation context that we encode to json and send to tealdbg

func (*DebugState) LineToPC

func (d *DebugState) LineToPC(line int) int

LineToPC converts line to pc Return 0 on unsuccess

func (*DebugState) PCToLine

func (d *DebugState) PCToLine(pc int) int

PCToLine converts pc to line Return 0 on unsuccess

type Debugger deprecated

type Debugger interface {
	// Register is fired on program creation
	Register(state *DebugState)
	// Update is fired on every step
	Update(state *DebugState)
	// Complete is called when the program exits
	Complete(state *DebugState)
}

Debugger is an interface that supports the first version of AVM debuggers. It consists of a set of functions called by eval function during AVM program execution.

Deprecated: This interface does not support non-app call or inner transactions. Use EvalTracer instead.

type EcGroup

type EcGroup int

EcGroup is an enum for `ec_` opcodes

const (
	// BN254g1 is the G1 group of BN254
	BN254g1 EcGroup = iota
	// BN254g2 is the G2 group of BN254
	BN254g2
	// BLS12_381g1 specifies the G1 group of BLS 12-381
	BLS12_381g1
	// BLS12_381g2 specifies the G2 group of BLS 12-381
	BLS12_381g2
)

func (EcGroup) String

func (i EcGroup) String() string

type EcdsaCurve

type EcdsaCurve int

EcdsaCurve is an enum for `ecdsa_` opcodes

const (
	// Secp256k1 curve for bitcoin/ethereum
	Secp256k1 EcdsaCurve = iota
	// Secp256r1 curve
	Secp256r1
)

func (EcdsaCurve) String

func (i EcdsaCurve) String() string

type EvalConstants

type EvalConstants struct {
	// MaxLogSize is the limit of total log size from n log calls in a program
	MaxLogSize uint64

	// MaxLogCalls is the limit of total log calls during a program execution
	MaxLogCalls uint64

	// UnnamedResources, if provided, allows resources to be used without being named according to
	// this policy.
	UnnamedResources UnnamedResourcePolicy
}

EvalConstants contains constant parameters that are used by opcodes during evaluation (including both real-execution and simulation).

func RuntimeEvalConstants

func RuntimeEvalConstants() EvalConstants

RuntimeEvalConstants gives a set of const params used in normal runtime of opcodes

type EvalContext

type EvalContext struct {
	*EvalParams

	Stack []stackValue

	Scratch scratchSpace
	// contains filtered or unexported fields
}

EvalContext is the execution context of AVM bytecode. It contains the full state of the running program, and tracks some of the things that the program has done, like log messages and inner transactions.

func EvalContract

func EvalContract(program []byte, gi int, aid basics.AppIndex, params *EvalParams) (bool, *EvalContext, error)

EvalContract executes stateful program as the gi'th transaction in params

func EvalSignatureFull

func EvalSignatureFull(gi int, params *EvalParams) (bool, *EvalContext, error)

EvalSignatureFull evaluates the logicsig of the ith transaction in params. A program passes successfully if it finishes with one int element on the stack that is non-zero. It returns EvalContext suitable for obtaining additional info about the execution.

func (*EvalContext) AppID

func (cx *EvalContext) AppID() basics.AppIndex

AppID returns the ID of the currently executing app. For LogicSigs it returns 0.

func (*EvalContext) Cost

func (cx *EvalContext) Cost() int

Cost return cost incurred so far

func (*EvalContext) GetOpSpec

func (cx *EvalContext) GetOpSpec() OpSpec

GetOpSpec queries for the OpSpec w.r.t. current program byte.

func (*EvalContext) GetProgram

func (cx *EvalContext) GetProgram() []byte

GetProgram queries for the current program

func (*EvalContext) GroupIndex

func (cx *EvalContext) GroupIndex() int

GroupIndex returns the group index of the transaction being evaluated

func (*EvalContext) PC

func (cx *EvalContext) PC() int

PC returns the program counter of the current application being evaluated

func (*EvalContext) ProgramVersion

func (cx *EvalContext) ProgramVersion() uint64

ProgramVersion returns the AVM version of the current program.

func (*EvalContext) RunMode

func (cx *EvalContext) RunMode() RunMode

RunMode returns the evaluation context's mode (signature or application)

type EvalError

type EvalError struct {
	Err error
	// contains filtered or unexported fields
}

EvalError indicates AVM evaluation failure

func (EvalError) Error

func (err EvalError) Error() string

Error satisfies builtin interface `error`

func (EvalError) Unwrap

func (err EvalError) Unwrap() error

type EvalParams

type EvalParams struct {
	Proto *config.ConsensusParams

	Trace *strings.Builder

	TxnGroup []transactions.SignedTxnWithAD

	SigLedger LedgerForSignature
	Ledger    LedgerForLogic

	// optional tracer
	Tracer EvalTracer

	// Amount "overpaid" by the transactions of the group.  Often 0.  When
	// positive, it can be spent by inner transactions.  Shared across a group's
	// txns, so that it can be updated (including upward, by overpaying inner
	// transactions). nil is treated as 0 (used before fee pooling is enabled).
	FeeCredit *uint64

	Specials *transactions.SpecialAddresses

	// Total pool of app call budget in a group transaction (nil before budget pooling enabled)
	PooledApplicationBudget *int

	// Total pool of logicsig budget in a group transaction (nil before lsig pooling enabled)
	PooledLogicSigBudget *int

	// SurplusReadBudget is the number of bytes from the IO budget that were not used for reading
	// in boxes before evaluation began. In other words, the txn group could have read in
	// SurplusReadBudget more box bytes, but did not.
	SurplusReadBudget uint64

	EvalConstants
	// contains filtered or unexported fields
}

EvalParams contains data that comes into condition evaluation.

func NewAppEvalParams

func NewAppEvalParams(txgroup []transactions.SignedTxnWithAD, proto *config.ConsensusParams, specials *transactions.SpecialAddresses) *EvalParams

NewAppEvalParams creates an EvalParams to use while evaluating a top-level txgroup.

func NewInnerEvalParams

func NewInnerEvalParams(txg []transactions.SignedTxnWithAD, caller *EvalContext) *EvalParams

NewInnerEvalParams creates an EvalParams to be used while evaluating an inner group txgroup

func NewSigEvalParams

func NewSigEvalParams(txgroup []transactions.SignedTxn, proto *config.ConsensusParams, ls LedgerForSignature) *EvalParams

NewSigEvalParams creates an EvalParams to be used while evaluating a group's logicsigs

func (*EvalParams) BoxDirtyBytes

func (ep *EvalParams) BoxDirtyBytes() uint64

BoxDirtyBytes returns the number of bytes that have been written to boxes

func (*EvalParams) GetApplicationAddress

func (ep *EvalParams) GetApplicationAddress(app basics.AppIndex) basics.Address

GetApplicationAddress memoizes app.Address() across a tx group's evaluation

func (*EvalParams) GetCaller

func (ep *EvalParams) GetCaller() *EvalContext

GetCaller returns the calling EvalContext if this is an inner transaction evaluation. Otherwise, this returns nil.

func (*EvalParams) GetIOBudget

func (ep *EvalParams) GetIOBudget() uint64

GetIOBudget returns the current IO budget for the group.

func (*EvalParams) RecordAD

func (ep *EvalParams) RecordAD(gi int, ad transactions.ApplyData)

RecordAD notes ApplyData information that was derived outside of the logic package. For example, after a acfg transaction is processed, the AD created by the acfg is added to the EvalParams this way.

func (*EvalParams) SetIOBudget

func (ep *EvalParams) SetIOBudget(ioBudget uint64)

SetIOBudget sets the IO budget for the group.

type EvalTracer

type EvalTracer interface {
	// BeforeBlock is called once at the beginning of block evaluation. It is passed the block header.
	BeforeBlock(hdr *bookkeeping.BlockHeader)

	// BeforeTxnGroup is called before a transaction group is executed. This includes both top-level
	// and inner transaction groups. The argument ep is the EvalParams object for the group; if the
	// group is an inner group, this is the EvalParams object for the inner group.
	//
	// Each transaction within the group calls BeforeTxn and subsequent hooks, as described in the
	// lifecycle diagram.
	BeforeTxnGroup(ep *EvalParams)

	// AfterTxnGroup is called after a transaction group has been executed. This includes both
	// top-level and inner transaction groups. The argument ep is the EvalParams object for the
	// group; if the group is an inner group, this is the EvalParams object for the inner group.
	// For top-level transaction groups, the deltas argument is the ledgercore.StateDelta changes
	// that occurred because of this transaction group. For inner transaction groups, this argument
	// is nil.
	AfterTxnGroup(ep *EvalParams, deltas *ledgercore.StateDelta, evalError error)

	// BeforeTxn is called before a transaction is executed.
	//
	// groupIndex refers to the index of the transaction in the transaction group that will be executed.
	BeforeTxn(ep *EvalParams, groupIndex int)

	// AfterTxn is called after a transaction has been executed.
	//
	// groupIndex refers to the index of the transaction in the transaction group that was just executed.
	// ad is the ApplyData result of the transaction; prefer using this instead of
	// ep.TxnGroup[groupIndex].ApplyData, since it may not be populated at this point.
	AfterTxn(ep *EvalParams, groupIndex int, ad transactions.ApplyData, evalError error)

	// BeforeProgram is called before an app or LogicSig program is evaluated.
	BeforeProgram(cx *EvalContext)

	// AfterProgram is called after an app or LogicSig program is evaluated.
	AfterProgram(cx *EvalContext, pass bool, evalError error)

	// BeforeOpcode is called before the op is evaluated
	BeforeOpcode(cx *EvalContext)

	// AfterOpcode is called after the op has been evaluated
	AfterOpcode(cx *EvalContext, evalError error)

	// AfterBlock is called after the block has finished evaluation. It will not be called in the event that an evalError
	// stops evaluation of the block.
	AfterBlock(hdr *bookkeeping.BlockHeader)
}

EvalTracer functions are called by eval function during AVM program execution, if a tracer is provided.

Refer to the lifecycle graph below for the sequence in which hooks are called.

NOTE: Arguments given to Tracer hooks (EvalParams and EvalContext) are passed by reference, they are not copies. It is therefore the responsibility of the tracer implementation to NOT modify the state of the structs passed to them. Additionally, hooks are responsible for copying the information they need from the argument structs. No guarantees are made that the referenced state will not change between hook calls. This decision was made in an effort to reduce the performance impact of tracers.

LOGICSIG LIFECYCLE GRAPH
┌─────────────────────────┐
│ LogicSig Evaluation     │
├─────────────────────────┤
│ > BeforeProgram         │
│                         │
│  ┌───────────────────┐  │
│  │ Teal Operation    │  │
│  ├───────────────────┤  │
│  │ > BeforeOpcode    │  │
│  │                   │  │
│  │ > AfterOpcode     │  │
│  └───────────────────┘  │
|   ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞   │
│                         │
│ > AfterProgram          │
└─────────────────────────┘

APP LIFECYCLE GRAPH
┌──────────────────────────────────────────────────────┐
│ Transaction Evaluation                               │
├──────────────────────────────────────────────────────┤
│ > BeforeTxnGroup                                     │
│                                                      │
│  ┌────────────────────────────────────────────────┐  │
│  │ > BeforeTxn                                    │  │
│  │                                                │  │
│  │  ┌──────────────────────────────────────────┐  │  │
│  │  │ ? App Call                               │  │  │
│  │  ├──────────────────────────────────────────┤  │  │
│  │  │ > BeforeProgram                          │  │  │
│  │  │                                          │  │  │
│  │  │  ┌────────────────────────────────────┐  │  │  │
│  │  │  │ Teal Operation                     │  │  │  │
│  │  │  ├────────────────────────────────────┤  │  │  │
│  │  │  │ > BeforeOpcode                     │  │  │  │
│  │  │  │  ┌──────────────────────────────┐  │  │  │  │
│  │  │  │  │ ? Inner Transaction Group    │  │  │  │  │
│  │  │  │  ├──────────────────────────────┤  │  │  │  │
│  │  │  │  │ > BeforeTxnGroup             │  │  │  │  │
│  │  │  │  │  ┌────────────────────────┐  │  │  │  │  │
│  │  │  │  │  │ Transaction Evaluation │  │  │  │  │  │
│  │  │  │  │  ├────────────────────────┤  │  │  │  │  │
│  │  │  │  │  │ ...                    │  │  │  │  │  │
│  │  │  │  │  └────────────────────────┘  │  │  │  │  │
│  │  │  │  │    ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞    │  │  │  │  │
│  │  │  │  │                              │  │  │  │  │
│  │  │  │  │ > AfterTxnGroup              │  │  │  │  │
│  │  │  │  └──────────────────────────────┘  │  │  │  │
│  │  │  │ > AfterOpcode                      │  │  │  │
│  │  │  └────────────────────────────────────┘  │  │  │
│  │  │    ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞    │  │  │
│  │  │                                          │  │  │
│  │  │ > AfterProgram                           │  │  │
│  │  └──────────────────────────────────────────┘  │  │
|  |    ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞    │  |
│  │                                                │  │
│  │ > AfterTxn                                     │  │
│  └────────────────────────────────────────────────┘  │
|    ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞  ⁞    |
│                                                      │
│ > AfterTxnGroup                                      │
└──────────────────────────────────────────────────────┘

Block Lifecycle Graph
┌──────────────────────────────────────────────────────┐
│ Block Evaluation                                     │
│  ┌────────────────────────────────────────────────┐  │
│  │ > BeforeBlock                                  │  │
│  │                                                │  │
│  │  ┌──────────────────────────────────────────┐  │  │
│  │  │ > Transaction/LogicSig Lifecycle         │  │  │
│  │  ├──────────────────────────────────────────┤  │  │
│  │  │  ┌────────────────────────────────────┐  │  │  │
│  │  │  │ ...                                │  │  │  │
│  │  │  └────────────────────────────────────┘  │  │  │
│  │  └──────────────────────────────────────────┘  │  │
│  ├────────────────────────────────────────────────│  │
│  │ > AfterBlock                                   │  │
│  └────────────────────────────────────────────────┘  │
└──────────────────────────────────────────────────────┘

func MakeEvalTracerDebuggerAdaptor

func MakeEvalTracerDebuggerAdaptor(debugger Debugger) EvalTracer

MakeEvalTracerDebuggerAdaptor creates an adaptor that externally adheres to the EvalTracer interface, but drives a Debugger interface

Warning: The output EvalTracer is specifically designed to be invoked under the exact same circumstances that the previous Debugger interface was invoked. This means that it will only work properly if you attach it directly to a logic.EvalParams and execute a program. If you attempt to run this EvalTracer under a different entry point (such as by attaching it to a BlockEvaluator), it WILL NOT work properly.

type FieldGroup

type FieldGroup struct {
	Name  string
	Doc   string
	Names []string
	// contains filtered or unexported fields
}

FieldGroup binds all the info for a field (names, int value, spec access) so they can be attached to opcodes and used by doc generation

func (*FieldGroup) SpecByName

func (fg *FieldGroup) SpecByName(name string) (FieldSpec, bool)

SpecByName returns a FieldsSpec for a name, respecting the "sparseness" of the Names array to hide some names

type FieldSpec

type FieldSpec interface {
	Field() byte
	Type() StackType
	OpVersion() uint64
	Note() string
	Version() uint64
}

FieldSpec unifies the various specs for assembly, disassembly, and doc generation.

type GlobalField

type GlobalField uint64

GlobalField is an enum for `global` opcode

const (
	// MinTxnFee ConsensusParams.MinTxnFee
	MinTxnFee GlobalField = iota
	// MinBalance ConsensusParams.MinBalance
	MinBalance
	// MaxTxnLife ConsensusParams.MaxTxnLife
	MaxTxnLife
	// ZeroAddress [32]byte{0...}
	ZeroAddress
	// GroupSize len(txn group)
	GroupSize

	// LogicSigVersion ConsensusParams.LogicSigVersion
	LogicSigVersion
	// Round basics.Round
	Round
	// LatestTimestamp uint64
	LatestTimestamp
	// CurrentApplicationID uint64
	CurrentApplicationID

	// CreatorAddress [32]byte
	CreatorAddress

	// CurrentApplicationAddress [32]byte
	CurrentApplicationAddress
	// GroupID [32]byte
	GroupID

	// OpcodeBudget The remaining budget available for execution
	OpcodeBudget

	// CallerApplicationID The ID of the caller app, else 0
	CallerApplicationID

	// CallerApplicationAddress The Address of the caller app, else ZeroAddress
	CallerApplicationAddress

	// AssetCreateMinBalance is the additional minimum balance required to
	// create an asset (which also opts an account into that asset)
	AssetCreateMinBalance

	// AssetOptInMinBalance is the additional minimum balance required to opt in to an asset
	AssetOptInMinBalance

	// GenesisHash is the genesis hash for the network
	GenesisHash
)

func (GlobalField) String

func (i GlobalField) String() string

type JSONRefType

type JSONRefType int

JSONRefType is an enum for the `json_ref` opcode

const (
	// JSONString represents string json value
	JSONString JSONRefType = iota
	// JSONUint64 represents uint64 json value
	JSONUint64
	// JSONObject represents json object
	JSONObject
)

func (JSONRefType) String

func (i JSONRefType) String() string

type LedgerForLogic

type LedgerForLogic interface {
	AccountData(addr basics.Address) (ledgercore.AccountData, error)
	Authorizer(addr basics.Address) (basics.Address, error)
	Round() basics.Round
	PrevTimestamp() int64

	AssetHolding(addr basics.Address, assetIdx basics.AssetIndex) (basics.AssetHolding, error)
	AssetParams(aidx basics.AssetIndex) (basics.AssetParams, basics.Address, error)
	AppParams(aidx basics.AppIndex) (basics.AppParams, basics.Address, error)
	OptedIn(addr basics.Address, appIdx basics.AppIndex) (bool, error)

	GetLocal(addr basics.Address, appIdx basics.AppIndex, key string, accountIdx uint64) (value basics.TealValue, exists bool, err error)
	SetLocal(addr basics.Address, appIdx basics.AppIndex, key string, value basics.TealValue, accountIdx uint64) error
	DelLocal(addr basics.Address, appIdx basics.AppIndex, key string, accountIdx uint64) error

	GetGlobal(appIdx basics.AppIndex, key string) (value basics.TealValue, exists bool, err error)
	SetGlobal(appIdx basics.AppIndex, key string, value basics.TealValue) error
	DelGlobal(appIdx basics.AppIndex, key string) error

	NewBox(appIdx basics.AppIndex, key string, value []byte, appAddr basics.Address) error
	GetBox(appIdx basics.AppIndex, key string) ([]byte, bool, error)
	SetBox(appIdx basics.AppIndex, key string, value []byte) error
	DelBox(appIdx basics.AppIndex, key string, appAddr basics.Address) (bool, error)

	Perform(gi int, ep *EvalParams) error
	Counter() uint64
}

LedgerForLogic represents ledger API for Stateful TEAL program

type LedgerForSignature

type LedgerForSignature interface {
	BlockHdr(basics.Round) (bookkeeping.BlockHeader, error)
	GenesisHash() crypto.Digest
}

LedgerForSignature represents the parts of Ledger that LogicSigs can see. It only exposes things that consensus has already agreed upon, so it is "stateless" for signature purposes.

type Msg

type Msg struct {
	ProgramHash crypto.Digest `codec:"p"`
	Data        []byte        `codec:"d"`
	// contains filtered or unexported fields
}

Msg is data meant to be signed and then verified with the ed25519verify opcode.

func (Msg) ToBeHashed

func (msg Msg) ToBeHashed() (protocol.HashID, []byte)

ToBeHashed implements crypto.Hashable

type NoHeaderLedger

type NoHeaderLedger struct {
}

NoHeaderLedger is intended for debugging TEAL in isolation(no real ledger) in which it is reasonable to preclude the use of `block`, `txn LastValidTime`. Also `global GenesisHash` is just a static value.

func (NoHeaderLedger) BlockHdr

BlockHdr always errors

func (NoHeaderLedger) GenesisHash

func (NoHeaderLedger) GenesisHash() crypto.Digest

GenesisHash returns a fixed value

type NullEvalTracer

type NullEvalTracer struct{}

NullEvalTracer implements EvalTracer, but all of its hook methods do nothing

func (NullEvalTracer) AfterBlock

func (n NullEvalTracer) AfterBlock(hdr *bookkeeping.BlockHeader)

AfterBlock does nothing

func (NullEvalTracer) AfterOpcode

func (n NullEvalTracer) AfterOpcode(cx *EvalContext, evalError error)

AfterOpcode does nothing

func (NullEvalTracer) AfterProgram

func (n NullEvalTracer) AfterProgram(cx *EvalContext, pass bool, evalError error)

AfterProgram does nothing

func (NullEvalTracer) AfterTxn

func (n NullEvalTracer) AfterTxn(ep *EvalParams, groupIndex int, ad transactions.ApplyData, evalError error)

AfterTxn does nothing

func (NullEvalTracer) AfterTxnGroup

func (n NullEvalTracer) AfterTxnGroup(ep *EvalParams, deltas *ledgercore.StateDelta, evalError error)

AfterTxnGroup does nothing

func (NullEvalTracer) BeforeBlock

func (n NullEvalTracer) BeforeBlock(hdr *bookkeeping.BlockHeader)

BeforeBlock does nothing

func (NullEvalTracer) BeforeOpcode

func (n NullEvalTracer) BeforeOpcode(cx *EvalContext)

BeforeOpcode does nothing

func (NullEvalTracer) BeforeProgram

func (n NullEvalTracer) BeforeProgram(cx *EvalContext)

BeforeProgram does nothing

func (NullEvalTracer) BeforeTxn

func (n NullEvalTracer) BeforeTxn(ep *EvalParams, groupIndex int)

BeforeTxn does nothing

func (NullEvalTracer) BeforeTxnGroup

func (n NullEvalTracer) BeforeTxnGroup(ep *EvalParams)

BeforeTxnGroup does nothing

type OnCompletionConstType

type OnCompletionConstType transactions.OnCompletion

OnCompletionConstType is the same as transactions.OnCompletion

func (OnCompletionConstType) String

func (i OnCompletionConstType) String() string

type OpDesc

type OpDesc struct {
	Short      string
	Extra      string
	Immediates []string
}

OpDesc contains the human readable descriptions of opcodes and their immediate arguments.

type OpDetails

type OpDetails struct {
	Modes RunMode // all modes that opcode can run in. i.e (cx.mode & Modes) != 0 allows

	FullCost   linearCost  // if non-zero, the cost of the opcode, no immediates matter
	Size       int         // if non-zero, the known size of opcode. if 0, check() determines.
	Immediates []immediate // details of each immediate arg to opcode
	// contains filtered or unexported fields
}

OpDetails records details such as non-standard costs, immediate arguments, or dynamic layout controlled by a check function. These objects are mostly built with constructor functions, so it's cleaner to have defaults set here, rather than in line after line of OpSpecs.

func (*OpDetails) Cost

func (d *OpDetails) Cost(program []byte, pc int, stack []stackValue) int

Cost computes the cost of the opcode, given details about how it is used, both static (the program, which can be used to find the immediate values supplied), and dynamic (the stack, which can be used to find the run-time arguments supplied). Cost is used at run-time. docCost returns similar information in human-readable form.

type OpImmediateDetails

type OpImmediateDetails struct {
	Comment   string `json:",omitempty"`
	Encoding  string `json:",omitempty"`
	Name      string `json:",omitempty"`
	Reference string `json:",omitempty"`
}

OpImmediateDetails contains information about the an immediate argument for a given opcode, combining OpSpec details with the extra note in the opcodeImmediateNotes map

func OpImmediateDetailsFromSpec

func OpImmediateDetailsFromSpec(spec OpSpec) []OpImmediateDetails

OpImmediateDetailsFromSpec provides a slice of OpImmediateDetails for a given OpSpec

type OpSpec

type OpSpec struct {
	Opcode byte
	Name   string

	Proto
	Version   uint64 // AVM version opcode introduced
	OpDetails        // Special cost or bytecode layout considerations
	// contains filtered or unexported fields
}

OpSpec defines an opcode

func OpcodesByVersion

func OpcodesByVersion(version uint64) []OpSpec

OpcodesByVersion returns list of opcodes available in a specific version of TEAL by copying v1 opcodes to v2, and then on to v3 to create a full list

func (*OpSpec) AlwaysExits

func (spec *OpSpec) AlwaysExits() bool

AlwaysExits is true iff the opcode always ends the program.

func (*OpSpec) DocCost

func (spec *OpSpec) DocCost(version uint64) string

DocCost returns the cost of the opcode in human-readable form.

type OpStream

type OpStream struct {
	Version  uint64
	Trace    *strings.Builder
	Warnings []sourceError // informational warnings, shouldn't stop assembly
	Errors   []sourceError // errors that should prevent final assembly
	Program  []byte        // Final program bytes. Will stay nil if any errors

	// map opcode offsets to source location
	OffsetToSource map[int]SourceLocation

	HasStatefulOps bool
	// contains filtered or unexported fields
}

OpStream accumulates state, including the final program, during assembly.

func AssembleString

func AssembleString(text string) (*OpStream, error)

AssembleString takes an entire program in a string and assembles it to bytecode using AssemblerDefaultVersion

func AssembleStringWithVersion

func AssembleStringWithVersion(text string, version uint64) (*OpStream, error)

AssembleStringWithVersion takes an entire program in a string and assembles it to bytecode using the assembler version specified. If version is assemblerNoVersion it uses #pragma version or fallsback to AssemblerDefaultVersion. OpStream is returned to allow access to warnings, (multiple) errors, or the PC to source line mapping. Note that AssemblerDefaultVersion is not the latest supported version, and therefore we might need to pass in explicitly a higher version.

func (*OpStream) ReportMultipleErrors

func (ops *OpStream) ReportMultipleErrors(fname string, writer io.Writer)

ReportMultipleErrors issues accumulated warnings and outputs errors to an io.Writer. In the case of exactly 1 error and no warnings, a slightly different format is provided to handle the cases when the original error is or isn't reported elsewhere. In the case of > 10 errors, only the first 10 errors will be reported.

type PCOffset

type PCOffset struct {
	PC     int `codec:"pc"`
	Offset int `codec:"offset"`
}

PCOffset stores the mapping from a program counter value to an offset in the disassembly of the bytecode

type Program

type Program []byte

Program is byte code to be interpreted for validating transactions.

func (Program) ToBeHashed

func (lsl Program) ToBeHashed() (protocol.HashID, []byte)

ToBeHashed implements crypto.Hashable

type ProgramKnowledge

type ProgramKnowledge struct {
	// contains filtered or unexported fields
}

ProgramKnowledge tracks statically known information as we assemble

type Proto

type Proto struct {
	Arg    typedList // what gets popped from the stack
	Return typedList // what gets pushed to the stack

	// StackExplain is the pointer to the function used in debugging process during simulation:
	// - on default construction, StackExplain relies on Arg and Return count.
	// - otherwise, we need to explicitly infer from EvalContext, by registering through explain function
	StackExplain debugStackExplain

	// AppStateExplain is the pointer to the function used for debugging in simulation:
	// - for an opcode not touching app's local/global/box state, this pointer is nil.
	// - otherwise, we call this method and check the operation of an opcode on app's state.
	AppStateExplain stateChangeExplain
}

Proto describes the "stack behavior" of an opcode, what it pops as arguments and pushes onto the stack as return values.

type RunMode

type RunMode uint64

RunMode is a bitset of logic evaluation modes. There are currently two such modes: Signature and Application.

const (
	// ModeSig is LogicSig execution
	ModeSig RunMode = 1 << iota

	// ModeApp is application/contract execution
	ModeApp
)

func (RunMode) Any

func (r RunMode) Any() bool

Any checks if this mode bitset represents any evaluation mode

func (RunMode) String

func (r RunMode) String() string

type SourceLocation

type SourceLocation struct {
	// Line is the line number, starting at 0.
	Line int
	// Column is the column number, starting at 0.
	Column int
}

SourceLocation points to a specific location in a source file.

type SourceMap

type SourceMap struct {
	Version    int      `json:"version"`
	File       string   `json:"file,omitempty"`
	SourceRoot string   `json:"sourceRoot,omitempty"`
	Sources    []string `json:"sources"`
	Names      []string `json:"names"`
	Mappings   string   `json:"mappings"`
}

SourceMap contains details from the source to assembly process. Currently, contains the map between TEAL source line to the assembled bytecode position and details about the template variables contained in the source file.

func GetSourceMap

func GetSourceMap(sourceNames []string, offsetToLocation map[int]SourceLocation) SourceMap

GetSourceMap returns a struct containing details about the assembled file and encoded mappings to the source file.

type StackType

type StackType struct {
	Name    string // alias (address, boolean, ...) or derived name [5]byte
	AVMType avmType
	Bound   [2]uint64 // represents max/min value for uint64 or max/min length for byte[]
}

StackType describes the type of a value on the operand stack

func NewStackType

func NewStackType(at avmType, bounds [2]uint64, stname ...string) StackType

NewStackType Initializes a new StackType with fields passed

func (StackType) String

func (st StackType) String() string

func (StackType) Typed

func (st StackType) Typed() bool

Typed tells whether the StackType is a specific concrete type.

type StackTypes

type StackTypes []StackType

StackTypes is an alias for a list of StackType with syntactic sugar

type TxnField

type TxnField int

TxnField is an enum type for `txn` and `gtxn`

const (
	// Sender Transaction.Sender
	Sender TxnField = iota
	// Fee Transaction.Fee
	Fee
	// FirstValid Transaction.FirstValid
	FirstValid
	// FirstValidTime timestamp of block(FirstValid-1)
	FirstValidTime
	// LastValid Transaction.LastValid
	LastValid
	// Note Transaction.Note
	Note
	// Lease Transaction.Lease
	Lease
	// Receiver Transaction.Receiver
	Receiver
	// Amount Transaction.Amount
	Amount
	// CloseRemainderTo Transaction.CloseRemainderTo
	CloseRemainderTo
	// VotePK Transaction.VotePK
	VotePK
	// SelectionPK Transaction.SelectionPK
	SelectionPK
	// VoteFirst Transaction.VoteFirst
	VoteFirst
	// VoteLast Transaction.VoteLast
	VoteLast
	// VoteKeyDilution Transaction.VoteKeyDilution
	VoteKeyDilution
	// Type Transaction.Type
	Type
	// TypeEnum int(Transaction.Type)
	TypeEnum
	// XferAsset Transaction.XferAsset
	XferAsset
	// AssetAmount Transaction.AssetAmount
	AssetAmount
	// AssetSender Transaction.AssetSender
	AssetSender
	// AssetReceiver Transaction.AssetReceiver
	AssetReceiver
	// AssetCloseTo Transaction.AssetCloseTo
	AssetCloseTo
	// GroupIndex i for txngroup[i] == Txn
	GroupIndex
	// TxID Transaction.ID()
	TxID
	// ApplicationID basics.AppIndex
	ApplicationID
	// OnCompletion OnCompletion
	OnCompletion
	// ApplicationArgs  [][]byte
	ApplicationArgs
	// NumAppArgs len(ApplicationArgs)
	NumAppArgs
	// Accounts []basics.Address
	Accounts
	// NumAccounts len(Accounts)
	NumAccounts
	// ApprovalProgram []byte
	ApprovalProgram
	// ClearStateProgram []byte
	ClearStateProgram
	// RekeyTo basics.Address
	RekeyTo
	// ConfigAsset basics.AssetIndex
	ConfigAsset
	// ConfigAssetTotal AssetParams.Total
	ConfigAssetTotal
	// ConfigAssetDecimals AssetParams.Decimals
	ConfigAssetDecimals
	// ConfigAssetDefaultFrozen AssetParams.AssetDefaultFrozen
	ConfigAssetDefaultFrozen
	// ConfigAssetUnitName AssetParams.UnitName
	ConfigAssetUnitName
	// ConfigAssetName AssetParams.AssetName
	ConfigAssetName
	// ConfigAssetURL AssetParams.URL
	ConfigAssetURL
	// ConfigAssetMetadataHash AssetParams.MetadataHash
	ConfigAssetMetadataHash
	// ConfigAssetManager AssetParams.Manager
	ConfigAssetManager
	// ConfigAssetReserve AssetParams.Reserve
	ConfigAssetReserve
	// ConfigAssetFreeze AssetParams.Freeze
	ConfigAssetFreeze
	// ConfigAssetClawback AssetParams.Clawback
	ConfigAssetClawback
	//FreezeAsset  basics.AssetIndex
	FreezeAsset
	// FreezeAssetAccount basics.Address
	FreezeAssetAccount
	// FreezeAssetFrozen bool
	FreezeAssetFrozen
	// Assets []basics.AssetIndex
	Assets
	// NumAssets len(ForeignAssets)
	NumAssets
	// Applications []basics.AppIndex
	Applications
	// NumApplications len(ForeignApps)
	NumApplications

	// GlobalNumUint uint64
	GlobalNumUint
	// GlobalNumByteSlice uint64
	GlobalNumByteSlice
	// LocalNumUint uint64
	LocalNumUint
	// LocalNumByteSlice uint64
	LocalNumByteSlice

	// ExtraProgramPages AppParams.ExtraProgramPages
	ExtraProgramPages

	// Nonparticipation Transaction.Nonparticipation
	Nonparticipation

	// Logs Transaction.ApplyData.EvalDelta.Logs
	Logs

	// NumLogs len(Logs)
	NumLogs

	// CreatedAssetID Transaction.ApplyData.EvalDelta.ConfigAsset
	CreatedAssetID

	// CreatedApplicationID Transaction.ApplyData.EvalDelta.ApplicationID
	CreatedApplicationID

	// LastLog Logs[len(Logs)-1]
	LastLog

	// StateProofPK Transaction.StateProofPK
	StateProofPK

	// ApprovalProgramPages [][]byte
	ApprovalProgramPages

	// NumApprovalProgramPages = len(ApprovalProgramPages) // 4096
	NumApprovalProgramPages

	// ClearStateProgramPages [][]byte
	ClearStateProgramPages

	// NumClearStateProgramPages = len(ClearStateProgramPages) // 4096
	NumClearStateProgramPages
)

func (TxnField) String

func (i TxnField) String() string

type UnnamedResourcePolicy

type UnnamedResourcePolicy interface {
	AvailableAccount(addr basics.Address) bool
	AvailableAsset(asset basics.AssetIndex) bool
	AvailableApp(app basics.AppIndex) bool
	AllowsHolding(addr basics.Address, asset basics.AssetIndex) bool
	AllowsLocal(addr basics.Address, app basics.AppIndex) bool
	AvailableBox(app basics.AppIndex, name string, operation BoxOperation, createSize uint64) bool
}

UnnamedResourcePolicy is an interface that defines the policy for allowing unnamed resources. This should only be used during simulation or debugging.

type VerCost

type VerCost struct {
	From int
	To   int
	// Cost is a human readable string to describe costs. Simple opcodes are
	// just an integer, but some opcodes have field or stack dependencies.
	Cost string
}

VerCost indicates the cost of an operation over the range of LogicVersions from From to To.

type VrfStandard

type VrfStandard int

VrfStandard is an enum for the `vrf_verify` opcode

const (
	// VrfAlgorand is the built-in VRF of the Algorand chain
	VrfAlgorand VrfStandard = iota
)

func (VrfStandard) String

func (i VrfStandard) String() string

type WebDebugger

type WebDebugger struct {
	URL string
}

WebDebugger represents a connection to tealdbg

func (*WebDebugger) Complete

func (dbg *WebDebugger) Complete(state *DebugState)

Complete sends state to remote debugger

func (*WebDebugger) Register

func (dbg *WebDebugger) Register(state *DebugState)

Register sends state to remote debugger

func (*WebDebugger) Update

func (dbg *WebDebugger) Update(state *DebugState)

Update sends state to remote debugger

type Writer

type Writer interface {
	Write([]byte) (int, error)
	WriteByte(c byte) error
}

Writer is what we want here. Satisfied by bufio.Buffer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL