logic

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 28 Imported by: 0

README

Transaction Execution Approval Language (TEAL)

TEAL is a bytecode based stack language that executes inside Algorand transactions to check the parameters of the transaction and approve the transaction as if by a signature. Programs have read-only access to the transaction they are attached to, transactions in their atomic transaction group, and a few global values. Programs cannot modify or create transactions, only reject or approve them. Approval is signaled by finishing with the stack containing a single non-zero uint64 value.

TEAL programs should be short and run fast as they are run in-line along with signature checking, transaction balance rule checking, and other checks during block assembly and validation. Many useful programs are less than 100 instructions.

The Stack

The stack starts empty and contains values of either uint64 or bytes (bytes are implemented in Go as a []byte slice). Most operations act on the stack, popping arguments from it and pushing results to it.

The maximum stack depth is currently 1000.

Scratch Space

In addition to the stack there are 256 positions of scratch space, also uint64-bytes union values, accessed by the load and store ops moving data from or to scratch space, respectively.

Execution Environment

TEAL runs in Algorand nodes 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 TEAL 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 TEAL program. Args are an array of byte strings. A common pattern would be to have the key to unlock some contract as an Arg. Args are recorded on the blockchain and publicly visible when the transaction is submitted to the network.

A program can either authorize some delegated action on a normal private key signed or multisig account or be wholly in charge of a contract account.

  • If the account has signed the program (an ed25519 signature on "Program" concatenated with the program bytes) 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.
  • If the SHA512_256 hash of the program (prefixed by "Program") is equal to the transaction Sender address 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 TEAL bytecode plus the length of any Args must add up to less than 1000 bytes (consensus parameter LogicSigMaxSize). Each TEAL op has an associated cost and the program cost must total less than 20000 (consensus parameter LogicSigMaxCost). Most ops have a cost of 1, but a few slow crypto ops are much higher. Prior to v4, program costs was estimated as the static sum of all opcode costs in a program (ignoring conditionals that might skip some code). Beginning with v4, a program's cost is tracked dynamically, while being evaluated. If the program exceeds its budget, it fails.

Execution modes

Starting from version 2 TEAL evaluator can run programs in two modes:

  1. Signature verification (stateless)
  2. Application run (stateful)

Differences between modes include:

  1. Max program length (consensus parameters LogicSigMaxSize, MaxApprovalProgramLen and MaxClearStateProgramLen)
  2. Max program cost (consensus parameters LogicSigMaxCost, MaxAppProgramCost)
  3. Opcodes availability. For example, all stateful operations are only available in stateful mode. Refer to opcodes document for details.

Constants

Constants are loaded into the environment into storage separate from the stack. They can then be pushed onto the stack by referring to the type and index. This makes for efficient re-use of byte constants used for account addresses, etc.

The assembler will hide most of this, allowing simple use of int 1234 and byte 0xcafed00d. These constants will automatically get assembled into int and byte pages of constants, de-duplicated, and operations to load them from constant storage space inserted.

Constants are loaded into the environment by two opcodes, intcblock and bytecblock. Both of these use proto-buf style variable length unsigned int, reproduced here. The intcblock opcode is followed by a varuint specifying the length of the array and then that number of varuint. The bytecblock opcode is followed by a varuint array length then that number of pairs of (varuint, bytes) length prefixed byte strings. This should efficiently load 32 and 64 byte constants which will be common as addresses, hashes, and signatures.

Constants are pushed onto the stack by intc, intc_[0123], bytec, and bytec_[0123]. The assembler will handle converting int N or byte N into the appropriate form of the instruction needed.

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 Constant 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 Constant 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 panic if the wrong type value is on the stack.

Many programs need only a few dozen instructions. The instruction set has some optimization built in. intc, bytec, and arg take an immediate value byte, making a 2-byte op to load a value onto the stack, but they also have single byte versions for loading the most common constant values. Any program will benefit from having a few common values loaded with a smaller one byte opcode. Cryptographic hashes and ed25519verify are single byte opcodes with powerful libraries behind them. These operations still take more time than other ops (and this is reflected in the cost of each op and the cost limit of a program) but are efficient in compiled code space.

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

Some operations 'panic' and immediately end execution of the program. A transaction checked by a program that panics is not valid. A contract account governed by a buggy program might not have a way to get assets back out of it. Code carefully.

Arithmetic, Logic, and Cryptographic Operations

For one-argument ops, X is the last element on the stack, which is typically replaced by a new value.

For two-argument ops, A is the previous element on the stack and B is the last element on the stack. These typically result in popping A and B from the stack and pushing the result.

Op Description
sha256 SHA256 hash of value X, yields [32]byte
keccak256 Keccak256 hash of value X, yields [32]byte
sha512_256 SHA512_256 hash of value X, 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}
+ A plus B. Panic on overflow.
- A minus B. Panic if B > A.
/ A divided by B. Panic if B == 0.
* A times B. Panic 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 X such that X^2 <= A
bitlen The index of the highest bit in A. If A is a byte-array, it is interpreted as a big-endian unsigned integer
exp A raised to the Bth power. Panic if A == B == 0 and on overflow
== A is equal to B => {0 or 1}
!= A is not equal to B => {0 or 1}
! X == 0 yields 1; else 0
len yields length of byte value X
itob converts uint64 X to big endian bytes
btoi converts bytes X as big endian to uint64
% A modulo B. Panic if B == 0.
| A bitwise-or B
& A bitwise-and B
^ A bitwise-xor B
~ bitwise invert value X
mulw A times B out to 128-bit long result as low (top) and high uint64 values on the stack
addw A plus B out to 128-bit long result as sum (top) and carry-bit uint64 values on the stack
divmodw Pop four uint64 values. The deepest two are interpreted as a uint128 dividend (deepest value is high word), the top two are interpreted as a uint128 divisor. Four uint64 values are pushed to the stack. The deepest two are the quotient (deeper value is the high uint64). The top two are the remainder, low bits on top.
expw A raised to the Bth power as a 128-bit long result as low (top) and high uint64 values on the stack. Panic if A == B == 0 or if the results exceeds 2^128-1
getbit pop a target A (integer or byte-array), and index B. Push the Bth bit of A.
setbit pop a target A, index B, and bit C. Set the Bth bit of A to C, and push the result
getbyte pop a byte-array A and integer B. Extract the Bth byte of A and push it as an integer
setbyte pop a byte-array A, integer B, and small integer C (between 0..255). Set the Bth byte of A to C, and push the result
concat pop two byte-arrays A and B and join them, push the result
substring s e pop a byte-array A. For immediate values in 0..255 S and E: extract a range of bytes from A starting at S up to but not including E, push the substring result. If E < S, or either is larger than the array length, the program fails
substring3 pop a byte-array A and two integers B and C. Extract a range of bytes from A starting at B up to but not including C, push the substring result. If C < B, or either is larger than the array length, the program fails

These opcodes take and return byte-array values that are interpreted as big-endian unsigned integers. Returned values are the shortest byte-array that can represent the returned value. For example, the zero value is the empty byte-array.

Input lengths are limited to maximum length 64, which represents a 512 bit unsigned integer.

Op Description
b+ A plus B, where A and B are byte-arrays interpreted as big-endian unsigned integers
b- A minus B, where A and B are byte-arrays interpreted as big-endian unsigned integers. Panic on underflow.
b/ A divided by B, where A and B are byte-arrays interpreted as big-endian unsigned integers. Panic if B is zero.
b* A times B, where A and B are byte-arrays interpreted as big-endian unsigned integers.
b< A is less than B, where A and B are byte-arrays interpreted as big-endian unsigned integers => { 0 or 1}
b> A is greater than B, where A and B are byte-arrays interpreted as big-endian unsigned integers => { 0 or 1}
b<= A is less than or equal to B, where A and B are byte-arrays interpreted as big-endian unsigned integers => { 0 or 1}
b>= A is greater than or equal to B, where A and B are byte-arrays interpreted as big-endian unsigned integers => { 0 or 1}
b== A is equals to B, where A and B are byte-arrays interpreted as big-endian unsigned integers => { 0 or 1}
b!= A is not equal to B, where A and B are byte-arrays interpreted as big-endian unsigned integers => { 0 or 1}
b% A modulo B, where A and B are byte-arrays interpreted as big-endian unsigned integers. Panic if B is zero.

These opcodes operate on the bits of byte-array values. The shorter array is interpeted 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 longest input. Therefore, unlike array arithmetic, these results may contain leading zero bytes.

Op Description
b| A bitwise-or B, where A and B are byte-arrays, zero-left extended to the greater of their lengths
b& A bitwise-and B, where A and B are byte-arrays, zero-left extended to the greater of their lengths
b^ A bitwise-xor B, where A and B are byte-arrays, zero-left extended to the greater of their lengths
b~ A with all bits inverted
Loading Values

Opcodes for getting data onto the stack.

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

Op Description
intcblock uint ... prepare block of uint64 constants for use by intc
intc i push Ith constant from intcblock to stack
intc_0 push constant 0 from intcblock to stack
intc_1 push constant 1 from intcblock to stack
intc_2 push constant 2 from intcblock to stack
intc_3 push constant 3 from intcblock to stack
pushint uint push immediate UINT to the stack as an integer
bytecblock bytes ... prepare block of byte-array constants for use by bytec
bytec i push Ith constant from bytecblock to stack
bytec_0 push constant 0 from bytecblock to stack
bytec_1 push constant 1 from bytecblock to stack
bytec_2 push constant 2 from bytecblock to stack
bytec_3 push constant 3 from bytecblock to stack
pushbytes bytes push the following program bytes to the stack
bzero push a byte-array of length A, containing all zero bytes
arg n push Nth LogicSig argument to stack
arg_0 push LogicSig argument 0 to stack
arg_1 push LogicSig argument 1 to stack
arg_2 push LogicSig argument 2 to stack
arg_3 push LogicSig argument 3 to stack
txn f push field F of current transaction to stack
gtxn t f push field F of the Tth transaction in the current group
txna f i push Ith value of the array field F of the current transaction
gtxna t f i push Ith value of the array field F from the Tth transaction in the current group
gtxns f push field F of the Ath transaction in the current group
gtxnsa f i push Ith value of the array field F from the Ath transaction in the current group
global f push value from globals to stack
load i copy a value from scratch space to the stack
store i pop a value from the stack and store to scratch space
gload t i push Ith scratch space index of the Tth transaction in the current group
gloads i push Ith scratch space index of the Ath transaction in the current group

Transaction Fields

Index Name Type Notes
0 Sender []byte 32 byte address
1 Fee uint64 micro-Algos
2 FirstValid uint64 round number
3 FirstValidTime uint64 Causes program to fail; reserved for future use
4 LastValid uint64 round number
5 Note []byte
6 Lease []byte
7 Receiver []byte 32 byte address
8 Amount uint64 micro-Algos
9 CloseRemainderTo []byte 32 byte address
10 VotePK []byte 32 byte address
11 SelectionPK []byte 32 byte address
12 VoteFirst uint64
13 VoteLast uint64
14 VoteKeyDilution uint64
15 Type []byte
16 TypeEnum uint64 See table below
17 XferAsset uint64 Asset ID
18 AssetAmount uint64 value in Asset's units
19 AssetSender []byte 32 byte address. Causes clawback of all value of asset from AssetSender if Sender is the Clawback address of the asset.
20 AssetReceiver []byte 32 byte address
21 AssetCloseTo []byte 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 []byte The computed ID for this transaction. 32 bytes.
24 ApplicationID uint64 ApplicationID from ApplicationCall transaction. LogicSigVersion >= 2.
25 OnCompletion uint64 ApplicationCall transaction on completion action. LogicSigVersion >= 2.
26 ApplicationArgs []byte Arguments passed to the application in the ApplicationCall transaction. LogicSigVersion >= 2.
27 NumAppArgs uint64 Number of ApplicationArgs. LogicSigVersion >= 2.
28 Accounts []byte Accounts listed in the ApplicationCall transaction. LogicSigVersion >= 2.
29 NumAccounts uint64 Number of Accounts. LogicSigVersion >= 2.
30 ApprovalProgram []byte Approval program. LogicSigVersion >= 2.
31 ClearStateProgram []byte Clear state program. LogicSigVersion >= 2.
32 RekeyTo []byte 32 byte Sender's new AuthAddr. LogicSigVersion >= 2.
33 ConfigAsset uint64 Asset ID in asset config transaction. LogicSigVersion >= 2.
34 ConfigAssetTotal uint64 Total number of units of this asset created. LogicSigVersion >= 2.
35 ConfigAssetDecimals uint64 Number of digits to display after the decimal place when displaying the asset. LogicSigVersion >= 2.
36 ConfigAssetDefaultFrozen uint64 Whether the asset's slots are frozen by default or not, 0 or 1. LogicSigVersion >= 2.
37 ConfigAssetUnitName []byte Unit name of the asset. LogicSigVersion >= 2.
38 ConfigAssetName []byte The asset name. LogicSigVersion >= 2.
39 ConfigAssetURL []byte URL. LogicSigVersion >= 2.
40 ConfigAssetMetadataHash []byte 32 byte commitment to some unspecified asset metadata. LogicSigVersion >= 2.
41 ConfigAssetManager []byte 32 byte address. LogicSigVersion >= 2.
42 ConfigAssetReserve []byte 32 byte address. LogicSigVersion >= 2.
43 ConfigAssetFreeze []byte 32 byte address. LogicSigVersion >= 2.
44 ConfigAssetClawback []byte 32 byte address. LogicSigVersion >= 2.
45 FreezeAsset uint64 Asset ID being frozen or un-frozen. LogicSigVersion >= 2.
46 FreezeAssetAccount []byte 32 byte address of the account whose asset slot is being frozen or un-frozen. LogicSigVersion >= 2.
47 FreezeAssetFrozen uint64 The new frozen value, 0 or 1. LogicSigVersion >= 2.
48 Assets uint64 Foreign Assets listed in the ApplicationCall transaction. LogicSigVersion >= 3.
49 NumAssets uint64 Number of Assets. LogicSigVersion >= 3.
50 Applications uint64 Foreign Apps listed in the ApplicationCall transaction. LogicSigVersion >= 3.
51 NumApplications uint64 Number of Applications. LogicSigVersion >= 3.
52 GlobalNumUint uint64 Number of global state integers in ApplicationCall. LogicSigVersion >= 3.
53 GlobalNumByteSlice uint64 Number of global state byteslices in ApplicationCall. LogicSigVersion >= 3.
54 LocalNumUint uint64 Number of local state integers in ApplicationCall. LogicSigVersion >= 3.
55 LocalNumByteSlice uint64 Number of local state byteslices in ApplicationCall. LogicSigVersion >= 3.

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 Notes
0 MinTxnFee uint64 micro Algos
1 MinBalance uint64 micro Algos
2 MaxTxnLife uint64 rounds
3 ZeroAddress []byte 32 byte address of all zero bytes
4 GroupSize uint64 Number of transactions in this atomic transaction group. At least 1
5 LogicSigVersion uint64 Maximum supported TEAL version. LogicSigVersion >= 2.
6 Round uint64 Current round number. LogicSigVersion >= 2.
7 LatestTimestamp uint64 Last confirmed block UNIX timestamp. Fails if negative. LogicSigVersion >= 2.
8 CurrentApplicationID uint64 ID of current application executing. Fails if no such application is executing. LogicSigVersion >= 2.
9 CreatorAddress []byte Address of the creator of the current application. Fails if no such application is executing. LogicSigVersion >= 3.

Asset Fields

Asset fields include AssetHolding and AssetParam fields that are used in asset_read_* opcodes

Index Name Type Notes
0 AssetBalance uint64 Amount of the asset unit held by this account
1 AssetFrozen uint64 Is the asset frozen or not
Index Name Type Notes
0 AssetTotal uint64 Total number of units of this asset
1 AssetDecimals uint64 See AssetParams.Decimals
2 AssetDefaultFrozen uint64 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 []byte Arbitrary commitment
7 AssetManager []byte Manager commitment
8 AssetReserve []byte Reserve address
9 AssetFreeze []byte Freeze address
10 AssetClawback []byte Clawback address
Flow Control
Op Description
err Error. Panic immediately. This is primarily a fencepost against accidental zero bytes getting compiled into programs.
bnz target branch to TARGET if value X is not zero
bz target branch to TARGET if value X is zero
b target branch unconditionally to TARGET
return use last value on stack as success value; end
pop discard value X from stack
dup duplicate last value on stack
dup2 duplicate two last values on stack: A, B -> A, B, A, B
dig n push the Nth value from the top of the stack. dig 0 is equivalent to dup
swap swaps two last values on stack: A, B -> B, A
select selects one of two values based on top-of-stack: A, B, C -> (if C != 0 then B else A)
assert immediately fail unless value X is a non-zero number
callsub target branch unconditionally to TARGET, saving the next instruction on the call stack
retsub pop the top instruction from the call stack and branch to it
State Access
Op Description
balance get balance for the requested account specified by Txn.Accounts[A] in microalgos. A is specified as an account index in the Accounts field of the ApplicationCall transaction, zero index means the sender. The balance is observed after the effects of previous transactions in the group, and after the fee for the current transaction is deducted.
min_balance get minimum required balance for the requested account specified by Txn.Accounts[A] in microalgos. A is specified as an account index in the Accounts field of the ApplicationCall transaction, zero index means the sender. Required balance is affected by ASA and App 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.
app_opted_in check if account specified by Txn.Accounts[A] opted in for the application B => {0 or 1}
app_local_get read from account specified by Txn.Accounts[A] from local state of the current application key B => value
app_local_get_ex read from account specified by Txn.Accounts[A] from local state of the application B key C => [... stack, value, 0 or 1]
app_global_get read key A from global state of a current application => value
app_global_get_ex read from application Txn.ForeignApps[A] global state key B => [... stack, value, 0 or 1]. A is specified as an account index in the ForeignApps field of the ApplicationCall transaction, zero index means this app
app_local_put write to account specified by Txn.Accounts[A] to local state of a current application key B with value C
app_global_put write key A and value B to global state of the current application
app_local_del delete from account specified by Txn.Accounts[A] local state key B of the current application
app_global_del delete key A from a global state of the current application
asset_holding_get i read from account specified by Txn.Accounts[A] and asset B holding field X (imm arg) => {0 or 1 (top), value}
asset_params_get i read from asset Txn.ForeignAssets[A] params field X (imm arg) => {0 or 1 (top), value}

Assembler Syntax

The assembler parses line by line. Ops that just use the stack appear on a line by themselves. Ops that take arguments are the op and then whitespace and then any argument or arguments.

The first line may contain a special version pragma #pragma version X, which directs the assembler to generate TEAL bytecode targeting a certain version. For instance, #pragma version 2 produces bytecode targeting TEAL v2. By default, the assembler targets TEAL 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 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.

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, 0 prefixed for octal, or decimal numbers.

intcblock may be explictly 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 op or keyword and ending in ':'. A label can be an argument (without the trailing ':') to a branch instruction.

Example:

int 1
bnz safe
err
safe:
pop

Encoding and Versioning

A 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 fields from breaking assumptions made by older versions of TEAL. If one of the transactions in a group will execute a TEAL program whose version predates a given field, that field must not be set anywhere in the transaction group, or the group will be rejected. For example, executing a TEAL version 1 program on a transaction with RekeyTo set to a nonzero address will cause the program to fail, regardless of the other contents of the program itself.

This requirement is enforced as follows:

  • For every transaction, compute the earliest TEAL version that supports all the fields and and values in this transaction. For example, a transaction with a nonzero RekeyTo field will have version (at least) 2.

  • 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 TEAL program with a version smaller than maxVerNo, then that TEAL program will fail.

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 TEAL Cannot Do

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

  • TEAL cannot create or change a transaction, only approve or reject.
  • Stateless TEAL cannot lookup balances of Algos or other assets. (Standard transaction accounting will apply after TEAL has run and authorized a transaction. A TEAL-approved 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.)
  • TEAL cannot access information in previous blocks. TEAL cannot access most information in other transactions in the current block. (TEAL can access fields of the transaction it is attached to and the transactions in an atomic transaction group.)
  • TEAL cannot know exactly what round the current transaction will commit in (but it is somewhere in FirstValid through LastValid).
  • TEAL cannot know exactly what time its transaction is committed.
  • TEAL 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 so as to skip some code.
  • Until v4, TEAL had no notion of subroutines (and therefore no recursion). As of v4, use callsub and retsub.
  • TEAL 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.

Documentation

Index

Constants

View Source
const AssemblerDefaultVersion = 1

AssemblerDefaultVersion what version of code do we emit by default AssemblerDefaultVersion is set to 1 on puprose 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 EvalMaxScratchSize = 255

EvalMaxScratchSize is the maximum number of scratch slots.

View Source
const EvalMaxVersion = LogicVersion

EvalMaxVersion is the max version we can interpret and run

View Source
const LogicVersion = 4

LogicVersion defines default assembler and max eval versions

View Source
const MaxByteMathSize = 64

MaxByteMathSize is the limit of byte strings supplied as input to byte math opcodes

View Source
const MaxStackDepth = 1000

MaxStackDepth should move to consensus params

View Source
const MaxStringSize = 4096

MaxStringSize is the limit of byte strings created by `concat`

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

OnCompletionPreamble describes what the OnCompletion constants represent.

Variables

View Source
var AssetHoldingFieldDocs = map[string]string{
	"AssetBalance": "Amount of the asset unit held by this account",
	"AssetFrozen":  "Is the asset frozen or not",
}

AssetHoldingFieldDocs are notes on fields available in `asset_holding_get`

View Source
var AssetHoldingFieldNames []string

AssetHoldingFieldNames are arguments to the 'asset_holding_get' opcode

View Source
var AssetHoldingFieldTypes []StackType

AssetHoldingFieldTypes is StackUint64 StackBytes in parallel with AssetHoldingFieldNames

View Source
var AssetParamsFieldDocs = map[string]string{
	"AssetTotal":         "Total number of units of this asset",
	"AssetDecimals":      "See AssetParams.Decimals",
	"AssetDefaultFrozen": "Frozen by default or not",
	"AssetUnitName":      "Asset unit name",
	"AssetName":          "Asset name",
	"AssetURL":           "URL with additional info about the asset",
	"AssetMetadataHash":  "Arbitrary commitment",
	"AssetManager":       "Manager commitment",
	"AssetReserve":       "Reserve address",
	"AssetFreeze":        "Freeze address",
	"AssetClawback":      "Clawback address",
}

AssetParamsFieldDocs are notes on fields available in `asset_params_get`

View Source
var AssetParamsFieldNames []string

AssetParamsFieldNames are arguments to the 'asset_holding_get' opcode

View Source
var AssetParamsFieldTypes []StackType

AssetParamsFieldTypes is StackUint64 StackBytes in parallel with AssetParamsFieldNames

View Source
var GlobalFieldNames []string

GlobalFieldNames are arguments to the 'global' opcode

View Source
var GlobalFieldTypes []StackType

GlobalFieldTypes is StackUint64 StackBytes in parallel with GlobalFieldNames

View Source
var OnCompletionNames []string

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

View Source
var OpGroups = map[string][]string{
	"Arithmetic":           {"sha256", "keccak256", "sha512_256", "ed25519verify", "+", "-", "/", "*", "<", ">", "<=", ">=", "&&", "||", "shl", "shr", "sqrt", "bitlen", "exp", "==", "!=", "!", "len", "itob", "btoi", "%", "|", "&", "^", "~", "mulw", "addw", "divmodw", "expw", "getbit", "setbit", "getbyte", "setbyte", "concat", "substring", "substring3"},
	"Byteslice Arithmetic": {"b+", "b-", "b/", "b*", "b<", "b>", "b<=", "b>=", "b==", "b!=", "b%"},
	"Byteslice Logic":      {"b|", "b&", "b^", "b~"},
	"Loading Values":       {"intcblock", "intc", "intc_0", "intc_1", "intc_2", "intc_3", "pushint", "bytecblock", "bytec", "bytec_0", "bytec_1", "bytec_2", "bytec_3", "pushbytes", "bzero", "arg", "arg_0", "arg_1", "arg_2", "arg_3", "txn", "gtxn", "txna", "gtxna", "gtxns", "gtxnsa", "global", "load", "store", "gload", "gloads"},
	"Flow Control":         {"err", "bnz", "bz", "b", "return", "pop", "dup", "dup2", "dig", "swap", "select", "assert", "callsub", "retsub"},
	"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"},
}

OpGroups is groupings of ops for documentation purposes.

View Source
var OpSpecs = []OpSpec{}/* 119 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 each version, mapping opcode name to OpSpec

View Source
var TxnFieldNames []string

TxnFieldNames are arguments to the 'txn' and 'txnById' opcodes

View Source
var TxnFieldTypes []StackType

TxnFieldTypes is StackBytes or StackUint64 parallel to TxnFieldNames

TxnTypeNames is the values of Txn.Type in enum order

View Source
var TxnaFieldNames = []string{ApplicationArgs.String(), Accounts.String()}

TxnaFieldNames are arguments to the 'txna' opcode It is a subset of txn transaction fields so initialized here in-place

View Source
var TxnaFieldTypes = []StackType{
	txnaFieldSpecByField[ApplicationArgs].ftype,
	txnaFieldSpecByField[Accounts].ftype,
	txnaFieldSpecByField[Assets].ftype,
	txnaFieldSpecByField[Applications].ftype,
}

TxnaFieldTypes is StackBytes or StackUint64 parallel to TxnFieldNames

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.

Functions

func Check

func Check(program []byte, params EvalParams) error

Check should be faster than Eval. 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 CheckStateful

func CheckStateful(program []byte, params EvalParams) error

CheckStateful should be faster than EvalStateful. 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 ComputeMinTealVersion

func ComputeMinTealVersion(group []transactions.SignedTxn) uint64

ComputeMinTealVersion calculates the minimum safe TEAL version that may be used by a transaction in this group. It is important to prevent newly-introduced transaction fields from breaking assumptions made by older versions of TEAL. If one of the transactions in a group will execute a TEAL program whose version predates a given field, that field must not be set anywhere in the transaction group, or the group will be rejected.

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 Eval

func Eval(program []byte, params EvalParams) (pass bool, err error)

Eval checks to see if a transaction passes logic A program passes successfully if it finishes with one int element on the stack that is non-zero.

func EvalStateful

func EvalStateful(program []byte, params EvalParams) (pass bool, err error)

EvalStateful executes stateful TEAL program

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 GlobalFieldDocs

func GlobalFieldDocs() map[string]string

GlobalFieldDocs are notes on fields available in `global` with extra versioning info if any

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 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 OpImmediateNote

func OpImmediateNote(opName string) string

OpImmediateNote returns a short string about immediate data which follows the op byte

func TxnFieldDocs

func TxnFieldDocs() map[string]string

TxnFieldDocs are notes on fields available by `txn` and `gtxn` with extra versioning info if any

func TxnFieldToTealValue

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

TxnFieldToTealValue is a thin wrapper for txnFieldToStack for external use

Types

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
)

func (AssetParamsField) String

func (i AssetParamsField) String() string

type DebugState

type DebugState struct {
	// fields set once on Register
	ExecID      string                   `codec:"execid"`
	Disassembly string                   `codec:"disasm"`
	PCOffset    []PCOffset               `codec:"pctooffset"`
	TxnGroup    []transactions.SignedTxn `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"`

	// global/local state changes are updated every step. Stateful TEAL only.
	basics.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 DebuggerHook

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

DebuggerHook functions are called by eval function during TEAL program execution if provided

type EvalParams

type EvalParams struct {
	// the transaction being evaluated
	Txn *transactions.SignedTxn

	Proto *config.ConsensusParams

	Trace io.Writer

	TxnGroup []transactions.SignedTxn

	// GroupIndex should point to Txn within TxnGroup
	GroupIndex int

	PastSideEffects []EvalSideEffects

	Logger logging.Logger

	Ledger LedgerForLogic

	// optional debugger
	Debugger DebuggerHook

	// MinTealVersion is the minimum allowed TEAL version of this program.
	// The program must reject if its version is less than this version. If
	// MinTealVersion is nil, we will compute it ourselves
	MinTealVersion *uint64
	// contains filtered or unexported fields
}

EvalParams contains data that comes into condition evaluation.

type EvalSideEffects

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

EvalSideEffects contains data returned from evaluation

func MakePastSideEffects

func MakePastSideEffects(size int) (pastSideEffects []EvalSideEffects)

MakePastSideEffects allocates and initializes a slice of EvalSideEffects of length `size`

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
)

func (GlobalField) String

func (i GlobalField) String() string

type LedgerForLogic

type LedgerForLogic interface {
	Balance(addr basics.Address) (basics.MicroAlgos, error)
	MinBalance(addr basics.Address, proto *config.ConsensusParams) (basics.MicroAlgos, error)
	Round() basics.Round
	LatestTimestamp() int64

	AssetHolding(addr basics.Address, assetIdx basics.AssetIndex) (basics.AssetHolding, error)
	AssetParams(aidx basics.AssetIndex) (basics.AssetParams, error)
	ApplicationID() basics.AppIndex
	CreatorAddress() basics.Address
	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, key string, value basics.TealValue, accountIdx uint64) error
	DelLocal(addr basics.Address, key string, accountIdx uint64) error

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

	GetDelta(txn *transactions.Transaction) (evalDelta basics.EvalDelta, err error)
}

LedgerForLogic represents ledger API for Stateful TEAL program

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 OnCompletionConstType

type OnCompletionConstType transactions.OnCompletion

OnCompletionConstType is the same as transactions.OnCompletion

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

func (OnCompletionConstType) String

func (i OnCompletionConstType) String() string

type OpCost

type OpCost struct {
	From int
	To   int
	Cost int
}

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

func OpAllCosts

func OpAllCosts(opName string) []OpCost

OpAllCosts returns an array of the cost score for an op by version. Each entry indicates the cost over a range of versions, so if the cost has remained constant, there is only one result, otherwise each entry shows the cost for a consecutive range of versions, inclusive.

type OpSpec

type OpSpec struct {
	Opcode byte
	Name   string

	Args    StackTypes // what gets popped from the stack
	Returns StackTypes // what gets pushed to the stack
	Version uint64     // TEAL version opcode introduced
	Modes   runMode    // if non-zero, then (mode & Modes) != 0 to allow
	Details 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

type OpStream

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

	// map opcode offsets to source line
	OffsetToLine map[int]int

	HasStatefulOps bool
	// contains filtered or unexported fields
}

OpStream is destination for program and scratch space

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) ByteLiteral

func (ops *OpStream) ByteLiteral(val []byte)

ByteLiteral writes opcodes and data for loading a []byte literal Values are accumulated so that they can be put into a bytecblock

func (*OpStream) Bytec

func (ops *OpStream) Bytec(constIndex uint)

Bytec writes opcodes for loading a []byte constant onto the stack.

func (*OpStream) GetVersion

func (ops *OpStream) GetVersion() uint64

GetVersion returns the LogicSigVersion we're building to

func (*OpStream) Intc

func (ops *OpStream) Intc(constIndex uint)

Intc writes opcodes for loading a uint64 constant onto the stack.

func (*OpStream) RecordSourceLine

func (ops *OpStream) RecordSourceLine()

RecordSourceLine adds an entry to pc to line mapping

func (*OpStream) ReferToLabel

func (ops *OpStream) ReferToLabel(pc int, label string)

ReferToLabel records an opcode label refence to resolve later

func (*OpStream) ReportProblems

func (ops *OpStream) ReportProblems(fname string)

ReportProblems issues accumulated warnings and errors to stderr.

func (*OpStream) Uint

func (ops *OpStream) Uint(val uint64)

Uint writes opcodes for loading a uint literal

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 PanicError

type PanicError struct {
	PanicValue interface{}
	StackTrace string
}

PanicError wraps a recover() catching a panic()

func (PanicError) Error

func (pe PanicError) Error() string

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 StackType

type StackType byte

StackType describes the type of a value on the operand stack

const StackAny StackType = 1

StackAny in an OpSpec shows that the op pops or yield any type

const StackBytes StackType = 3

StackBytes in an OpSpec shows that the op pops or yields a []byte

const StackNone StackType = 0

StackNone in an OpSpec shows that the op pops or yields nothing

const StackUint64 StackType = 2

StackUint64 in an OpSpec shows that the op pops or yields a uint64

func (StackType) String

func (st StackType) String() string

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 panic
	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

	// AppProgramExtraPages AppParams.ExtraProgramPages
	AppProgramExtraPages
)

func (TxnField) String

func (i TxnField) String() string

type WebDebuggerHook

type WebDebuggerHook struct {
	URL string
}

WebDebuggerHook represents a connection to tealdbg

func (*WebDebuggerHook) Complete

func (dbg *WebDebuggerHook) Complete(state *DebugState) error

Complete sends state to remote debugger

func (*WebDebuggerHook) Register

func (dbg *WebDebuggerHook) Register(state *DebugState) error

Register sends state to remote debugger

func (*WebDebuggerHook) Update

func (dbg *WebDebuggerHook) Update(state *DebugState) error

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

Jump to

Keyboard shortcuts

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