diff --git a/tealish/base.py b/tealish/base.py index 911268c..26becb5 100644 --- a/tealish/base.py +++ b/tealish/base.py @@ -147,6 +147,9 @@ def get_field_type(self, namespace: str, name: str) -> str: def lookup_op(self, name: str) -> Op: return lang_spec.lookup_op(name) + def lookup_type(self, type: str) -> AVMType: + return lang_spec.lookup_type(type) + def lookup_func(self, name: str) -> "Func": return self.get_scope().lookup_func(name) diff --git a/tealish/expression_nodes.py b/tealish/expression_nodes.py index 2e88407..a9c593c 100644 --- a/tealish/expression_nodes.py +++ b/tealish/expression_nodes.py @@ -3,7 +3,7 @@ from .base import BaseNode from .errors import CompileError from .tealish_builtins import AVMType, get_struct -from .langspec import Op, type_lookup +from .langspec import Op if TYPE_CHECKING: @@ -107,7 +107,7 @@ def process(self) -> None: self.a.process() self.check_arg_types(self.op, [self.a]) op = self.lookup_op(self.op) - self.type = type_lookup(op.returns) + self.type = self.lookup_type(op.returns[0]) def write_teal(self, writer: "TealWriter") -> None: writer.write(self, self.a) @@ -132,7 +132,7 @@ def process(self) -> None: self.b.process() self.check_arg_types(self.op, [self.a, self.b]) op = self.lookup_op(self.op) - self.type = type_lookup(op.returns) + self.type = self.lookup_type(op.returns[0]) def write_teal(self, writer: "TealWriter") -> None: writer.write(self, self.a) @@ -213,10 +213,10 @@ def write_teal_user_defined_func_call(self, writer: "TealWriter") -> None: def process_op_call(self, op: Op) -> None: self.func_call_type = "op" self.op = op - immediates = self.args[: op.immediate_args_num] + immediates = self.args[: len(op.immediate_args)] num_args = len(op.args) - self.args = self.args[op.immediate_args_num :] + self.args = self.args[len(op.immediate_args) :] if len(self.args) != num_args: raise CompileError(f"Expected {num_args} args for {op.name}!", node=self) for i, arg in enumerate(self.args): diff --git a/tealish/langspec.json b/tealish/langspec.json index 319798e..cb35490 100644 --- a/tealish/langspec.json +++ b/tealish/langspec.json @@ -1 +1,4605 @@ -{"EvalMaxVersion": 8, "LogicSigVersion": 8, "Ops": [{"Opcode": 0, "Name": "err", "Size": 1, "Doc": "Fail immediately.", "Groups": ["Flow Control"]}, {"Opcode": 1, "Name": "sha256", "Args": "B", "Returns": "B", "Size": 1, "Doc": "SHA256 hash of value A, yields [32]byte", "Groups": ["Arithmetic"]}, {"Opcode": 2, "Name": "keccak256", "Args": "B", "Returns": "B", "Size": 1, "Doc": "Keccak256 hash of value A, yields [32]byte", "Groups": ["Arithmetic"]}, {"Opcode": 3, "Name": "sha512_256", "Args": "B", "Returns": "B", "Size": 1, "Doc": "SHA512_256 hash of value A, yields [32]byte", "Groups": ["Arithmetic"]}, {"Opcode": 4, "Name": "ed25519verify", "Args": "BBB", "Returns": "U", "Size": 1, "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey => {0 or 1}", "DocExtra": "The 32 byte public key is the last element on the stack, preceded by the 64 byte signature at the second-to-last element on the stack, preceded by the data which was signed at the third-to-last element on the stack.", "Groups": ["Arithmetic"]}, {"Opcode": 5, "Name": "ecdsa_verify", "Args": "BBBBB", "Returns": "U", "Size": 2, "Doc": "for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1}", "DocExtra": "The 32 byte Y-component of a public key is the last element on the stack, preceded by X-component of a pubkey, preceded by S and R components of a signature, preceded by the data that is fifth element on the stack. All values are big-endian encoded. The signed data must be 32 bytes long, and signatures in lower-S form are only accepted.", "ImmediateNote": "{uint8 curve index}", "Groups": ["Arithmetic"]}, {"Opcode": 6, "Name": "ecdsa_pk_decompress", "Args": "B", "Returns": "BB", "Size": 2, "Doc": "decompress pubkey A into components X, Y", "DocExtra": "The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded.", "ImmediateNote": "{uint8 curve index}", "Groups": ["Arithmetic"]}, {"Opcode": 7, "Name": "ecdsa_pk_recover", "Args": "BUBB", "Returns": "BB", "Size": 2, "Doc": "for (data A, recovery id B, signature C, D) recover a public key", "DocExtra": "S (top) and R elements of a signature, recovery id and data (bottom) are expected on the stack and used to deriver a public key. All values are big-endian encoded. The signed data must be 32 bytes long.", "ImmediateNote": "{uint8 curve index}", "Groups": ["Arithmetic"]}, {"Opcode": 8, "Name": "+", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A plus B. Fail on overflow.", "DocExtra": "Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`.", "Groups": ["Arithmetic"]}, {"Opcode": 9, "Name": "-", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A minus B. Fail if B > A.", "Groups": ["Arithmetic"]}, {"Opcode": 10, "Name": "/", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A divided by B (truncated division). Fail if B == 0.", "DocExtra": "`divmodw` is available to divide the two-element values produced by `mulw` and `addw`.", "Groups": ["Arithmetic"]}, {"Opcode": 11, "Name": "*", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A times B. Fail on overflow.", "DocExtra": "Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`.", "Groups": ["Arithmetic"]}, {"Opcode": 12, "Name": "<", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A less than B => {0 or 1}", "Groups": ["Arithmetic"]}, {"Opcode": 13, "Name": ">", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A greater than B => {0 or 1}", "Groups": ["Arithmetic"]}, {"Opcode": 14, "Name": "<=", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A less than or equal to B => {0 or 1}", "Groups": ["Arithmetic"]}, {"Opcode": 15, "Name": ">=", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A greater than or equal to B => {0 or 1}", "Groups": ["Arithmetic"]}, {"Opcode": 16, "Name": "&&", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A is not zero and B is not zero => {0 or 1}", "Groups": ["Arithmetic"]}, {"Opcode": 17, "Name": "||", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A is not zero or B is not zero => {0 or 1}", "Groups": ["Arithmetic"]}, {"Opcode": 18, "Name": "==", "Args": "..", "Returns": "U", "Size": 1, "Doc": "A is equal to B => {0 or 1}", "Groups": ["Arithmetic"]}, {"Opcode": 19, "Name": "!=", "Args": "..", "Returns": "U", "Size": 1, "Doc": "A is not equal to B => {0 or 1}", "Groups": ["Arithmetic"]}, {"Opcode": 20, "Name": "!", "Args": "U", "Returns": "U", "Size": 1, "Doc": "A == 0 yields 1; else 0", "Groups": ["Arithmetic"]}, {"Opcode": 21, "Name": "len", "Args": "B", "Returns": "U", "Size": 1, "Doc": "yields length of byte value A", "Groups": ["Arithmetic"]}, {"Opcode": 22, "Name": "itob", "Args": "U", "Returns": "B", "Size": 1, "Doc": "converts uint64 A to big-endian byte array, always of length 8", "Groups": ["Arithmetic"]}, {"Opcode": 23, "Name": "btoi", "Args": "B", "Returns": "U", "Size": 1, "Doc": "converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8.", "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", "Groups": ["Arithmetic"]}, {"Opcode": 24, "Name": "%", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A modulo B. Fail if B == 0.", "Groups": ["Arithmetic"]}, {"Opcode": 25, "Name": "|", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A bitwise-or B", "Groups": ["Arithmetic"]}, {"Opcode": 26, "Name": "&", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A bitwise-and B", "Groups": ["Arithmetic"]}, {"Opcode": 27, "Name": "^", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A bitwise-xor B", "Groups": ["Arithmetic"]}, {"Opcode": 28, "Name": "~", "Args": "U", "Returns": "U", "Size": 1, "Doc": "bitwise invert value A", "Groups": ["Arithmetic"]}, {"Opcode": 29, "Name": "mulw", "Args": "UU", "Returns": "UU", "Size": 1, "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", "Groups": ["Arithmetic"]}, {"Opcode": 30, "Name": "addw", "Args": "UU", "Returns": "UU", "Size": 1, "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", "Groups": ["Arithmetic"]}, {"Opcode": 31, "Name": "divmodw", "Args": "UUUU", "Returns": "UUUU", "Size": 1, "Doc": "W,X = (A,B / C,D); Y,Z = (A,B modulo C,D)", "DocExtra": "The notation J,K indicates that two uint64 values J and K are interpreted as a uint128 value, with J as the high uint64 and K the low.", "Groups": ["Arithmetic"]}, {"Opcode": 32, "Name": "intcblock", "Size": 0, "Doc": "prepare block of uint64 constants for use by intc", "DocExtra": "`intcblock` loads following program bytes into an array of integer constants in the evaluator. These integer constants can be referred to by `intc` and `intc_*` which will push the value onto the stack. Subsequent calls to `intcblock` reset and replace the integer constants available to the script.", "ImmediateNote": "{varuint count} [{varuint value}, ...]", "Groups": ["Loading Values"]}, {"Opcode": 33, "Name": "intc", "Returns": "U", "Size": 2, "Doc": "Ith constant from intcblock", "ImmediateNote": "{uint8 int constant index}", "Groups": ["Loading Values"]}, {"Opcode": 34, "Name": "intc_0", "Returns": "U", "Size": 1, "Doc": "constant 0 from intcblock", "Groups": ["Loading Values"]}, {"Opcode": 35, "Name": "intc_1", "Returns": "U", "Size": 1, "Doc": "constant 1 from intcblock", "Groups": ["Loading Values"]}, {"Opcode": 36, "Name": "intc_2", "Returns": "U", "Size": 1, "Doc": "constant 2 from intcblock", "Groups": ["Loading Values"]}, {"Opcode": 37, "Name": "intc_3", "Returns": "U", "Size": 1, "Doc": "constant 3 from intcblock", "Groups": ["Loading Values"]}, {"Opcode": 38, "Name": "bytecblock", "Size": 0, "Doc": "prepare block of byte-array constants for use by bytec", "DocExtra": "`bytecblock` loads the following program bytes into an array of byte-array constants in the evaluator. These constants can be referred to by `bytec` and `bytec_*` which will push the value onto the stack. Subsequent calls to `bytecblock` reset and replace the bytes constants available to the script.", "ImmediateNote": "{varuint count} [({varuint value length} bytes), ...]", "Groups": ["Loading Values"]}, {"Opcode": 39, "Name": "bytec", "Returns": "B", "Size": 2, "Doc": "Ith constant from bytecblock", "ImmediateNote": "{uint8 byte constant index}", "Groups": ["Loading Values"]}, {"Opcode": 40, "Name": "bytec_0", "Returns": "B", "Size": 1, "Doc": "constant 0 from bytecblock", "Groups": ["Loading Values"]}, {"Opcode": 41, "Name": "bytec_1", "Returns": "B", "Size": 1, "Doc": "constant 1 from bytecblock", "Groups": ["Loading Values"]}, {"Opcode": 42, "Name": "bytec_2", "Returns": "B", "Size": 1, "Doc": "constant 2 from bytecblock", "Groups": ["Loading Values"]}, {"Opcode": 43, "Name": "bytec_3", "Returns": "B", "Size": 1, "Doc": "constant 3 from bytecblock", "Groups": ["Loading Values"]}, {"Opcode": 44, "Name": "arg", "Returns": "B", "Size": 2, "Doc": "Nth LogicSig argument", "ImmediateNote": "{uint8 arg index N}", "Groups": ["Loading Values"]}, {"Opcode": 45, "Name": "arg_0", "Returns": "B", "Size": 1, "Doc": "LogicSig argument 0", "Groups": ["Loading Values"]}, {"Opcode": 46, "Name": "arg_1", "Returns": "B", "Size": 1, "Doc": "LogicSig argument 1", "Groups": ["Loading Values"]}, {"Opcode": 47, "Name": "arg_2", "Returns": "B", "Size": 1, "Doc": "LogicSig argument 2", "Groups": ["Loading Values"]}, {"Opcode": 48, "Name": "arg_3", "Returns": "B", "Size": 1, "Doc": "LogicSig argument 3", "Groups": ["Loading Values"]}, {"Opcode": 49, "Name": "txn", "Returns": ".", "Size": 2, "ArgEnum": ["Sender", "Fee", "FirstValid", "FirstValidTime", "LastValid", "Note", "Lease", "Receiver", "Amount", "CloseRemainderTo", "VotePK", "SelectionPK", "VoteFirst", "VoteLast", "VoteKeyDilution", "Type", "TypeEnum", "XferAsset", "AssetAmount", "AssetSender", "AssetReceiver", "AssetCloseTo", "GroupIndex", "TxID", "ApplicationID", "OnCompletion", "ApplicationArgs", "NumAppArgs", "Accounts", "NumAccounts", "ApprovalProgram", "ClearStateProgram", "RekeyTo", "ConfigAsset", "ConfigAssetTotal", "ConfigAssetDecimals", "ConfigAssetDefaultFrozen", "ConfigAssetUnitName", "ConfigAssetName", "ConfigAssetURL", "ConfigAssetMetadataHash", "ConfigAssetManager", "ConfigAssetReserve", "ConfigAssetFreeze", "ConfigAssetClawback", "FreezeAsset", "FreezeAssetAccount", "FreezeAssetFrozen", "Assets", "NumAssets", "Applications", "NumApplications", "GlobalNumUint", "GlobalNumByteSlice", "LocalNumUint", "LocalNumByteSlice", "ExtraProgramPages", "Nonparticipation", "Logs", "NumLogs", "CreatedAssetID", "CreatedApplicationID", "LastLog", "StateProofPK", "ApprovalProgramPages", "NumApprovalProgramPages", "ClearStateProgramPages", "NumClearStateProgramPages"], "ArgEnumTypes": "BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBBBUBU", "Doc": "field F of current transaction", "ImmediateNote": "{uint8 transaction field index}", "Groups": ["Loading Values"]}, {"Opcode": 50, "Name": "global", "Returns": ".", "Size": 2, "ArgEnum": ["MinTxnFee", "MinBalance", "MaxTxnLife", "ZeroAddress", "GroupSize", "LogicSigVersion", "Round", "LatestTimestamp", "CurrentApplicationID", "CreatorAddress", "CurrentApplicationAddress", "GroupID", "OpcodeBudget", "CallerApplicationID", "CallerApplicationAddress"], "ArgEnumTypes": "UUUBUUUUUBBBUUB", "Doc": "global field F", "ImmediateNote": "{uint8 global field index}", "Groups": ["Loading Values"]}, {"Opcode": 51, "Name": "gtxn", "Returns": ".", "Size": 3, "ArgEnum": ["Sender", "Fee", "FirstValid", "FirstValidTime", "LastValid", "Note", "Lease", "Receiver", "Amount", "CloseRemainderTo", "VotePK", "SelectionPK", "VoteFirst", "VoteLast", "VoteKeyDilution", "Type", "TypeEnum", "XferAsset", "AssetAmount", "AssetSender", "AssetReceiver", "AssetCloseTo", "GroupIndex", "TxID", "ApplicationID", "OnCompletion", "ApplicationArgs", "NumAppArgs", "Accounts", "NumAccounts", "ApprovalProgram", "ClearStateProgram", "RekeyTo", "ConfigAsset", "ConfigAssetTotal", "ConfigAssetDecimals", "ConfigAssetDefaultFrozen", "ConfigAssetUnitName", "ConfigAssetName", "ConfigAssetURL", "ConfigAssetMetadataHash", "ConfigAssetManager", "ConfigAssetReserve", "ConfigAssetFreeze", "ConfigAssetClawback", "FreezeAsset", "FreezeAssetAccount", "FreezeAssetFrozen", "Assets", "NumAssets", "Applications", "NumApplications", "GlobalNumUint", "GlobalNumByteSlice", "LocalNumUint", "LocalNumByteSlice", "ExtraProgramPages", "Nonparticipation", "Logs", "NumLogs", "CreatedAssetID", "CreatedApplicationID", "LastLog", "StateProofPK", "ApprovalProgramPages", "NumApprovalProgramPages", "ClearStateProgramPages", "NumClearStateProgramPages"], "ArgEnumTypes": "BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBBBUBU", "Doc": "field F of the Tth transaction in the current group", "DocExtra": "for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`.", "ImmediateNote": "{uint8 transaction group index} {uint8 transaction field index}", "Groups": ["Loading Values"]}, {"Opcode": 52, "Name": "load", "Returns": ".", "Size": 2, "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", "ImmediateNote": "{uint8 position in scratch space to load from}", "Groups": ["Loading Values"]}, {"Opcode": 53, "Name": "store", "Args": ".", "Size": 2, "Doc": "store A to the Ith scratch space", "ImmediateNote": "{uint8 position in scratch space to store to}", "Groups": ["Loading Values"]}, {"Opcode": 54, "Name": "txna", "Returns": ".", "Size": 3, "ArgEnum": ["ApplicationArgs", "Accounts", "Assets", "Applications", "Logs", "ApprovalProgramPages", "ClearStateProgramPages"], "ArgEnumTypes": "BBUUBBB", "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", "ImmediateNote": "{uint8 transaction field index} {uint8 transaction field array index}", "Groups": ["Loading Values"]}, {"Opcode": 55, "Name": "gtxna", "Returns": ".", "Size": 4, "ArgEnum": ["ApplicationArgs", "Accounts", "Assets", "Applications", "Logs", "ApprovalProgramPages", "ClearStateProgramPages"], "ArgEnumTypes": "BBUUBBB", "Doc": "Ith value of the array field F from the Tth transaction in the current group\n`gtxna` can be called using `gtxn` with 3 immediates.", "ImmediateNote": "{uint8 transaction group index} {uint8 transaction field index} {uint8 transaction field array index}", "Groups": ["Loading Values"]}, {"Opcode": 56, "Name": "gtxns", "Args": "U", "Returns": ".", "Size": 2, "ArgEnum": ["Sender", "Fee", "FirstValid", "FirstValidTime", "LastValid", "Note", "Lease", "Receiver", "Amount", "CloseRemainderTo", "VotePK", "SelectionPK", "VoteFirst", "VoteLast", "VoteKeyDilution", "Type", "TypeEnum", "XferAsset", "AssetAmount", "AssetSender", "AssetReceiver", "AssetCloseTo", "GroupIndex", "TxID", "ApplicationID", "OnCompletion", "ApplicationArgs", "NumAppArgs", "Accounts", "NumAccounts", "ApprovalProgram", "ClearStateProgram", "RekeyTo", "ConfigAsset", "ConfigAssetTotal", "ConfigAssetDecimals", "ConfigAssetDefaultFrozen", "ConfigAssetUnitName", "ConfigAssetName", "ConfigAssetURL", "ConfigAssetMetadataHash", "ConfigAssetManager", "ConfigAssetReserve", "ConfigAssetFreeze", "ConfigAssetClawback", "FreezeAsset", "FreezeAssetAccount", "FreezeAssetFrozen", "Assets", "NumAssets", "Applications", "NumApplications", "GlobalNumUint", "GlobalNumByteSlice", "LocalNumUint", "LocalNumByteSlice", "ExtraProgramPages", "Nonparticipation", "Logs", "NumLogs", "CreatedAssetID", "CreatedApplicationID", "LastLog", "StateProofPK", "ApprovalProgramPages", "NumApprovalProgramPages", "ClearStateProgramPages", "NumClearStateProgramPages"], "ArgEnumTypes": "BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBBBUBU", "Doc": "field F of the Ath transaction in the current group", "DocExtra": "for notes on transaction fields available, see `txn`. If top of stack is _i_, `gtxns field` is equivalent to `gtxn _i_ field`. gtxns exists so that _i_ can be calculated, often based on the index of the current transaction.", "ImmediateNote": "{uint8 transaction field index}", "Groups": ["Loading Values"]}, {"Opcode": 57, "Name": "gtxnsa", "Args": "U", "Returns": ".", "Size": 3, "ArgEnum": ["ApplicationArgs", "Accounts", "Assets", "Applications", "Logs", "ApprovalProgramPages", "ClearStateProgramPages"], "ArgEnumTypes": "BBUUBBB", "Doc": "Ith value of the array field F from the Ath transaction in the current group\n`gtxnsa` can be called using `gtxns` with 2 immediates.", "ImmediateNote": "{uint8 transaction field index} {uint8 transaction field array index}", "Groups": ["Loading Values"]}, {"Opcode": 58, "Name": "gload", "Returns": ".", "Size": 3, "Doc": "Ith scratch space value of the Tth transaction in the current group", "DocExtra": "`gload` fails unless the requested transaction is an ApplicationCall and T < GroupIndex.", "ImmediateNote": "{uint8 transaction group index} {uint8 position in scratch space to load from}", "Groups": ["Loading Values"]}, {"Opcode": 59, "Name": "gloads", "Args": "U", "Returns": ".", "Size": 2, "Doc": "Ith scratch space value of the Ath transaction in the current group", "DocExtra": "`gloads` fails unless the requested transaction is an ApplicationCall and A < GroupIndex.", "ImmediateNote": "{uint8 position in scratch space to load from}", "Groups": ["Loading Values"]}, {"Opcode": 60, "Name": "gaid", "Returns": "U", "Size": 2, "Doc": "ID of the asset or application created in the Tth transaction of the current group", "DocExtra": "`gaid` fails unless the requested transaction created an asset or application and T < GroupIndex.", "ImmediateNote": "{uint8 transaction group index}", "Groups": ["Loading Values"]}, {"Opcode": 61, "Name": "gaids", "Args": "U", "Returns": "U", "Size": 1, "Doc": "ID of the asset or application created in the Ath transaction of the current group", "DocExtra": "`gaids` fails unless the requested transaction created an asset or application and A < GroupIndex.", "Groups": ["Loading Values"]}, {"Opcode": 62, "Name": "loads", "Args": "U", "Returns": ".", "Size": 1, "Doc": "Ath scratch space value. All scratch spaces are 0 at program start.", "Groups": ["Loading Values"]}, {"Opcode": 63, "Name": "stores", "Args": "U.", "Size": 1, "Doc": "store B to the Ath scratch space", "Groups": ["Loading Values"]}, {"Opcode": 64, "Name": "bnz", "Args": "U", "Size": 3, "Doc": "branch to TARGET if value A is not zero", "DocExtra": "The `bnz` instruction opcode 0x40 is followed by two immediate data bytes which are a high byte first and low byte second which together form a 16 bit offset which the instruction may branch to. For a bnz instruction at `pc`, if the last element of the stack is not zero then branch to instruction at `pc + 3 + N`, else proceed to next instruction at `pc + 3`. Branch targets must be aligned instructions. (e.g. Branching to the second byte of a 2 byte op will be rejected.) Starting at v4, the offset is treated as a signed 16 bit integer allowing for backward branches and looping. In prior version (v1 to v3), branch offsets are limited to forward branches only, 0-0x7fff.\n\nAt v2 it became allowed to branch to the end of the program exactly after the last instruction: bnz to byte N (with 0-indexing) was illegal for a TEAL program with N bytes before v2, and is legal after it. This change eliminates the need for a last instruction of no-op as a branch target at the end. (Branching beyond the end--in other words, to a byte larger than N--is still illegal and will cause the program to fail.)", "ImmediateNote": "{int16 branch offset, big-endian}", "Groups": ["Flow Control"]}, {"Opcode": 65, "Name": "bz", "Args": "U", "Size": 3, "Doc": "branch to TARGET if value A is zero", "DocExtra": "See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`.", "ImmediateNote": "{int16 branch offset, big-endian}", "Groups": ["Flow Control"]}, {"Opcode": 66, "Name": "b", "Size": 3, "Doc": "branch unconditionally to TARGET", "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", "ImmediateNote": "{int16 branch offset, big-endian}", "Groups": ["Flow Control"]}, {"Opcode": 67, "Name": "return", "Args": "U", "Size": 1, "Doc": "use A as success value; end", "Groups": ["Flow Control"]}, {"Opcode": 68, "Name": "assert", "Args": "U", "Size": 1, "Doc": "immediately fail unless A is a non-zero number", "Groups": ["Flow Control"]}, {"Opcode": 69, "Name": "bury", "Args": ".", "Size": 2, "Doc": "replace the Nth value from the top of the stack with A. bury 0 fails.", "ImmediateNote": "{uint8 depth}", "Groups": ["Flow Control"]}, {"Opcode": 70, "Name": "popn", "Size": 2, "Doc": "remove N values from the top of the stack", "ImmediateNote": "{uint8 stack depth}", "Groups": ["Flow Control"]}, {"Opcode": 71, "Name": "dupn", "Args": ".", "Size": 2, "Doc": "duplicate A, N times", "ImmediateNote": "{uint8 copy count}", "Groups": ["Flow Control"]}, {"Opcode": 72, "Name": "pop", "Args": ".", "Size": 1, "Doc": "discard A", "Groups": ["Flow Control"]}, {"Opcode": 73, "Name": "dup", "Args": ".", "Returns": "..", "Size": 1, "Doc": "duplicate A", "Groups": ["Flow Control"]}, {"Opcode": 74, "Name": "dup2", "Args": "..", "Returns": "....", "Size": 1, "Doc": "duplicate A and B", "Groups": ["Flow Control"]}, {"Opcode": 75, "Name": "dig", "Args": ".", "Returns": "..", "Size": 2, "Doc": "Nth value from the top of the stack. dig 0 is equivalent to dup", "ImmediateNote": "{uint8 depth}", "Groups": ["Flow Control"]}, {"Opcode": 76, "Name": "swap", "Args": "..", "Returns": "..", "Size": 1, "Doc": "swaps A and B on stack", "Groups": ["Flow Control"]}, {"Opcode": 77, "Name": "select", "Args": "..U", "Returns": ".", "Size": 1, "Doc": "selects one of two values based on top-of-stack: B if C != 0, else A", "Groups": ["Flow Control"]}, {"Opcode": 78, "Name": "cover", "Args": ".", "Returns": ".", "Size": 2, "Doc": "remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth <= N.", "ImmediateNote": "{uint8 depth}", "Groups": ["Flow Control"]}, {"Opcode": 79, "Name": "uncover", "Args": ".", "Returns": ".", "Size": 2, "Doc": "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.", "ImmediateNote": "{uint8 depth}", "Groups": ["Flow Control"]}, {"Opcode": 80, "Name": "concat", "Args": "BB", "Returns": "B", "Size": 1, "Doc": "join A and B", "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", "Groups": ["Arithmetic"]}, {"Opcode": 81, "Name": "substring", "Args": "B", "Returns": "B", "Size": 3, "Doc": "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", "ImmediateNote": "{uint8 start position} {uint8 end position}", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 82, "Name": "substring3", "Args": "BUU", "Returns": "B", "Size": 1, "Doc": "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", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 83, "Name": "getbit", "Args": ".U", "Returns": "U", "Size": 1, "Doc": "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", "DocExtra": "see explanation of bit ordering in setbit", "Groups": ["Arithmetic"]}, {"Opcode": 84, "Name": "setbit", "Args": ".UU", "Returns": ".", "Size": 1, "Doc": "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", "DocExtra": "When A is a uint64, index 0 is the least significant bit. Setting bit 3 to 1 on the integer 0 yields 8, or 2^3. When A is a byte array, index 0 is the leftmost bit of the leftmost byte. Setting bits 0 through 11 to 1 in a 4-byte-array of 0s yields the byte array 0xfff00000. Setting bit 3 to 1 on the 1-byte-array 0x00 yields the byte array 0x10.", "Groups": ["Arithmetic"]}, {"Opcode": 85, "Name": "getbyte", "Args": "BU", "Returns": "U", "Size": 1, "Doc": "Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails", "Groups": ["Arithmetic"]}, {"Opcode": 86, "Name": "setbyte", "Args": "BUU", "Returns": "B", "Size": 1, "Doc": "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", "Groups": ["Arithmetic"]}, {"Opcode": 87, "Name": "extract", "Args": "B", "Returns": "B", "Size": 3, "Doc": "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", "ImmediateNote": "{uint8 start position} {uint8 length}", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 88, "Name": "extract3", "Args": "BUU", "Returns": "B", "Size": 1, "Doc": "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\n`extract3` can be called using `extract` with no immediates.", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 89, "Name": "extract_uint16", "Args": "BU", "Returns": "U", "Size": 1, "Doc": "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", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 90, "Name": "extract_uint32", "Args": "BU", "Returns": "U", "Size": 1, "Doc": "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", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 91, "Name": "extract_uint64", "Args": "BU", "Returns": "U", "Size": 1, "Doc": "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", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 92, "Name": "replace2", "Args": "BB", "Returns": "B", "Size": 2, "Doc": "Copy of A with the bytes starting at S replaced by the bytes of B. Fails if S+len(B) exceeds len(A)\n`replace2` can be called using `replace` with 1 immediate.", "ImmediateNote": "{uint8 start position}", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 93, "Name": "replace3", "Args": "BUB", "Returns": "B", "Size": 1, "Doc": "Copy of A with the bytes starting at B replaced by the bytes of C. Fails if B+len(C) exceeds len(A)\n`replace3` can be called using `replace` with no immediates.", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 94, "Name": "base64_decode", "Args": "B", "Returns": "B", "Size": 2, "Doc": "decode A which was base64-encoded using _encoding_ E. Fail if A is not base64 encoded with encoding E", "DocExtra": "*Warning*: Usage should be restricted to very rare use cases. In almost all cases, smart contracts should directly handle non-encoded byte-strings.\tThis opcode should only be used in cases where base64 is the only available option, e.g. interoperability with a third-party that only signs base64 strings.\n\n Decodes A using the base64 encoding E. Specify the encoding with an immediate arg either as URL and Filename Safe (`URLEncoding`) or Standard (`StdEncoding`). See [RFC 4648 sections 4 and 5](https://rfc-editor.org/rfc/rfc4648.html#section-4). It is assumed that the encoding ends with the exact number of `=` padding characters as required by the RFC. When padding occurs, any unused pad bits in the encoding must be set to zero or the decoding will fail. The special cases of `\\n` and `\\r` are allowed but completely ignored. An error will result when attempting to decode a string with a character that is not in the encoding alphabet or not one of `=`, `\\r`, or `\\n`.", "ImmediateNote": "{uint8 encoding index}", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 95, "Name": "json_ref", "Args": "BB", "Returns": ".", "Size": 2, "Doc": "key B's value, of type R, from a [valid](jsonspec.md) utf-8 encoded json object A", "DocExtra": "*Warning*: Usage should be restricted to very rare use cases, as JSON decoding is expensive and quite limited. In addition, JSON objects are large and not optimized for size.\n\nAlmost all smart contracts should use simpler and smaller methods (such as the [ABI](https://arc.algorand.foundation/ARCs/arc-0004). This opcode should only be used in cases where JSON is only available option, e.g. when a third-party only signs JSON.", "ImmediateNote": "{uint8 return type}", "Groups": ["Byte Array Manipulation"]}, {"Opcode": 96, "Name": "balance", "Args": ".", "Returns": "U", "Size": 1, "Doc": "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`", "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value.", "Groups": ["State Access"]}, {"Opcode": 97, "Name": "app_opted_in", "Args": ".U", "Returns": "U", "Size": 1, "Doc": "1 if account A is opted in to application B, else 0", "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: 1 if opted in and 0 otherwise.", "Groups": ["State Access"]}, {"Opcode": 98, "Name": "app_local_get", "Args": ".B", "Returns": ".", "Size": 1, "Doc": "local state of the key B in the current application in account A", "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. Return: value. The value is zero (of type uint64) if the key does not exist.", "Groups": ["State Access"]}, {"Opcode": 99, "Name": "app_local_get_ex", "Args": ".UB", "Returns": ".U", "Size": 1, "Doc": "X is the local state of application B, key C in account A. Y is 1 if key existed, else 0", "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset), state key. Return: did_exist flag (top of the stack, 1 if the application and key existed and 0 otherwise), value. The value is zero (of type uint64) if the key does not exist.", "Groups": ["State Access"]}, {"Opcode": 100, "Name": "app_global_get", "Args": "B", "Returns": ".", "Size": 1, "Doc": "global state of the key A in the current application", "DocExtra": "params: state key. Return: value. The value is zero (of type uint64) if the key does not exist.", "Groups": ["State Access"]}, {"Opcode": 101, "Name": "app_global_get_ex", "Args": "UB", "Returns": ".U", "Size": 1, "Doc": "X is the global state of application A, key B. Y is 1 if key existed, else 0", "DocExtra": "params: Txn.ForeignApps offset (or, since v4, an _available_ application id), state key. Return: did_exist flag (top of the stack, 1 if the application and key existed and 0 otherwise), value. The value is zero (of type uint64) if the key does not exist.", "Groups": ["State Access"]}, {"Opcode": 102, "Name": "app_local_put", "Args": ".B.", "Size": 1, "Doc": "write C to key B in account A's local state of the current application", "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value.", "Groups": ["State Access"]}, {"Opcode": 103, "Name": "app_global_put", "Args": "B.", "Size": 1, "Doc": "write B to key A in the global state of the current application", "Groups": ["State Access"]}, {"Opcode": 104, "Name": "app_local_del", "Args": ".B", "Size": 1, "Doc": "delete key B from account A's local state of the current application", "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), state key.\n\nDeleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.)", "Groups": ["State Access"]}, {"Opcode": 105, "Name": "app_global_del", "Args": "B", "Size": 1, "Doc": "delete key A from the global state of the current application", "DocExtra": "params: state key.\n\nDeleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.)", "Groups": ["State Access"]}, {"Opcode": 112, "Name": "asset_holding_get", "Args": ".U", "Returns": ".U", "Size": 2, "ArgEnum": ["AssetBalance", "AssetFrozen"], "ArgEnumTypes": "UU", "Doc": "X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0", "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ address), asset id (or, since v4, a Txn.ForeignAssets offset). Return: did_exist flag (1 if the asset existed and 0 otherwise), value.", "ImmediateNote": "{uint8 asset holding field index}", "Groups": ["State Access"]}, {"Opcode": 113, "Name": "asset_params_get", "Args": "U", "Returns": ".U", "Size": 2, "ArgEnum": ["AssetTotal", "AssetDecimals", "AssetDefaultFrozen", "AssetUnitName", "AssetName", "AssetURL", "AssetMetadataHash", "AssetManager", "AssetReserve", "AssetFreeze", "AssetClawback", "AssetCreator"], "ArgEnumTypes": "UUUBBBBBBBBB", "Doc": "X is field F from asset A. Y is 1 if A exists, else 0", "DocExtra": "params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value.", "ImmediateNote": "{uint8 asset params field index}", "Groups": ["State Access"]}, {"Opcode": 114, "Name": "app_params_get", "Args": "U", "Returns": ".U", "Size": 2, "ArgEnum": ["AppApprovalProgram", "AppClearStateProgram", "AppGlobalNumUint", "AppGlobalNumByteSlice", "AppLocalNumUint", "AppLocalNumByteSlice", "AppExtraProgramPages", "AppCreator", "AppAddress"], "ArgEnumTypes": "BBUUUUUBB", "Doc": "X is field F from app A. Y is 1 if A exists, else 0", "DocExtra": "params: Txn.ForeignApps offset or an _available_ app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value.", "ImmediateNote": "{uint8 app params field index}", "Groups": ["State Access"]}, {"Opcode": 115, "Name": "acct_params_get", "Args": ".", "Returns": ".U", "Size": 2, "ArgEnum": ["AcctBalance", "AcctMinBalance", "AcctAuthAddr", "AcctTotalNumUint", "AcctTotalNumByteSlice", "AcctTotalExtraAppPages", "AcctTotalAppsCreated", "AcctTotalAppsOptedIn", "AcctTotalAssetsCreated", "AcctTotalAssets", "AcctTotalBoxes", "AcctTotalBoxBytes"], "ArgEnumTypes": "UUBUUUUUUUUU", "Doc": "X is field F from account A. Y is 1 if A owns positive algos, else 0", "ImmediateNote": "{uint8 account params field index}", "Groups": ["State Access"]}, {"Opcode": 120, "Name": "min_balance", "Args": ".", "Returns": "U", "Size": 1, "Doc": "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.", "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value.", "Groups": ["State Access"]}, {"Opcode": 128, "Name": "pushbytes", "Returns": "B", "Size": 0, "Doc": "immediate BYTES", "DocExtra": "pushbytes args are not added to the bytecblock during assembly processes", "ImmediateNote": "{varuint length} {bytes}", "Groups": ["Loading Values"]}, {"Opcode": 129, "Name": "pushint", "Returns": "U", "Size": 0, "Doc": "immediate UINT", "DocExtra": "pushint args are not added to the intcblock during assembly processes", "ImmediateNote": "{varuint int}", "Groups": ["Loading Values"]}, {"Opcode": 130, "Name": "pushbytess", "Size": 0, "Doc": "push sequences of immediate byte arrays to stack (first byte array being deepest)", "DocExtra": "pushbytess args are not added to the bytecblock during assembly processes", "ImmediateNote": "{varuint count} [({varuint value length} bytes), ...]", "Groups": ["Loading Values"]}, {"Opcode": 131, "Name": "pushints", "Size": 0, "Doc": "push sequence of immediate uints to stack in the order they appear (first uint being deepest)", "DocExtra": "pushints args are not added to the intcblock during assembly processes", "ImmediateNote": "{varuint count} [{varuint value}, ...]", "Groups": ["Loading Values"]}, {"Opcode": 132, "Name": "ed25519verify_bare", "Args": "BBB", "Returns": "U", "Size": 1, "Doc": "for (data A, signature B, pubkey C) verify the signature of the data against the pubkey => {0 or 1}", "Groups": ["Arithmetic"]}, {"Opcode": 136, "Name": "callsub", "Size": 3, "Doc": "branch unconditionally to TARGET, saving the next instruction on the call stack", "DocExtra": "The call stack is separate from the data stack. Only `callsub`, `retsub`, and `proto` manipulate it.", "ImmediateNote": "{int16 branch offset, big-endian}", "Groups": ["Flow Control"]}, {"Opcode": 137, "Name": "retsub", "Size": 1, "Doc": "pop the top instruction from the call stack and branch to it", "DocExtra": "If the current frame was prepared by `proto A R`, `retsub` will remove the 'A' arguments from the stack, move the `R` return values down, and pop any stack locations above the relocated return values.", "Groups": ["Flow Control"]}, {"Opcode": 138, "Name": "proto", "Size": 3, "Doc": "Prepare top call frame for a retsub that will assume A args and R return values.", "DocExtra": "Fails unless the last instruction executed was a `callsub`.", "ImmediateNote": "{uint8 arguments} {uint8 return values}", "Groups": ["Flow Control"]}, {"Opcode": 139, "Name": "frame_dig", "Returns": ".", "Size": 2, "Doc": "Nth (signed) value from the frame pointer.", "ImmediateNote": "{int8 frame slot}", "Groups": ["Flow Control"]}, {"Opcode": 140, "Name": "frame_bury", "Args": ".", "Size": 2, "Doc": "replace the Nth (signed) value from the frame pointer in the stack with A", "ImmediateNote": "{int8 frame slot}", "Groups": ["Flow Control"]}, {"Opcode": 141, "Name": "switch", "Args": "U", "Size": 0, "Doc": "branch to the Ath label. Continue at following instruction if index A exceeds the number of labels.", "ImmediateNote": "{uint8 branch count} [{int16 branch offset, big-endian}, ...]", "Groups": ["Flow Control"]}, {"Opcode": 142, "Name": "match", "Size": 0, "Doc": "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.", "DocExtra": "`match` consumes N+1 values from the stack. Let the top stack value be B. The following N values represent an ordered list of match cases/constants (A), where the first value (A[0]) is the deepest in the stack. The immediate arguments are an ordered list of N labels (T). `match` will branch to target T[I], where A[I] = B. If there are no matches then execution continues on to the next instruction.", "ImmediateNote": "{uint8 branch count} [{int16 branch offset, big-endian}, ...]", "Groups": ["Flow Control"]}, {"Opcode": 144, "Name": "shl", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A times 2^B, modulo 2^64", "Groups": ["Arithmetic"]}, {"Opcode": 145, "Name": "shr", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A divided by 2^B", "Groups": ["Arithmetic"]}, {"Opcode": 146, "Name": "sqrt", "Args": "U", "Returns": "U", "Size": 1, "Doc": "The largest integer I such that I^2 <= A", "Groups": ["Arithmetic"]}, {"Opcode": 147, "Name": "bitlen", "Args": ".", "Returns": "U", "Size": 1, "Doc": "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", "DocExtra": "bitlen interprets arrays as big-endian integers, unlike setbit/getbit", "Groups": ["Arithmetic"]}, {"Opcode": 148, "Name": "exp", "Args": "UU", "Returns": "U", "Size": 1, "Doc": "A raised to the Bth power. Fail if A == B == 0 and on overflow", "Groups": ["Arithmetic"]}, {"Opcode": 149, "Name": "expw", "Args": "UU", "Returns": "UU", "Size": 1, "Doc": "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", "Groups": ["Arithmetic"]}, {"Opcode": 150, "Name": "bsqrt", "Args": "B", "Returns": "B", "Size": 1, "Doc": "The largest integer I such that I^2 <= A. A and I are interpreted as big-endian unsigned integers", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 151, "Name": "divw", "Args": "UUU", "Returns": "U", "Size": 1, "Doc": "A,B / C. Fail if C == 0 or if result overflows.", "DocExtra": "The notation A,B indicates that A and B are interpreted as a uint128 value, with A as the high uint64 and B the low.", "Groups": ["Arithmetic"]}, {"Opcode": 152, "Name": "sha3_256", "Args": "B", "Returns": "B", "Size": 1, "Doc": "SHA3_256 hash of value A, yields [32]byte", "Groups": ["Arithmetic"]}, {"Opcode": 160, "Name": "b+", "Args": "BB", "Returns": "B", "Size": 1, "Doc": "A plus B. A and B are interpreted as big-endian unsigned integers", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 161, "Name": "b-", "Args": "BB", "Returns": "B", "Size": 1, "Doc": "A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 162, "Name": "b/", "Args": "BB", "Returns": "B", "Size": 1, "Doc": "A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 163, "Name": "b*", "Args": "BB", "Returns": "B", "Size": 1, "Doc": "A times B. A and B are interpreted as big-endian unsigned integers.", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 164, "Name": "b<", "Args": "BB", "Returns": "U", "Size": 1, "Doc": "1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 165, "Name": "b>", "Args": "BB", "Returns": "U", "Size": 1, "Doc": "1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 166, "Name": "b<=", "Args": "BB", "Returns": "U", "Size": 1, "Doc": "1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 167, "Name": "b>=", "Args": "BB", "Returns": "U", "Size": 1, "Doc": "1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 168, "Name": "b==", "Args": "BB", "Returns": "U", "Size": 1, "Doc": "1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 169, "Name": "b!=", "Args": "BB", "Returns": "U", "Size": 1, "Doc": "0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 170, "Name": "b%", "Args": "BB", "Returns": "B", "Size": 1, "Doc": "A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", "Groups": ["Byte Array Arithmetic"]}, {"Opcode": 171, "Name": "b|", "Args": "BB", "Returns": "B", "Size": 1, "Doc": "A bitwise-or B. A and B are zero-left extended to the greater of their lengths", "Groups": ["Byte Array Logic"]}, {"Opcode": 172, "Name": "b&", "Args": "BB", "Returns": "B", "Size": 1, "Doc": "A bitwise-and B. A and B are zero-left extended to the greater of their lengths", "Groups": ["Byte Array Logic"]}, {"Opcode": 173, "Name": "b^", "Args": "BB", "Returns": "B", "Size": 1, "Doc": "A bitwise-xor B. A and B are zero-left extended to the greater of their lengths", "Groups": ["Byte Array Logic"]}, {"Opcode": 174, "Name": "b~", "Args": "B", "Returns": "B", "Size": 1, "Doc": "A with all bits inverted", "Groups": ["Byte Array Logic"]}, {"Opcode": 175, "Name": "bzero", "Args": "U", "Returns": "B", "Size": 1, "Doc": "zero filled byte-array of length A", "Groups": ["Loading Values"]}, {"Opcode": 176, "Name": "log", "Args": "B", "Size": 1, "Doc": "write A to log state of the current application", "DocExtra": "`log` fails if called more than MaxLogCalls times in a program, or if the sum of logged bytes exceeds 1024 bytes.", "Groups": ["State Access"]}, {"Opcode": 177, "Name": "itxn_begin", "Size": 1, "Doc": "begin preparation of a new inner transaction in a new transaction group", "DocExtra": "`itxn_begin` initializes Sender to the application address; Fee to the minimum allowable, taking into account MinTxnFee and credit from overpaying in earlier transactions; FirstValid/LastValid to the values in the invoking transaction, and all other fields to zero or empty values.", "Groups": ["Inner Transactions"]}, {"Opcode": 178, "Name": "itxn_field", "Args": ".", "Size": 2, "ArgEnum": ["Sender", "Fee", "Note", "Receiver", "Amount", "CloseRemainderTo", "VotePK", "SelectionPK", "VoteFirst", "VoteLast", "VoteKeyDilution", "Type", "TypeEnum", "XferAsset", "AssetAmount", "AssetSender", "AssetReceiver", "AssetCloseTo", "ApplicationID", "OnCompletion", "ApplicationArgs", "Accounts", "ApprovalProgram", "ClearStateProgram", "RekeyTo", "ConfigAsset", "ConfigAssetTotal", "ConfigAssetDecimals", "ConfigAssetDefaultFrozen", "ConfigAssetUnitName", "ConfigAssetName", "ConfigAssetURL", "ConfigAssetMetadataHash", "ConfigAssetManager", "ConfigAssetReserve", "ConfigAssetFreeze", "ConfigAssetClawback", "FreezeAsset", "FreezeAssetAccount", "FreezeAssetFrozen", "Assets", "Applications", "GlobalNumUint", "GlobalNumByteSlice", "LocalNumUint", "LocalNumByteSlice", "ExtraProgramPages", "Nonparticipation", "StateProofPK", "ApprovalProgramPages", "ClearStateProgramPages"], "ArgEnumTypes": "BUBBUBBBUUUBUUUBBBUUBBBBBUUUUBBBBBBBBUBUUUUUUUUUBBB", "Doc": "set field F of the current inner transaction to A", "DocExtra": "`itxn_field` fails if A is of the wrong type for F, including a byte array of the wrong size for use as an address when F is an address field. `itxn_field` also fails if A is an account, asset, or app that is not _available_, or an attempt is made extend an array field beyond the limit imposed by consensus parameters. (Addresses set into asset params of acfg transactions need not be _available_.)", "ImmediateNote": "{uint8 transaction field index}", "Groups": ["Inner Transactions"]}, {"Opcode": 179, "Name": "itxn_submit", "Size": 1, "Doc": "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.", "DocExtra": "`itxn_submit` resets the current transaction so that it can not be resubmitted. A new `itxn_begin` is required to prepare another inner transaction.", "Groups": ["Inner Transactions"]}, {"Opcode": 180, "Name": "itxn", "Returns": ".", "Size": 2, "ArgEnum": ["Sender", "Fee", "FirstValid", "FirstValidTime", "LastValid", "Note", "Lease", "Receiver", "Amount", "CloseRemainderTo", "VotePK", "SelectionPK", "VoteFirst", "VoteLast", "VoteKeyDilution", "Type", "TypeEnum", "XferAsset", "AssetAmount", "AssetSender", "AssetReceiver", "AssetCloseTo", "GroupIndex", "TxID", "ApplicationID", "OnCompletion", "ApplicationArgs", "NumAppArgs", "Accounts", "NumAccounts", "ApprovalProgram", "ClearStateProgram", "RekeyTo", "ConfigAsset", "ConfigAssetTotal", "ConfigAssetDecimals", "ConfigAssetDefaultFrozen", "ConfigAssetUnitName", "ConfigAssetName", "ConfigAssetURL", "ConfigAssetMetadataHash", "ConfigAssetManager", "ConfigAssetReserve", "ConfigAssetFreeze", "ConfigAssetClawback", "FreezeAsset", "FreezeAssetAccount", "FreezeAssetFrozen", "Assets", "NumAssets", "Applications", "NumApplications", "GlobalNumUint", "GlobalNumByteSlice", "LocalNumUint", "LocalNumByteSlice", "ExtraProgramPages", "Nonparticipation", "Logs", "NumLogs", "CreatedAssetID", "CreatedApplicationID", "LastLog", "StateProofPK", "ApprovalProgramPages", "NumApprovalProgramPages", "ClearStateProgramPages", "NumClearStateProgramPages"], "ArgEnumTypes": "BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBBBUBU", "Doc": "field F of the last inner transaction", "ImmediateNote": "{uint8 transaction field index}", "Groups": ["Inner Transactions"]}, {"Opcode": 181, "Name": "itxna", "Returns": ".", "Size": 3, "ArgEnum": ["ApplicationArgs", "Accounts", "Assets", "Applications", "Logs", "ApprovalProgramPages", "ClearStateProgramPages"], "ArgEnumTypes": "BBUUBBB", "Doc": "Ith value of the array field F of the last inner transaction", "ImmediateNote": "{uint8 transaction field index} {uint8 transaction field array index}", "Groups": ["Inner Transactions"]}, {"Opcode": 182, "Name": "itxn_next", "Size": 1, "Doc": "begin preparation of a new inner transaction in the same transaction group", "DocExtra": "`itxn_next` initializes the transaction exactly as `itxn_begin` does", "Groups": ["Inner Transactions"]}, {"Opcode": 183, "Name": "gitxn", "Returns": ".", "Size": 3, "ArgEnum": ["Sender", "Fee", "FirstValid", "FirstValidTime", "LastValid", "Note", "Lease", "Receiver", "Amount", "CloseRemainderTo", "VotePK", "SelectionPK", "VoteFirst", "VoteLast", "VoteKeyDilution", "Type", "TypeEnum", "XferAsset", "AssetAmount", "AssetSender", "AssetReceiver", "AssetCloseTo", "GroupIndex", "TxID", "ApplicationID", "OnCompletion", "ApplicationArgs", "NumAppArgs", "Accounts", "NumAccounts", "ApprovalProgram", "ClearStateProgram", "RekeyTo", "ConfigAsset", "ConfigAssetTotal", "ConfigAssetDecimals", "ConfigAssetDefaultFrozen", "ConfigAssetUnitName", "ConfigAssetName", "ConfigAssetURL", "ConfigAssetMetadataHash", "ConfigAssetManager", "ConfigAssetReserve", "ConfigAssetFreeze", "ConfigAssetClawback", "FreezeAsset", "FreezeAssetAccount", "FreezeAssetFrozen", "Assets", "NumAssets", "Applications", "NumApplications", "GlobalNumUint", "GlobalNumByteSlice", "LocalNumUint", "LocalNumByteSlice", "ExtraProgramPages", "Nonparticipation", "Logs", "NumLogs", "CreatedAssetID", "CreatedApplicationID", "LastLog", "StateProofPK", "ApprovalProgramPages", "NumApprovalProgramPages", "ClearStateProgramPages", "NumClearStateProgramPages"], "ArgEnumTypes": "BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBBBUBU", "Doc": "field F of the Tth transaction in the last inner group submitted", "ImmediateNote": "{uint8 transaction group index} {uint8 transaction field index}", "Groups": ["Inner Transactions"]}, {"Opcode": 184, "Name": "gitxna", "Returns": ".", "Size": 4, "ArgEnum": ["ApplicationArgs", "Accounts", "Assets", "Applications", "Logs", "ApprovalProgramPages", "ClearStateProgramPages"], "ArgEnumTypes": "BBUUBBB", "Doc": "Ith value of the array field F from the Tth transaction in the last inner group submitted", "ImmediateNote": "{uint8 transaction group index} {uint8 transaction field index} {uint8 transaction field array index}", "Groups": ["Inner Transactions"]}, {"Opcode": 185, "Name": "box_create", "Args": "BU", "Returns": "U", "Size": 1, "Doc": "create a box named A, of length B. Fail if A is empty or B exceeds 32,768. Returns 0 if A already existed, else 1", "DocExtra": "Newly created boxes are filled with 0 bytes. `box_create` will fail if the referenced box already exists with a different size. Otherwise, existing boxes are unchanged by `box_create`.", "Groups": ["Box Access"]}, {"Opcode": 186, "Name": "box_extract", "Args": "BUU", "Returns": "B", "Size": 1, "Doc": "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.", "Groups": ["Box Access"]}, {"Opcode": 187, "Name": "box_replace", "Args": "BUB", "Size": 1, "Doc": "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.", "Groups": ["Box Access"]}, {"Opcode": 188, "Name": "box_del", "Args": "B", "Returns": "U", "Size": 1, "Doc": "delete box named A if it exists. Return 1 if A existed, 0 otherwise", "Groups": ["Box Access"]}, {"Opcode": 189, "Name": "box_len", "Args": "B", "Returns": "UU", "Size": 1, "Doc": "X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0.", "Groups": ["Box Access"]}, {"Opcode": 190, "Name": "box_get", "Args": "B", "Returns": "BU", "Size": 1, "Doc": "X is the contents of box A if A exists, else ''. Y is 1 if A exists, else 0.", "DocExtra": "For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `box_replace`", "Groups": ["Box Access"]}, {"Opcode": 191, "Name": "box_put", "Args": "BB", "Size": 1, "Doc": "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", "DocExtra": "For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `box_replace`", "Groups": ["Box Access"]}, {"Opcode": 192, "Name": "txnas", "Args": "U", "Returns": ".", "Size": 2, "ArgEnum": ["ApplicationArgs", "Accounts", "Assets", "Applications", "Logs", "ApprovalProgramPages", "ClearStateProgramPages"], "ArgEnumTypes": "BBUUBBB", "Doc": "Ath value of the array field F of the current transaction", "ImmediateNote": "{uint8 transaction field index}", "Groups": ["Loading Values"]}, {"Opcode": 193, "Name": "gtxnas", "Args": "U", "Returns": ".", "Size": 3, "ArgEnum": ["ApplicationArgs", "Accounts", "Assets", "Applications", "Logs", "ApprovalProgramPages", "ClearStateProgramPages"], "ArgEnumTypes": "BBUUBBB", "Doc": "Ath value of the array field F from the Tth transaction in the current group", "ImmediateNote": "{uint8 transaction group index} {uint8 transaction field index}", "Groups": ["Loading Values"]}, {"Opcode": 194, "Name": "gtxnsas", "Args": "UU", "Returns": ".", "Size": 2, "ArgEnum": ["ApplicationArgs", "Accounts", "Assets", "Applications", "Logs", "ApprovalProgramPages", "ClearStateProgramPages"], "ArgEnumTypes": "BBUUBBB", "Doc": "Bth value of the array field F from the Ath transaction in the current group", "ImmediateNote": "{uint8 transaction field index}", "Groups": ["Loading Values"]}, {"Opcode": 195, "Name": "args", "Args": "U", "Returns": "B", "Size": 1, "Doc": "Ath LogicSig argument", "Groups": ["Loading Values"]}, {"Opcode": 196, "Name": "gloadss", "Args": "UU", "Returns": ".", "Size": 1, "Doc": "Bth scratch space value of the Ath transaction in the current group", "Groups": ["Loading Values"]}, {"Opcode": 197, "Name": "itxnas", "Args": "U", "Returns": ".", "Size": 2, "Doc": "Ath value of the array field F of the last inner transaction", "ImmediateNote": "{uint8 transaction field index}", "Groups": ["Inner Transactions"]}, {"Opcode": 198, "Name": "gitxnas", "Args": "U", "Returns": ".", "Size": 3, "Doc": "Ath value of the array field F from the Tth transaction in the last inner group submitted", "ImmediateNote": "{uint8 transaction group index} {uint8 transaction field index}", "Groups": ["Inner Transactions"]}, {"Opcode": 208, "Name": "vrf_verify", "Args": "BBB", "Returns": "BU", "Size": 2, "Doc": "Verify the proof B of message A against pubkey C. Returns vrf output and verification flag.", "DocExtra": "`VrfAlgorand` is the VRF used in Algorand. It is ECVRF-ED25519-SHA512-Elligator2, specified in the IETF internet draft [draft-irtf-cfrg-vrf-03](https://datatracker.ietf.org/doc/draft-irtf-cfrg-vrf/03/).", "ImmediateNote": "{uint8 parameters index}", "Groups": ["Arithmetic"]}, {"Opcode": 209, "Name": "block", "Args": "U", "Returns": ".", "Size": 2, "Doc": "field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)", "ImmediateNote": "{uint8 block field}", "Groups": ["State Access"]}]} \ No newline at end of file +{ + "EvalMaxVersion": 8, + "LogicSigVersion": 8, + "StackTypes": { + "[]byte": { + "Type": "[]byte", + "LengthBound": [ + 0, + 4096 + ] + }, + "addr": { + "Type": "[]byte", + "LengthBound": [ + 32, + 32 + ] + }, + "any": { + "Type": "any", + "LengthBound": [ + 0, + 4096 + ], + "ValueBound": [ + 0, + 18446744073709551615 + ] + }, + "bigint": { + "Type": "[]byte", + "LengthBound": [ + 0, + 64 + ] + }, + "bool": { + "Type": "uint64", + "ValueBound": [ + 0, + 1 + ] + }, + "hash": { + "Type": "[]byte", + "LengthBound": [ + 32, + 32 + ] + }, + "key": { + "Type": "[]byte", + "LengthBound": [ + 0, + 64 + ] + }, + "method": { + "Type": "[]byte", + "LengthBound": [ + 4, + 4 + ] + }, + "none": { + "Type": "none" + }, + "uint64": { + "Type": "uint64", + "ValueBound": [ + 0, + 18446744073709551615 + ] + } + }, + "Fields": { + "ECDSA": [ + { + "Name": "Secp256k1", + "Type": "none", + "Note": "secp256k1 curve, used in Bitcoin", + "Value": 0 + }, + { + "Name": "Secp256r1", + "Type": "none", + "Note": "secp256r1 curve, NIST standard", + "Value": 1 + } + ], + "acct_params": [ + { + "Name": "AcctBalance", + "Type": "uint64", + "Note": "Account balance in microalgos", + "Value": 0 + }, + { + "Name": "AcctMinBalance", + "Type": "uint64", + "Note": "Minimum required balance for account, in microalgos", + "Value": 1 + }, + { + "Name": "AcctAuthAddr", + "Type": "addr", + "Note": "Address the account is rekeyed to.", + "Value": 2 + }, + { + "Name": "AcctTotalNumUint", + "Type": "uint64", + "Note": "The total number of uint64 values allocated by this account in Global and Local States.", + "Value": 3 + }, + { + "Name": "AcctTotalNumByteSlice", + "Type": "uint64", + "Note": "The total number of byte array values allocated by this account in Global and Local States.", + "Value": 4 + }, + { + "Name": "AcctTotalExtraAppPages", + "Type": "uint64", + "Note": "The number of extra app code pages used by this account.", + "Value": 5 + }, + { + "Name": "AcctTotalAppsCreated", + "Type": "uint64", + "Note": "The number of existing apps created by this account.", + "Value": 6 + }, + { + "Name": "AcctTotalAppsOptedIn", + "Type": "uint64", + "Note": "The number of apps this account is opted into.", + "Value": 7 + }, + { + "Name": "AcctTotalAssetsCreated", + "Type": "uint64", + "Note": "The number of existing ASAs created by this account.", + "Value": 8 + }, + { + "Name": "AcctTotalAssets", + "Type": "uint64", + "Note": "The numbers of ASAs held by this account (including ASAs this account created).", + "Value": 9 + }, + { + "Name": "AcctTotalBoxes", + "Type": "uint64", + "Note": "The number of existing boxes created by this account's app.", + "Value": 10 + }, + { + "Name": "AcctTotalBoxBytes", + "Type": "uint64", + "Note": "The total number of bytes used by this account's app's box keys and values.", + "Value": 11 + } + ], + "app_params": [ + { + "Name": "AppApprovalProgram", + "Type": "[]byte", + "Note": "Bytecode of Approval Program", + "Value": 0 + }, + { + "Name": "AppClearStateProgram", + "Type": "[]byte", + "Note": "Bytecode of Clear State Program", + "Value": 1 + }, + { + "Name": "AppGlobalNumUint", + "Type": "uint64", + "Note": "Number of uint64 values allowed in Global State", + "Value": 2 + }, + { + "Name": "AppGlobalNumByteSlice", + "Type": "uint64", + "Note": "Number of byte array values allowed in Global State", + "Value": 3 + }, + { + "Name": "AppLocalNumUint", + "Type": "uint64", + "Note": "Number of uint64 values allowed in Local State", + "Value": 4 + }, + { + "Name": "AppLocalNumByteSlice", + "Type": "uint64", + "Note": "Number of byte array values allowed in Local State", + "Value": 5 + }, + { + "Name": "AppExtraProgramPages", + "Type": "uint64", + "Note": "Number of Extra Program Pages of code space", + "Value": 6 + }, + { + "Name": "AppCreator", + "Type": "addr", + "Note": "Creator address", + "Value": 7 + }, + { + "Name": "AppAddress", + "Type": "addr", + "Note": "Address for which this application has authority", + "Value": 8 + } + ], + "asset_holding": [ + { + "Name": "AssetBalance", + "Type": "uint64", + "Note": "Amount of the asset unit held by this account", + "Value": 0 + }, + { + "Name": "AssetFrozen", + "Type": "bool", + "Note": "Is the asset frozen or not", + "Value": 1 + } + ], + "asset_params": [ + { + "Name": "AssetTotal", + "Type": "uint64", + "Note": "Total number of units of this asset", + "Value": 0 + }, + { + "Name": "AssetDecimals", + "Type": "uint64", + "Note": "See AssetParams.Decimals", + "Value": 1 + }, + { + "Name": "AssetDefaultFrozen", + "Type": "bool", + "Note": "Frozen by default or not", + "Value": 2 + }, + { + "Name": "AssetUnitName", + "Type": "[]byte", + "Note": "Asset unit name", + "Value": 3 + }, + { + "Name": "AssetName", + "Type": "[]byte", + "Note": "Asset name", + "Value": 4 + }, + { + "Name": "AssetURL", + "Type": "[]byte", + "Note": "URL with additional info about the asset", + "Value": 5 + }, + { + "Name": "AssetMetadataHash", + "Type": "hash", + "Note": "Arbitrary commitment", + "Value": 6 + }, + { + "Name": "AssetManager", + "Type": "addr", + "Note": "Manager address", + "Value": 7 + }, + { + "Name": "AssetReserve", + "Type": "addr", + "Note": "Reserve address", + "Value": 8 + }, + { + "Name": "AssetFreeze", + "Type": "addr", + "Note": "Freeze address", + "Value": 9 + }, + { + "Name": "AssetClawback", + "Type": "addr", + "Note": "Clawback address", + "Value": 10 + }, + { + "Name": "AssetCreator", + "Type": "addr", + "Note": "Creator address", + "Value": 11 + } + ], + "base64": [ + { + "Name": "URLEncoding", + "Type": "none", + "Value": 0 + }, + { + "Name": "StdEncoding", + "Type": "none", + "Value": 1 + } + ], + "block": [ + { + "Name": "BlkSeed", + "Type": "hash", + "Value": 0 + }, + { + "Name": "BlkTimestamp", + "Type": "uint64", + "Value": 1 + } + ], + "global": [ + { + "Name": "MinTxnFee", + "Type": "uint64", + "Note": "microalgos", + "Value": 0 + }, + { + "Name": "MinBalance", + "Type": "uint64", + "Note": "microalgos", + "Value": 1 + }, + { + "Name": "MaxTxnLife", + "Type": "uint64", + "Note": "rounds", + "Value": 2 + }, + { + "Name": "ZeroAddress", + "Type": "addr", + "Note": "32 byte address of all zero bytes", + "Value": 3 + }, + { + "Name": "GroupSize", + "Type": "uint64", + "Note": "Number of transactions in this atomic transaction group. At least 1", + "Value": 4 + }, + { + "Name": "LogicSigVersion", + "Type": "uint64", + "Note": "Maximum supported version", + "Value": 5 + }, + { + "Name": "Round", + "Type": "uint64", + "Note": "Current round number. Application mode only.", + "Value": 6 + }, + { + "Name": "LatestTimestamp", + "Type": "uint64", + "Note": "Last confirmed block UNIX timestamp. Fails if negative. Application mode only.", + "Value": 7 + }, + { + "Name": "CurrentApplicationID", + "Type": "uint64", + "Note": "ID of current application executing. Application mode only.", + "Value": 8 + }, + { + "Name": "CreatorAddress", + "Type": "addr", + "Note": "Address of the creator of the current application. Application mode only.", + "Value": 9 + }, + { + "Name": "CurrentApplicationAddress", + "Type": "addr", + "Note": "Address that the current application controls. Application mode only.", + "Value": 10 + }, + { + "Name": "GroupID", + "Type": "hash", + "Note": "ID of the transaction group. 32 zero bytes if the transaction is not part of a group.", + "Value": 11 + }, + { + "Name": "OpcodeBudget", + "Type": "uint64", + "Note": "The remaining cost that can be spent by opcodes in this program.", + "Value": 12 + }, + { + "Name": "CallerApplicationID", + "Type": "uint64", + "Note": "The application ID of the application that called this application. 0 if this application is at the top-level. Application mode only.", + "Value": 13 + }, + { + "Name": "CallerApplicationAddress", + "Type": "addr", + "Note": "The application address of the application that called this application. ZeroAddress if this application is at the top-level. Application mode only.", + "Value": 14 + } + ], + "itxn_field": [ + { + "Name": "Sender", + "Type": "addr", + "Note": "32 byte address", + "Value": 0 + }, + { + "Name": "Fee", + "Type": "uint64", + "Note": "microalgos", + "Value": 1 + }, + { + "Name": "Note", + "Type": "[]byte", + "Note": "Any data up to 1024 bytes", + "Value": 5 + }, + { + "Name": "Receiver", + "Type": "addr", + "Note": "32 byte address", + "Value": 7 + }, + { + "Name": "Amount", + "Type": "uint64", + "Note": "microalgos", + "Value": 8 + }, + { + "Name": "CloseRemainderTo", + "Type": "addr", + "Note": "32 byte address", + "Value": 9 + }, + { + "Name": "VotePK", + "Type": "addr", + "Note": "32 byte address", + "Value": 10 + }, + { + "Name": "SelectionPK", + "Type": "addr", + "Note": "32 byte address", + "Value": 11 + }, + { + "Name": "VoteFirst", + "Type": "uint64", + "Note": "The first round that the participation key is valid.", + "Value": 12 + }, + { + "Name": "VoteLast", + "Type": "uint64", + "Note": "The last round that the participation key is valid.", + "Value": 13 + }, + { + "Name": "VoteKeyDilution", + "Type": "uint64", + "Note": "Dilution for the 2-level participation key", + "Value": 14 + }, + { + "Name": "Type", + "Type": "[]byte", + "Note": "Transaction type as bytes", + "Value": 15 + }, + { + "Name": "TypeEnum", + "Type": "uint64", + "Note": "Transaction type as integer", + "Value": 16, + "ArgEnum": "itxn_type" + }, + { + "Name": "XferAsset", + "Type": "uint64", + "Note": "Asset ID", + "Value": 17 + }, + { + "Name": "AssetAmount", + "Type": "uint64", + "Note": "value in Asset's units", + "Value": 18 + }, + { + "Name": "AssetSender", + "Type": "addr", + "Note": "32 byte address. Source of assets if Sender is the Asset's Clawback address.", + "Value": 19 + }, + { + "Name": "AssetReceiver", + "Type": "addr", + "Note": "32 byte address", + "Value": 20 + }, + { + "Name": "AssetCloseTo", + "Type": "addr", + "Note": "32 byte address", + "Value": 21 + }, + { + "Name": "ApplicationID", + "Type": "uint64", + "Note": "ApplicationID from ApplicationCall transaction", + "Value": 24 + }, + { + "Name": "OnCompletion", + "Type": "uint64", + "Note": "ApplicationCall transaction on completion action", + "Value": 25, + "ArgEnum": "on_completion" + }, + { + "Name": "ApplicationArgs", + "Type": "[]byte", + "Note": "Arguments passed to the application in the ApplicationCall transaction", + "Value": 26 + }, + { + "Name": "Accounts", + "Type": "addr", + "Note": "Accounts listed in the ApplicationCall transaction", + "Value": 28 + }, + { + "Name": "ApprovalProgram", + "Type": "[]byte", + "Note": "Approval program", + "Value": 30 + }, + { + "Name": "ClearStateProgram", + "Type": "[]byte", + "Note": "Clear state program", + "Value": 31 + }, + { + "Name": "RekeyTo", + "Type": "addr", + "Note": "32 byte Sender's new AuthAddr", + "Value": 32 + }, + { + "Name": "ConfigAsset", + "Type": "uint64", + "Note": "Asset ID in asset config transaction", + "Value": 33 + }, + { + "Name": "ConfigAssetTotal", + "Type": "uint64", + "Note": "Total number of units of this asset created", + "Value": 34 + }, + { + "Name": "ConfigAssetDecimals", + "Type": "uint64", + "Note": "Number of digits to display after the decimal place when displaying the asset", + "Value": 35 + }, + { + "Name": "ConfigAssetDefaultFrozen", + "Type": "bool", + "Note": "Whether the asset's slots are frozen by default or not, 0 or 1", + "Value": 36 + }, + { + "Name": "ConfigAssetUnitName", + "Type": "[]byte", + "Note": "Unit name of the asset", + "Value": 37 + }, + { + "Name": "ConfigAssetName", + "Type": "[]byte", + "Note": "The asset name", + "Value": 38 + }, + { + "Name": "ConfigAssetURL", + "Type": "[]byte", + "Note": "URL", + "Value": 39 + }, + { + "Name": "ConfigAssetMetadataHash", + "Type": "hash", + "Note": "32 byte commitment to unspecified asset metadata", + "Value": 40 + }, + { + "Name": "ConfigAssetManager", + "Type": "addr", + "Note": "32 byte address", + "Value": 41 + }, + { + "Name": "ConfigAssetReserve", + "Type": "addr", + "Note": "32 byte address", + "Value": 42 + }, + { + "Name": "ConfigAssetFreeze", + "Type": "addr", + "Note": "32 byte address", + "Value": 43 + }, + { + "Name": "ConfigAssetClawback", + "Type": "addr", + "Note": "32 byte address", + "Value": 44 + }, + { + "Name": "FreezeAsset", + "Type": "uint64", + "Note": "Asset ID being frozen or un-frozen", + "Value": 45 + }, + { + "Name": "FreezeAssetAccount", + "Type": "addr", + "Note": "32 byte address of the account whose asset slot is being frozen or un-frozen", + "Value": 46 + }, + { + "Name": "FreezeAssetFrozen", + "Type": "bool", + "Note": "The new frozen value, 0 or 1", + "Value": 47 + }, + { + "Name": "Assets", + "Type": "uint64", + "Note": "Foreign Assets listed in the ApplicationCall transaction", + "Value": 48 + }, + { + "Name": "Applications", + "Type": "uint64", + "Note": "Foreign Apps listed in the ApplicationCall transaction", + "Value": 50 + }, + { + "Name": "GlobalNumUint", + "Type": "uint64", + "Note": "Number of global state integers in ApplicationCall", + "Value": 52 + }, + { + "Name": "GlobalNumByteSlice", + "Type": "uint64", + "Note": "Number of global state byteslices in ApplicationCall", + "Value": 53 + }, + { + "Name": "LocalNumUint", + "Type": "uint64", + "Note": "Number of local state integers in ApplicationCall", + "Value": 54 + }, + { + "Name": "LocalNumByteSlice", + "Type": "uint64", + "Note": "Number of local state byteslices in ApplicationCall", + "Value": 55 + }, + { + "Name": "ExtraProgramPages", + "Type": "uint64", + "Note": "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.", + "Value": 56 + }, + { + "Name": "Nonparticipation", + "Type": "bool", + "Note": "Marks an account nonparticipating for rewards", + "Value": 57 + }, + { + "Name": "StateProofPK", + "Type": "[]byte", + "Note": "64 byte state proof public key", + "Value": 63 + }, + { + "Name": "ApprovalProgramPages", + "Type": "[]byte", + "Note": "Approval Program as an array of pages", + "Value": 64 + }, + { + "Name": "ClearStateProgramPages", + "Type": "[]byte", + "Note": "ClearState Program as an array of pages", + "Value": 66 + } + ], + "itxn_type": [ + { + "Name": "pay", + "Type": "uint64", + "Note": "Payment", + "Value": 1 + }, + { + "Name": "keyreg", + "Type": "uint64", + "Note": "KeyRegistration", + "Value": 2 + }, + { + "Name": "acfg", + "Type": "uint64", + "Note": "AssetConfig", + "Value": 3 + }, + { + "Name": "axfer", + "Type": "uint64", + "Note": "AssetTransfer", + "Value": 4 + }, + { + "Name": "afrz", + "Type": "uint64", + "Note": "AssetFreeze", + "Value": 5 + }, + { + "Name": "appl", + "Type": "uint64", + "Note": "ApplicationCall", + "Value": 6 + } + ], + "json_ref": [ + { + "Name": "JSONString", + "Type": "[]byte", + "Value": 0 + }, + { + "Name": "JSONUint64", + "Type": "uint64", + "Value": 1 + }, + { + "Name": "JSONObject", + "Type": "[]byte", + "Value": 2 + } + ], + "on_complete": [ + { + "Name": "NoOp", + "Type": "uint64", + "Note": "Only execute the `ApprovalProgram` associated with this application ID, with no additional effects.", + "Value": 0 + }, + { + "Name": "OptIn", + "Type": "uint64", + "Note": "Before executing the `ApprovalProgram`, allocate local state for this application into the sender's account data.", + "Value": 1 + }, + { + "Name": "CloseOut", + "Type": "uint64", + "Note": "After executing the `ApprovalProgram`, clear any local state for this application out of the sender's account data.", + "Value": 2 + }, + { + "Name": "ClearState", + "Type": "uint64", + "Note": "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`.", + "Value": 3 + }, + { + "Name": "UpdateApplication", + "Type": "uint64", + "Note": "After executing the `ApprovalProgram`, replace the `ApprovalProgram` and `ClearStateProgram` associated with this application ID with the programs specified in this transaction.", + "Value": 4 + }, + { + "Name": "DeleteApplication", + "Type": "uint64", + "Note": "After executing the `ApprovalProgram`, delete the application parameters from the account data of the application's creator.", + "Value": 5 + } + ], + "txn": [ + { + "Name": "Sender", + "Type": "addr", + "Note": "32 byte address", + "Value": 0 + }, + { + "Name": "Fee", + "Type": "uint64", + "Note": "microalgos", + "Value": 1 + }, + { + "Name": "FirstValid", + "Type": "uint64", + "Note": "round number", + "Value": 2 + }, + { + "Name": "FirstValidTime", + "Type": "uint64", + "Note": "UNIX timestamp of block before txn.FirstValid. Fails if negative", + "Value": 3 + }, + { + "Name": "LastValid", + "Type": "uint64", + "Note": "round number", + "Value": 4 + }, + { + "Name": "Note", + "Type": "[]byte", + "Note": "Any data up to 1024 bytes", + "Value": 5 + }, + { + "Name": "Lease", + "Type": "hash", + "Note": "32 byte lease value", + "Value": 6 + }, + { + "Name": "Receiver", + "Type": "addr", + "Note": "32 byte address", + "Value": 7 + }, + { + "Name": "Amount", + "Type": "uint64", + "Note": "microalgos", + "Value": 8 + }, + { + "Name": "CloseRemainderTo", + "Type": "addr", + "Note": "32 byte address", + "Value": 9 + }, + { + "Name": "VotePK", + "Type": "addr", + "Note": "32 byte address", + "Value": 10 + }, + { + "Name": "SelectionPK", + "Type": "addr", + "Note": "32 byte address", + "Value": 11 + }, + { + "Name": "VoteFirst", + "Type": "uint64", + "Note": "The first round that the participation key is valid.", + "Value": 12 + }, + { + "Name": "VoteLast", + "Type": "uint64", + "Note": "The last round that the participation key is valid.", + "Value": 13 + }, + { + "Name": "VoteKeyDilution", + "Type": "uint64", + "Note": "Dilution for the 2-level participation key", + "Value": 14 + }, + { + "Name": "Type", + "Type": "[]byte", + "Note": "Transaction type as bytes", + "Value": 15 + }, + { + "Name": "TypeEnum", + "Type": "uint64", + "Note": "Transaction type as integer", + "Value": 16, + "ArgEnum": "txn_type" + }, + { + "Name": "XferAsset", + "Type": "uint64", + "Note": "Asset ID", + "Value": 17 + }, + { + "Name": "AssetAmount", + "Type": "uint64", + "Note": "value in Asset's units", + "Value": 18 + }, + { + "Name": "AssetSender", + "Type": "addr", + "Note": "32 byte address. Source of assets if Sender is the Asset's Clawback address.", + "Value": 19 + }, + { + "Name": "AssetReceiver", + "Type": "addr", + "Note": "32 byte address", + "Value": 20 + }, + { + "Name": "AssetCloseTo", + "Type": "addr", + "Note": "32 byte address", + "Value": 21 + }, + { + "Name": "GroupIndex", + "Type": "uint64", + "Note": "Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1", + "Value": 22 + }, + { + "Name": "TxID", + "Type": "hash", + "Note": "The computed ID for this transaction. 32 bytes.", + "Value": 23 + }, + { + "Name": "ApplicationID", + "Type": "uint64", + "Note": "ApplicationID from ApplicationCall transaction", + "Value": 24 + }, + { + "Name": "OnCompletion", + "Type": "uint64", + "Note": "ApplicationCall transaction on completion action", + "Value": 25, + "ArgEnum": "on_completion" + }, + { + "Name": "NumAppArgs", + "Type": "uint64", + "Note": "Number of ApplicationArgs", + "Value": 27 + }, + { + "Name": "NumAccounts", + "Type": "uint64", + "Note": "Number of Accounts", + "Value": 29 + }, + { + "Name": "ApprovalProgram", + "Type": "[]byte", + "Note": "Approval program", + "Value": 30 + }, + { + "Name": "ClearStateProgram", + "Type": "[]byte", + "Note": "Clear state program", + "Value": 31 + }, + { + "Name": "RekeyTo", + "Type": "addr", + "Note": "32 byte Sender's new AuthAddr", + "Value": 32 + }, + { + "Name": "ConfigAsset", + "Type": "uint64", + "Note": "Asset ID in asset config transaction", + "Value": 33 + }, + { + "Name": "ConfigAssetTotal", + "Type": "uint64", + "Note": "Total number of units of this asset created", + "Value": 34 + }, + { + "Name": "ConfigAssetDecimals", + "Type": "uint64", + "Note": "Number of digits to display after the decimal place when displaying the asset", + "Value": 35 + }, + { + "Name": "ConfigAssetDefaultFrozen", + "Type": "bool", + "Note": "Whether the asset's slots are frozen by default or not, 0 or 1", + "Value": 36 + }, + { + "Name": "ConfigAssetUnitName", + "Type": "[]byte", + "Note": "Unit name of the asset", + "Value": 37 + }, + { + "Name": "ConfigAssetName", + "Type": "[]byte", + "Note": "The asset name", + "Value": 38 + }, + { + "Name": "ConfigAssetURL", + "Type": "[]byte", + "Note": "URL", + "Value": 39 + }, + { + "Name": "ConfigAssetMetadataHash", + "Type": "hash", + "Note": "32 byte commitment to unspecified asset metadata", + "Value": 40 + }, + { + "Name": "ConfigAssetManager", + "Type": "addr", + "Note": "32 byte address", + "Value": 41 + }, + { + "Name": "ConfigAssetReserve", + "Type": "addr", + "Note": "32 byte address", + "Value": 42 + }, + { + "Name": "ConfigAssetFreeze", + "Type": "addr", + "Note": "32 byte address", + "Value": 43 + }, + { + "Name": "ConfigAssetClawback", + "Type": "addr", + "Note": "32 byte address", + "Value": 44 + }, + { + "Name": "FreezeAsset", + "Type": "uint64", + "Note": "Asset ID being frozen or un-frozen", + "Value": 45 + }, + { + "Name": "FreezeAssetAccount", + "Type": "addr", + "Note": "32 byte address of the account whose asset slot is being frozen or un-frozen", + "Value": 46 + }, + { + "Name": "FreezeAssetFrozen", + "Type": "bool", + "Note": "The new frozen value, 0 or 1", + "Value": 47 + }, + { + "Name": "NumAssets", + "Type": "uint64", + "Note": "Number of Assets", + "Value": 49 + }, + { + "Name": "NumApplications", + "Type": "uint64", + "Note": "Number of Applications", + "Value": 51 + }, + { + "Name": "GlobalNumUint", + "Type": "uint64", + "Note": "Number of global state integers in ApplicationCall", + "Value": 52 + }, + { + "Name": "GlobalNumByteSlice", + "Type": "uint64", + "Note": "Number of global state byteslices in ApplicationCall", + "Value": 53 + }, + { + "Name": "LocalNumUint", + "Type": "uint64", + "Note": "Number of local state integers in ApplicationCall", + "Value": 54 + }, + { + "Name": "LocalNumByteSlice", + "Type": "uint64", + "Note": "Number of local state byteslices in ApplicationCall", + "Value": 55 + }, + { + "Name": "ExtraProgramPages", + "Type": "uint64", + "Note": "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.", + "Value": 56 + }, + { + "Name": "Nonparticipation", + "Type": "bool", + "Note": "Marks an account nonparticipating for rewards", + "Value": 57 + }, + { + "Name": "NumLogs", + "Type": "uint64", + "Note": "Number of Logs (only with `itxn` in v5). Application mode only", + "Value": 59 + }, + { + "Name": "CreatedAssetID", + "Type": "uint64", + "Note": "Asset ID allocated by the creation of an ASA (only with `itxn` in v5). Application mode only", + "Value": 60 + }, + { + "Name": "CreatedApplicationID", + "Type": "uint64", + "Note": "ApplicationID allocated by the creation of an application (only with `itxn` in v5). Application mode only", + "Value": 61 + }, + { + "Name": "LastLog", + "Type": "[]byte", + "Note": "The last message emitted. Empty bytes if none were emitted. Application mode only", + "Value": 62 + }, + { + "Name": "StateProofPK", + "Type": "[]byte", + "Note": "64 byte state proof public key", + "Value": 63 + }, + { + "Name": "NumApprovalProgramPages", + "Type": "uint64", + "Note": "Number of Approval Program pages", + "Value": 65 + }, + { + "Name": "NumClearStateProgramPages", + "Type": "uint64", + "Note": "Number of ClearState Program pages", + "Value": 67 + } + ], + "txn_type": [ + { + "Name": "unknown", + "Type": "uint64", + "Note": "Unknown type. Invalid transaction", + "Value": 0 + }, + { + "Name": "pay", + "Type": "uint64", + "Note": "Payment", + "Value": 1 + }, + { + "Name": "keyreg", + "Type": "uint64", + "Note": "KeyRegistration", + "Value": 2 + }, + { + "Name": "acfg", + "Type": "uint64", + "Note": "AssetConfig", + "Value": 3 + }, + { + "Name": "axfer", + "Type": "uint64", + "Note": "AssetTransfer", + "Value": 4 + }, + { + "Name": "afrz", + "Type": "uint64", + "Note": "AssetFreeze", + "Value": 5 + }, + { + "Name": "appl", + "Type": "uint64", + "Note": "ApplicationCall", + "Value": 6 + } + ], + "txna": [ + { + "Name": "ApplicationArgs", + "Type": "[]byte", + "Note": "Arguments passed to the application in the ApplicationCall transaction", + "Value": 26 + }, + { + "Name": "Accounts", + "Type": "addr", + "Note": "Accounts listed in the ApplicationCall transaction", + "Value": 28 + }, + { + "Name": "Assets", + "Type": "uint64", + "Note": "Foreign Assets listed in the ApplicationCall transaction", + "Value": 48 + }, + { + "Name": "Applications", + "Type": "uint64", + "Note": "Foreign Apps listed in the ApplicationCall transaction", + "Value": 50 + }, + { + "Name": "Logs", + "Type": "[]byte", + "Note": "Log messages emitted by an application call (only with `itxn` in v5). Application mode only", + "Value": 58 + }, + { + "Name": "ApprovalProgramPages", + "Type": "[]byte", + "Note": "Approval Program as an array of pages", + "Value": 64 + }, + { + "Name": "ClearStateProgramPages", + "Type": "[]byte", + "Note": "ClearState Program as an array of pages", + "Value": 66 + } + ], + "vrf_verify": [ + { + "Name": "VrfAlgorand", + "Type": "none", + "Value": 0 + } + ] + }, + "PseudoOps": [ + { + "Name": "method", + "ImmediateDetails":[ + { + "Comment": "Method Signature", + "Encoding": "bytes", + "Name": "methodsig" + } + ], + "Returns": [ + "method" + ], + "Size": 2, + "Cost": "" + }, + { + "Name": "int", + "Returns": [ + "uint64" + ], + "Size": 2, + "Cost": "" + }, + { + "Name": "byte", + "Returns": [ + "[]byte" + ], + "Size": 2, + "Cost": "" + }, + { + "Name": "addr", + "Returns": [ + "addr" + ], + "Size": 2, + "Cost": "" + } + ], + "Ops": [ + { + "Name": "err", + "Returns": [ + "none" + ], + "Size": 1, + "Doc": "Fail immediately.", + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 1, + "Name": "sha256", + "Args": [ + "[]byte" + ], + "Returns": [ + "hash" + ], + "Size": 1, + "Doc": "SHA256 hash of value A", + "Groups": [ + "Arithmetic" + ], + "Cost": "35" + }, + { + "Opcode": 2, + "Name": "keccak256", + "Args": [ + "[]byte" + ], + "Returns": [ + "hash" + ], + "Size": 1, + "Doc": "Keccak256 hash of value A", + "Groups": [ + "Arithmetic" + ], + "Cost": "130" + }, + { + "Opcode": 3, + "Name": "sha512_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "hash" + ], + "Size": 1, + "Doc": "SHA512_256 hash of value A", + "Groups": [ + "Arithmetic" + ], + "Cost": "45" + }, + { + "Opcode": 4, + "Name": "ed25519verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey", + "DocExtra": "The 32 byte public key is the last element on the stack, preceded by the 64 byte signature at the second-to-last element on the stack, preceded by the data which was signed at the third-to-last element on the stack.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1900" + }, + { + "Opcode": 5, + "Name": "ecdsa_verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 2, + "ArgEnum": "ECDSA", + "Doc": "for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey", + "DocExtra": "The 32 byte Y-component of a public key is the last element on the stack, preceded by X-component of a pubkey, preceded by S and R components of a signature, preceded by the data that is fifth element on the stack. All values are big-endian encoded. The signed data must be 32 bytes long, and signatures in lower-S form are only accepted.", + "ImmediateDetails": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "Groups": [ + "Arithmetic" + ], + "Cost": " Secp256k1=1700 Secp256r1=2500" + }, + { + "Opcode": 6, + "Name": "ecdsa_pk_decompress", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": "ECDSA", + "Doc": "decompress pubkey A into components X, Y", + "DocExtra": "The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded.", + "ImmediateDetails": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "Groups": [ + "Arithmetic" + ], + "Cost": " Secp256k1=650 Secp256r1=2400" + }, + { + "Opcode": 7, + "Name": "ecdsa_pk_recover", + "Args": [ + "[]byte", + "uint64", + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": "ECDSA", + "Doc": "for (data A, recovery id B, signature C, D) recover a public key", + "DocExtra": "S (top) and R elements of a signature, recovery id and data (bottom) are expected on the stack and used to deriver a public key. All values are big-endian encoded. The signed data must be 32 bytes long.", + "ImmediateDetails": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "Groups": [ + "Arithmetic" + ], + "Cost": "2000" + }, + { + "Opcode": 8, + "Name": "+", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A plus B. Fail on overflow.", + "DocExtra": "Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 9, + "Name": "-", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A minus B. Fail if B > A.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 10, + "Name": "/", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A divided by B (truncated division). Fail if B == 0.", + "DocExtra": "`divmodw` is available to divide the two-element values produced by `mulw` and `addw`.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 11, + "Name": "*", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A times B. Fail on overflow.", + "DocExtra": "Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 12, + "Name": "<", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "A less than B", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 13, + "Name": ">", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "A greater than B", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 14, + "Name": "<=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "A less than or equal to B", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 15, + "Name": ">=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "A greater than or equal to B", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 16, + "Name": "&&", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "A is not zero and B is not zero", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 17, + "Name": "||", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "A is not zero or B is not zero", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 18, + "Name": "==", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "A is equal to B", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 19, + "Name": "!=", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "A is not equal to B", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 20, + "Name": "!", + "Args": [ + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "A == 0 yields 1; else 0", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 21, + "Name": "len", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "yields length of byte value A", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 22, + "Name": "itob", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "converts uint64 A to big-endian byte array, always of length 8", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 23, + "Name": "btoi", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8.", + "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 24, + "Name": "%", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A modulo B. Fail if B == 0.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 25, + "Name": "|", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A bitwise-or B", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 26, + "Name": "&", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A bitwise-and B", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 27, + "Name": "^", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A bitwise-xor B", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 28, + "Name": "~", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "bitwise invert value A", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 29, + "Name": "mulw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 30, + "Name": "addw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 31, + "Name": "divmodw", + "Args": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Size": 1, + "Doc": "W,X = (A,B / C,D); Y,Z = (A,B modulo C,D)", + "DocExtra": "The notation J,K indicates that two uint64 values J and K are interpreted as a uint128 value, with J as the high uint64 and K the low.", + "Groups": [ + "Arithmetic" + ], + "Cost": "20" + }, + { + "Opcode": 32, + "Name": "intcblock", + "Size": 0, + "Doc": "prepare block of uint64 constants for use by intc", + "DocExtra": "`intcblock` loads following program bytes into an array of integer constants in the evaluator. These integer constants can be referred to by `intc` and `intc_*` which will push the value onto the stack. Subsequent calls to `intcblock` reset and replace the integer constants available to the script.", + "ImmediateDetails": [ + { + "Comment": "a block of int constant values", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 33, + "Name": "intc", + "Returns": [ + "uint64" + ], + "Size": 2, + "Doc": "Ith constant from intcblock", + "ImmediateDetails": [ + { + "Comment": "an index in the intcblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 34, + "Name": "intc_0", + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "constant 0 from intcblock", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 35, + "Name": "intc_1", + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "constant 1 from intcblock", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 36, + "Name": "intc_2", + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "constant 2 from intcblock", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 37, + "Name": "intc_3", + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "constant 3 from intcblock", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 38, + "Name": "bytecblock", + "Size": 0, + "Doc": "prepare block of byte-array constants for use by bytec", + "DocExtra": "`bytecblock` loads the following program bytes into an array of byte-array constants in the evaluator. These constants can be referred to by `bytec` and `bytec_*` which will push the value onto the stack. Subsequent calls to `bytecblock` reset and replace the bytes constants available to the script.", + "ImmediateDetails": [ + { + "Comment": "a block of byte const values", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 39, + "Name": "bytec", + "Returns": [ + "[]byte" + ], + "Size": 2, + "Doc": "Ith constant from bytecblock", + "ImmediateDetails": [ + { + "Comment": "an index in the bytec block", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 40, + "Name": "bytec_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "constant 0 from bytecblock", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 41, + "Name": "bytec_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "constant 1 from bytecblock", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 42, + "Name": "bytec_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "constant 2 from bytecblock", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 43, + "Name": "bytec_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "constant 3 from bytecblock", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 44, + "Name": "arg", + "Returns": [ + "[]byte" + ], + "Size": 2, + "Doc": "Nth LogicSig argument", + "ImmediateDetails": [ + { + "Comment": "an arg index", + "Encoding": "uint8", + "Name": "N" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 45, + "Name": "arg_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "LogicSig argument 0", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 46, + "Name": "arg_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "LogicSig argument 1", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 47, + "Name": "arg_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "LogicSig argument 2", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 48, + "Name": "arg_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "LogicSig argument 3", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 49, + "Name": "txn", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": "txn", + "Doc": "field F of current transaction", + "ImmediateDetails": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 50, + "Name": "global", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": "global", + "Doc": "global field F", + "ImmediateDetails": [ + { + "Comment": "a global field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "global" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 51, + "Name": "gtxn", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": "txn", + "Doc": "field F of the Tth transaction in the current group", + "DocExtra": "for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`.", + "ImmediateDetails": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 52, + "Name": "load", + "Returns": [ + "any" + ], + "Size": 2, + "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", + "ImmediateDetails": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 53, + "Name": "store", + "Args": [ + "any" + ], + "Size": 2, + "Doc": "store A to the Ith scratch space", + "ImmediateDetails": [ + { + "Comment": "position in scratch space to store to", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 54, + "Name": "txna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": "txna", + "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", + "ImmediateDetails": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 55, + "Name": "gtxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": "txna", + "Doc": "Ith value of the array field F from the Tth transaction in the current group\n`gtxna` can be called using `gtxn` with 3 immediates.", + "ImmediateDetails": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 56, + "Name": "gtxns", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": "txn", + "Doc": "field F of the Ath transaction in the current group", + "DocExtra": "for notes on transaction fields available, see `txn`. If top of stack is _i_, `gtxns field` is equivalent to `gtxn _i_ field`. gtxns exists so that _i_ can be calculated, often based on the index of the current transaction.", + "ImmediateDetails": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 57, + "Name": "gtxnsa", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": "txna", + "Doc": "Ith value of the array field F from the Ath transaction in the current group\n`gtxnsa` can be called using `gtxns` with 2 immediates.", + "ImmediateDetails": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 58, + "Name": "gload", + "Returns": [ + "any" + ], + "Size": 3, + "Doc": "Ith scratch space value of the Tth transaction in the current group", + "DocExtra": "`gload` fails unless the requested transaction is an ApplicationCall and T < GroupIndex.", + "ImmediateDetails": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 59, + "Name": "gloads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "Doc": "Ith scratch space value of the Ath transaction in the current group", + "DocExtra": "`gloads` fails unless the requested transaction is an ApplicationCall and A < GroupIndex.", + "ImmediateDetails": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 60, + "Name": "gaid", + "Returns": [ + "uint64" + ], + "Size": 2, + "Doc": "ID of the asset or application created in the Tth transaction of the current group", + "DocExtra": "`gaid` fails unless the requested transaction created an asset or application and T < GroupIndex.", + "ImmediateDetails": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 61, + "Name": "gaids", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "ID of the asset or application created in the Ath transaction of the current group", + "DocExtra": "`gaids` fails unless the requested transaction created an asset or application and A < GroupIndex.", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 62, + "Name": "loads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "Doc": "Ath scratch space value. All scratch spaces are 0 at program start.", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 63, + "Name": "stores", + "Args": [ + "uint64", + "any" + ], + "Size": 1, + "Doc": "store B to the Ath scratch space", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 64, + "Name": "bnz", + "Args": [ + "uint64" + ], + "Size": 3, + "Doc": "branch to TARGET if value A is not zero", + "DocExtra": "The `bnz` instruction opcode 0x40 is followed by two immediate data bytes which are a high byte first and low byte second which together form a 16 bit offset which the instruction may branch to. For a bnz instruction at `pc`, if the last element of the stack is not zero then branch to instruction at `pc + 3 + N`, else proceed to next instruction at `pc + 3`. Branch targets must be aligned instructions. (e.g. Branching to the second byte of a 2 byte op will be rejected.) Starting at v4, the offset is treated as a signed 16 bit integer allowing for backward branches and looping. In prior version (v1 to v3), branch offsets are limited to forward branches only, 0-0x7fff.\n\nAt v2 it became allowed to branch to the end of the program exactly after the last instruction: bnz to byte N (with 0-indexing) was illegal for a TEAL program with N bytes before v2, and is legal after it. This change eliminates the need for a last instruction of no-op as a branch target at the end. (Branching beyond the end--in other words, to a byte larger than N--is still illegal and will cause the program to fail.)", + "ImmediateDetails": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 65, + "Name": "bz", + "Args": [ + "uint64" + ], + "Size": 3, + "Doc": "branch to TARGET if value A is zero", + "DocExtra": "See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`.", + "ImmediateDetails": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 66, + "Name": "b", + "Size": 3, + "Doc": "branch unconditionally to TARGET", + "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", + "ImmediateDetails": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 67, + "Name": "return", + "Args": [ + "uint64" + ], + "Returns": [ + "none" + ], + "Size": 1, + "Doc": "use A as success value; end", + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 68, + "Name": "assert", + "Args": [ + "uint64" + ], + "Size": 1, + "Doc": "immediately fail unless A is a non-zero number", + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 69, + "Name": "bury", + "Args": [ + "any" + ], + "Size": 2, + "Doc": "replace the Nth value from the top of the stack with A. bury 0 fails.", + "ImmediateDetails": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 70, + "Name": "popn", + "Size": 2, + "Doc": "remove N values from the top of the stack", + "ImmediateDetails": [ + { + "Comment": "the stack depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 71, + "Name": "dupn", + "Args": [ + "any" + ], + "Size": 2, + "Doc": "duplicate A, N times", + "ImmediateDetails": [ + { + "Comment": "the copy count", + "Encoding": "uint8", + "Name": "N" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 72, + "Name": "pop", + "Args": [ + "any" + ], + "Size": 1, + "Doc": "discard A", + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 73, + "Name": "dup", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "Doc": "duplicate A", + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 74, + "Name": "dup2", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any", + "any", + "any" + ], + "Size": 1, + "Doc": "duplicate A and B", + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 75, + "Name": "dig", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 2, + "Doc": "Nth value from the top of the stack. dig 0 is equivalent to dup", + "ImmediateDetails": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 76, + "Name": "swap", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "Doc": "swaps A and B on stack", + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 77, + "Name": "select", + "Args": [ + "any", + "any", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "Doc": "selects one of two values based on top-of-stack: B if C != 0, else A", + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 78, + "Name": "cover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "Doc": "remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth <= N.", + "ImmediateDetails": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 79, + "Name": "uncover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "Doc": "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.", + "ImmediateDetails": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 80, + "Name": "concat", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "join A and B", + "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 81, + "Name": "substring", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "Doc": "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", + "ImmediateDetails": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "end position", + "Encoding": "uint8", + "Name": "E" + } + ], + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "1" + }, + { + "Opcode": 82, + "Name": "substring3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "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", + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "1" + }, + { + "Opcode": 83, + "Name": "getbit", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "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", + "DocExtra": "see explanation of bit ordering in setbit", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 84, + "Name": "setbit", + "Args": [ + "any", + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "Doc": "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", + "DocExtra": "When A is a uint64, index 0 is the least significant bit. Setting bit 3 to 1 on the integer 0 yields 8, or 2^3. When A is a byte array, index 0 is the leftmost bit of the leftmost byte. Setting bits 0 through 11 to 1 in a 4-byte-array of 0s yields the byte array 0xfff00000. Setting bit 3 to 1 on the 1-byte-array 0x00 yields the byte array 0x10.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 85, + "Name": "getbyte", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 86, + "Name": "setbyte", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "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", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 87, + "Name": "extract", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "Doc": "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", + "ImmediateDetails": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "length", + "Encoding": "uint8", + "Name": "L" + } + ], + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "1" + }, + { + "Opcode": 88, + "Name": "extract3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "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\n`extract3` can be called using `extract` with no immediates.", + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "1" + }, + { + "Opcode": 89, + "Name": "extract_uint16", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "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", + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "1" + }, + { + "Opcode": 90, + "Name": "extract_uint32", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "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", + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "1" + }, + { + "Opcode": 91, + "Name": "extract_uint64", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "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", + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "1" + }, + { + "Opcode": 92, + "Name": "replace2", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 2, + "Doc": "Copy of A with the bytes starting at S replaced by the bytes of B. Fails if S+len(B) exceeds len(A)\n`replace2` can be called using `replace` with 1 immediate.", + "ImmediateDetails": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + } + ], + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "1" + }, + { + "Opcode": 93, + "Name": "replace3", + "Args": [ + "[]byte", + "uint64", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "Copy of A with the bytes starting at B replaced by the bytes of C. Fails if B+len(C) exceeds len(A)\n`replace3` can be called using `replace` with no immediates.", + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "1" + }, + { + "Opcode": 94, + "Name": "base64_decode", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 2, + "ArgEnum": "base64", + "Doc": "decode A which was base64-encoded using _encoding_ E. Fail if A is not base64 encoded with encoding E", + "DocExtra": "*Warning*: Usage should be restricted to very rare use cases. In almost all cases, smart contracts should directly handle non-encoded byte-strings.\tThis opcode should only be used in cases where base64 is the only available option, e.g. interoperability with a third-party that only signs base64 strings.\n\n Decodes A using the base64 encoding E. Specify the encoding with an immediate arg either as URL and Filename Safe (`URLEncoding`) or Standard (`StdEncoding`). See [RFC 4648 sections 4 and 5](https://rfc-editor.org/rfc/rfc4648.html#section-4). It is assumed that the encoding ends with the exact number of `=` padding characters as required by the RFC. When padding occurs, any unused pad bits in the encoding must be set to zero or the decoding will fail. The special cases of `\\n` and `\\r` are allowed but completely ignored. An error will result when attempting to decode a string with a character that is not in the encoding alphabet or not one of `=`, `\\r`, or `\\n`.", + "ImmediateDetails": [ + { + "Comment": "an encoding index", + "Encoding": "uint8", + "Name": "E", + "Reference": "base64" + } + ], + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "1 + 1 per 16 bytes of A" + }, + { + "Opcode": 95, + "Name": "json_ref", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": "json_ref", + "Doc": "key B's value, of type R, from a [valid](jsonspec.md) utf-8 encoded json object A", + "DocExtra": "*Warning*: Usage should be restricted to very rare use cases, as JSON decoding is expensive and quite limited. In addition, JSON objects are large and not optimized for size.\n\nAlmost all smart contracts should use simpler and smaller methods (such as the [ABI](https://arc.algorand.foundation/ARCs/arc-0004). This opcode should only be used in cases where JSON is only available option, e.g. when a third-party only signs JSON.", + "ImmediateDetails": [ + { + "Comment": "a return type index", + "Encoding": "uint8", + "Name": "R", + "Reference": "json_ref" + } + ], + "Groups": [ + "Byte Array Manipulation" + ], + "Cost": "25 + 2 per 7 bytes of A" + }, + { + "Opcode": 96, + "Name": "balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "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`", + "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value.", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 97, + "Name": "app_opted_in", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "1 if account A is opted in to application B, else 0", + "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: 1 if opted in and 0 otherwise.", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 98, + "Name": "app_local_get", + "Args": [ + "any", + "key" + ], + "Returns": [ + "any" + ], + "Size": 1, + "Doc": "local state of the key B in the current application in account A", + "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. Return: value. The value is zero (of type uint64) if the key does not exist.", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 99, + "Name": "app_local_get_ex", + "Args": [ + "any", + "uint64", + "key" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "Doc": "X is the local state of application B, key C in account A. Y is 1 if key existed, else 0", + "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset), state key. Return: did_exist flag (top of the stack, 1 if the application and key existed and 0 otherwise), value. The value is zero (of type uint64) if the key does not exist.", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 100, + "Name": "app_global_get", + "Args": [ + "key" + ], + "Returns": [ + "any" + ], + "Size": 1, + "Doc": "global state of the key A in the current application", + "DocExtra": "params: state key. Return: value. The value is zero (of type uint64) if the key does not exist.", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 101, + "Name": "app_global_get_ex", + "Args": [ + "uint64", + "key" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "Doc": "X is the global state of application A, key B. Y is 1 if key existed, else 0", + "DocExtra": "params: Txn.ForeignApps offset (or, since v4, an _available_ application id), state key. Return: did_exist flag (top of the stack, 1 if the application and key existed and 0 otherwise), value. The value is zero (of type uint64) if the key does not exist.", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 102, + "Name": "app_local_put", + "Args": [ + "any", + "key", + "any" + ], + "Size": 1, + "Doc": "write C to key B in account A's local state of the current application", + "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value.", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 103, + "Name": "app_global_put", + "Args": [ + "key", + "any" + ], + "Size": 1, + "Doc": "write B to key A in the global state of the current application", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 104, + "Name": "app_local_del", + "Args": [ + "any", + "key" + ], + "Size": 1, + "Doc": "delete key B from account A's local state of the current application", + "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), state key.\n\nDeleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.)", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 105, + "Name": "app_global_del", + "Args": [ + "key" + ], + "Size": 1, + "Doc": "delete key A from the global state of the current application", + "DocExtra": "params: state key.\n\nDeleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.)", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 112, + "Name": "asset_holding_get", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": "asset_holding", + "Doc": "X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0", + "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ address), asset id (or, since v4, a Txn.ForeignAssets offset). Return: did_exist flag (1 if the asset existed and 0 otherwise), value.", + "ImmediateDetails": [ + { + "Comment": "asset holding field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_holding" + } + ], + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 113, + "Name": "asset_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": "asset_params", + "Doc": "X is field F from asset A. Y is 1 if A exists, else 0", + "DocExtra": "params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value.", + "ImmediateDetails": [ + { + "Comment": "asset params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_params" + } + ], + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 114, + "Name": "app_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": "app_params", + "Doc": "X is field F from app A. Y is 1 if A exists, else 0", + "DocExtra": "params: Txn.ForeignApps offset or an _available_ app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value.", + "ImmediateDetails": [ + { + "Comment": "app params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "app_params" + } + ], + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 115, + "Name": "acct_params_get", + "Args": [ + "any" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": "acct_params", + "Doc": "X is field F from account A. Y is 1 if A owns positive algos, else 0", + "ImmediateDetails": [ + { + "Comment": "account params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "acct_params" + } + ], + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 120, + "Name": "min_balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "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.", + "DocExtra": "params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value.", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 128, + "Name": "pushbytes", + "Returns": [ + "[]byte" + ], + "Size": 0, + "Doc": "immediate BYTES", + "DocExtra": "pushbytes args are not added to the bytecblock during assembly processes", + "ImmediateDetails": [ + { + "Comment": "a byte constant", + "Encoding": "varuint length, bytes", + "Name": "BYTES" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 129, + "Name": "pushint", + "Returns": [ + "uint64" + ], + "Size": 0, + "Doc": "immediate UINT", + "DocExtra": "pushint args are not added to the intcblock during assembly processes", + "ImmediateDetails": [ + { + "Comment": "an int constant", + "Encoding": "varuint", + "Name": "UINT" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 130, + "Name": "pushbytess", + "Size": 0, + "Doc": "push sequences of immediate byte arrays to stack (first byte array being deepest)", + "DocExtra": "pushbytess args are not added to the bytecblock during assembly processes", + "ImmediateDetails": [ + { + "Comment": "a list of byte constants", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 131, + "Name": "pushints", + "Size": 0, + "Doc": "push sequence of immediate uints to stack in the order they appear (first uint being deepest)", + "DocExtra": "pushints args are not added to the intcblock during assembly processes", + "ImmediateDetails": [ + { + "Comment": "a list of int constants", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 132, + "Name": "ed25519verify_bare", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "for (data A, signature B, pubkey C) verify the signature of the data against the pubkey", + "Groups": [ + "Arithmetic" + ], + "Cost": "1900" + }, + { + "Opcode": 136, + "Name": "callsub", + "Size": 3, + "Doc": "branch unconditionally to TARGET, saving the next instruction on the call stack", + "DocExtra": "The call stack is separate from the data stack. Only `callsub`, `retsub`, and `proto` manipulate it.", + "ImmediateDetails": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 137, + "Name": "retsub", + "Size": 1, + "Doc": "pop the top instruction from the call stack and branch to it", + "DocExtra": "If the current frame was prepared by `proto A R`, `retsub` will remove the 'A' arguments from the stack, move the `R` return values down, and pop any stack locations above the relocated return values.", + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 138, + "Name": "proto", + "Size": 3, + "Doc": "Prepare top call frame for a retsub that will assume A args and R return values.", + "DocExtra": "Fails unless the last instruction executed was a `callsub`.", + "ImmediateDetails": [ + { + "Comment": "the number of arguments", + "Encoding": "uint8", + "Name": "A" + }, + { + "Comment": "the number of return values", + "Encoding": "uint8", + "Name": "R" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 139, + "Name": "frame_dig", + "Returns": [ + "any" + ], + "Size": 2, + "Doc": "Nth (signed) value from the frame pointer.", + "ImmediateDetails": [ + { + "Comment": "a frame slot", + "Encoding": "int8", + "Name": "I" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 140, + "Name": "frame_bury", + "Args": [ + "any" + ], + "Size": 2, + "Doc": "replace the Nth (signed) value from the frame pointer in the stack with A", + "ImmediateDetails": [ + { + "Comment": "a frame slot", + "Encoding": "int8", + "Name": "I" + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 141, + "Name": "switch", + "Args": [ + "uint64" + ], + "Size": 0, + "Doc": "branch to the Ath label. Continue at following instruction if index A exceeds the number of labels.", + "ImmediateDetails": [ + { + "Comment": "a list of labels", + "Encoding": "varuint count, [int16 (big-endian) ...]", + "Name": "TARGET ..." + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 142, + "Name": "match", + "Size": 0, + "Doc": "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.", + "DocExtra": "`match` consumes N+1 values from the stack. Let the top stack value be B. The following N values represent an ordered list of match cases/constants (A), where the first value (A[0]) is the deepest in the stack. The immediate arguments are an ordered list of N labels (T). `match` will branch to target T[I], where A[I] = B. If there are no matches then execution continues on to the next instruction.", + "ImmediateDetails": [ + { + "Comment": "a list of labels", + "Encoding": "varuint count, [int16 (big-endian) ...]", + "Name": "TARGET ..." + } + ], + "Groups": [ + "Flow Control" + ], + "Cost": "1" + }, + { + "Opcode": 144, + "Name": "shl", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A times 2^B, modulo 2^64", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 145, + "Name": "shr", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A divided by 2^B", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 146, + "Name": "sqrt", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "The largest integer I such that I^2 <= A", + "Groups": [ + "Arithmetic" + ], + "Cost": "4" + }, + { + "Opcode": 147, + "Name": "bitlen", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "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", + "DocExtra": "bitlen interprets arrays as big-endian integers, unlike setbit/getbit", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 148, + "Name": "exp", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A raised to the Bth power. Fail if A == B == 0 and on overflow", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 149, + "Name": "expw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "Doc": "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", + "Groups": [ + "Arithmetic" + ], + "Cost": "10" + }, + { + "Opcode": 150, + "Name": "bsqrt", + "Args": [ + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "Doc": "The largest integer I such that I^2 <= A. A and I are interpreted as big-endian unsigned integers", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "40" + }, + { + "Opcode": 151, + "Name": "divw", + "Args": [ + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "Doc": "A,B / C. Fail if C == 0 or if result overflows.", + "DocExtra": "The notation A,B indicates that A and B are interpreted as a uint128 value, with A as the high uint64 and B the low.", + "Groups": [ + "Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 152, + "Name": "sha3_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "hash" + ], + "Size": 1, + "Doc": "SHA3_256 hash of value A", + "Groups": [ + "Arithmetic" + ], + "Cost": "130" + }, + { + "Opcode": 160, + "Name": "b+", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "Doc": "A plus B. A and B are interpreted as big-endian unsigned integers", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "10" + }, + { + "Opcode": 161, + "Name": "b-", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "Doc": "A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "10" + }, + { + "Opcode": 162, + "Name": "b/", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "Doc": "A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "20" + }, + { + "Opcode": 163, + "Name": "b*", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "Doc": "A times B. A and B are interpreted as big-endian unsigned integers.", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "20" + }, + { + "Opcode": 164, + "Name": "b<", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 165, + "Name": "b>", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 166, + "Name": "b<=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 167, + "Name": "b>=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 168, + "Name": "b==", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 169, + "Name": "b!=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "1" + }, + { + "Opcode": 170, + "Name": "b%", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "Doc": "A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "Groups": [ + "Byte Array Arithmetic" + ], + "Cost": "20" + }, + { + "Opcode": 171, + "Name": "b|", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "Doc": "A bitwise-or B. A and B are zero-left extended to the greater of their lengths", + "Groups": [ + "Byte Array Logic" + ], + "Cost": "6" + }, + { + "Opcode": 172, + "Name": "b&", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "Doc": "A bitwise-and B. A and B are zero-left extended to the greater of their lengths", + "Groups": [ + "Byte Array Logic" + ], + "Cost": "6" + }, + { + "Opcode": 173, + "Name": "b^", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "Doc": "A bitwise-xor B. A and B are zero-left extended to the greater of their lengths", + "Groups": [ + "Byte Array Logic" + ], + "Cost": "6" + }, + { + "Opcode": 174, + "Name": "b~", + "Args": [ + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "Doc": "A with all bits inverted", + "Groups": [ + "Byte Array Logic" + ], + "Cost": "4" + }, + { + "Opcode": 175, + "Name": "bzero", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "zero filled byte-array of length A", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 176, + "Name": "log", + "Args": [ + "[]byte" + ], + "Size": 1, + "Doc": "write A to log state of the current application", + "DocExtra": "`log` fails if called more than MaxLogCalls times in a program, or if the sum of logged bytes exceeds 1024 bytes.", + "Groups": [ + "State Access" + ], + "Cost": "1" + }, + { + "Opcode": 177, + "Name": "itxn_begin", + "Size": 1, + "Doc": "begin preparation of a new inner transaction in a new transaction group", + "DocExtra": "`itxn_begin` initializes Sender to the application address; Fee to the minimum allowable, taking into account MinTxnFee and credit from overpaying in earlier transactions; FirstValid/LastValid to the values in the invoking transaction, and all other fields to zero or empty values.", + "Groups": [ + "Inner Transactions" + ], + "Cost": "1" + }, + { + "Opcode": 178, + "Name": "itxn_field", + "Args": [ + "any" + ], + "Size": 2, + "ArgEnum": "itxn_field", + "Doc": "set field F of the current inner transaction to A", + "DocExtra": "`itxn_field` fails if A is of the wrong type for F, including a byte array of the wrong size for use as an address when F is an address field. `itxn_field` also fails if A is an account, asset, or app that is not _available_, or an attempt is made extend an array field beyond the limit imposed by consensus parameters. (Addresses set into asset params of acfg transactions need not be _available_.)", + "ImmediateDetails": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "itxn_field" + } + ], + "Groups": [ + "Inner Transactions" + ], + "Cost": "1" + }, + { + "Opcode": 179, + "Name": "itxn_submit", + "Size": 1, + "Doc": "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.", + "DocExtra": "`itxn_submit` resets the current transaction so that it can not be resubmitted. A new `itxn_begin` is required to prepare another inner transaction.", + "Groups": [ + "Inner Transactions" + ], + "Cost": "1" + }, + { + "Opcode": 180, + "Name": "itxn", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": "txn", + "Doc": "field F of the last inner transaction", + "ImmediateDetails": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "Groups": [ + "Inner Transactions" + ], + "Cost": "1" + }, + { + "Opcode": 181, + "Name": "itxna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": "txna", + "Doc": "Ith value of the array field F of the last inner transaction", + "ImmediateDetails": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "a transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Inner Transactions" + ], + "Cost": "1" + }, + { + "Opcode": 182, + "Name": "itxn_next", + "Size": 1, + "Doc": "begin preparation of a new inner transaction in the same transaction group", + "DocExtra": "`itxn_next` initializes the transaction exactly as `itxn_begin` does", + "Groups": [ + "Inner Transactions" + ], + "Cost": "1" + }, + { + "Opcode": 183, + "Name": "gitxn", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": "txn", + "Doc": "field F of the Tth transaction in the last inner group submitted", + "ImmediateDetails": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "Groups": [ + "Inner Transactions" + ], + "Cost": "1" + }, + { + "Opcode": 184, + "Name": "gitxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": "txna", + "Doc": "Ith value of the array field F from the Tth transaction in the last inner group submitted", + "ImmediateDetails": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "Groups": [ + "Inner Transactions" + ], + "Cost": "1" + }, + { + "Opcode": 185, + "Name": "box_create", + "Args": [ + "key", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "create a box named A, of length B. Fail if A is empty or B exceeds 32,768. Returns 0 if A already existed, else 1", + "DocExtra": "Newly created boxes are filled with 0 bytes. `box_create` will fail if the referenced box already exists with a different size. Otherwise, existing boxes are unchanged by `box_create`.", + "Groups": [ + "Box Access" + ], + "Cost": "1" + }, + { + "Opcode": 186, + "Name": "box_extract", + "Args": [ + "key", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "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.", + "Groups": [ + "Box Access" + ], + "Cost": "1" + }, + { + "Opcode": 187, + "Name": "box_replace", + "Args": [ + "key", + "uint64", + "[]byte" + ], + "Size": 1, + "Doc": "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.", + "Groups": [ + "Box Access" + ], + "Cost": "1" + }, + { + "Opcode": 188, + "Name": "box_del", + "Args": [ + "key" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "Doc": "delete box named A if it exists. Return 1 if A existed, 0 otherwise", + "Groups": [ + "Box Access" + ], + "Cost": "1" + }, + { + "Opcode": 189, + "Name": "box_len", + "Args": [ + "key" + ], + "Returns": [ + "uint64", + "bool" + ], + "Size": 1, + "Doc": "X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0.", + "Groups": [ + "Box Access" + ], + "Cost": "1" + }, + { + "Opcode": 190, + "Name": "box_get", + "Args": [ + "key" + ], + "Returns": [ + "[]byte", + "bool" + ], + "Size": 1, + "Doc": "X is the contents of box A if A exists, else ''. Y is 1 if A exists, else 0.", + "DocExtra": "For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `box_replace`", + "Groups": [ + "Box Access" + ], + "Cost": "1" + }, + { + "Opcode": 191, + "Name": "box_put", + "Args": [ + "key", + "[]byte" + ], + "Size": 1, + "Doc": "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", + "DocExtra": "For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `box_replace`", + "Groups": [ + "Box Access" + ], + "Cost": "1" + }, + { + "Opcode": 192, + "Name": "txnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": "txna", + "Doc": "Ath value of the array field F of the current transaction", + "ImmediateDetails": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 193, + "Name": "gtxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": "txna", + "Doc": "Ath value of the array field F from the Tth transaction in the current group", + "ImmediateDetails": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 194, + "Name": "gtxnsas", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": "txna", + "Doc": "Bth value of the array field F from the Ath transaction in the current group", + "ImmediateDetails": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 195, + "Name": "args", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "Doc": "Ath LogicSig argument", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 196, + "Name": "gloadss", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "Doc": "Bth scratch space value of the Ath transaction in the current group", + "Groups": [ + "Loading Values" + ], + "Cost": "1" + }, + { + "Opcode": 197, + "Name": "itxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": "txna", + "Doc": "Ath value of the array field F of the last inner transaction", + "ImmediateDetails": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "Groups": [ + "Inner Transactions" + ], + "Cost": "1" + }, + { + "Opcode": 198, + "Name": "gitxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": "txna", + "Doc": "Ath value of the array field F from the Tth transaction in the last inner group submitted", + "ImmediateDetails": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "Groups": [ + "Inner Transactions" + ], + "Cost": "1" + }, + { + "Opcode": 208, + "Name": "vrf_verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte", + "bool" + ], + "Size": 2, + "ArgEnum": "vrf_verify", + "Doc": "Verify the proof B of message A against pubkey C. Returns vrf output and verification flag.", + "DocExtra": "`VrfAlgorand` is the VRF used in Algorand. It is ECVRF-ED25519-SHA512-Elligator2, specified in the IETF internet draft [draft-irtf-cfrg-vrf-03](https://datatracker.ietf.org/doc/draft-irtf-cfrg-vrf/03/).", + "ImmediateDetails": [ + { + "Comment": "the parameters index", + "Encoding": "uint8", + "Name": "S", + "Reference": "vrf_verify" + } + ], + "Groups": [ + "Arithmetic" + ], + "Cost": "5700" + }, + { + "Opcode": 209, + "Name": "block", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": "block", + "Doc": "field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)", + "ImmediateDetails": [ + { + "Comment": "the block field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "block" + } + ], + "Groups": [ + "State Access" + ], + "Cost": "1" + } + ] +} diff --git a/tealish/langspec.py b/tealish/langspec.py index fd15047..9cd3303 100644 --- a/tealish/langspec.py +++ b/tealish/langspec.py @@ -4,7 +4,7 @@ import tealish import json from .tealish_builtins import constants, AVMType -from typing import List, Dict, Any, Tuple, Optional +from typing import List, Dict, Any, Tuple, Optional, cast abc = "ABCDEFGHIJK" @@ -23,10 +23,13 @@ _opcode_type_map = { - ".": AVMType.any, - "B": AVMType.bytes, - "U": AVMType.int, - "": AVMType.none, + "any": AVMType.any, + "[]byte": AVMType.bytes, + "uint64": AVMType.int, + "none": AVMType.none, + "addr": AVMType.bytes, + "hash": AVMType.bytes, + "bool": AVMType.int, } operators = [ @@ -87,8 +90,91 @@ def type_lookup(a: str) -> AVMType: return _opcode_type_map[a] -def convert_args_to_types(args: str) -> List[AVMType]: - return [type_lookup(args[idx]) for idx in range(len(args))] +def convert_args_to_types( + args: List[str], stack_types: Dict[str, "StackType"] +) -> List[AVMType]: + arg_types: List[AVMType] = [] + for arg in args: + if arg in _opcode_type_map: + arg_types.append(_opcode_type_map[arg]) + elif arg in stack_types: + arg_types.append(stack_types[arg].type) + return arg_types + + +class StackType: + """ + StackType represents a named and possibly value or length bound datatype + """ + + #: the avm base type ([]byte, uint64, any, none) + type: AVMType + #: if set, defines the min/max length of this type + length_bound: Optional[Tuple[int, int]] + #: if set, defines the min/max value of this type + value_bound: Optional[Tuple[int, int]] + + def __init__(self, details: Dict[str, Any]): + self.type = type_lookup(details["Type"]) + self.length_bound = details.get("LengthBound", None) + self.value_bound = details.get("ValueBound", None) + + +class FieldGroupValue: + """ + FieldGroupValue represents a single element of a FieldGroup which describes + the possible values for immediate arguments + """ + + #: the human readable name for this field group value + name: str + #: the stack type returned by this field group value + type: str + #: a documentation string describing this field group value + note: str + #: the integer value to use when encoding this field group value + value: int + + def __init__(self, v: Dict[str, Any]): + self.name = v["Name"] + self.type = v["Type"] + self.note = v.get("Note", "") + self.value = v["Value"] + + +class FieldGroup: + """ + FieldGroup represents the full set of FieldEnumValues for a given Field + """ + + #: dict of name to type this FieldGroup contains + values: Dict[str, AVMType] + + def __init__(self, vals: List[Dict[str, Any]]): + initialized_vals = [FieldGroupValue(val) for val in vals] + self.values = {v.name: type_lookup(v.type) for v in initialized_vals} + + +class ImmediateDetails: + """ + ImmediateDetails represents the details for the immediate arguments to + a given Op + """ + + #: Some extra text descriptive information + comment: str + #: The encoding to use in bytecode for this argument type + encoding: str + #: The name of the argument given by the op spec + name: str + #: If set, refers to the FieldGroup this immediate belongs to + reference: str + + def __init__(self, details: Dict[str, Any]): + self.comment = details["Comment"] + self.encoding = details["Encoding"] + self.name = details["Name"] + self.reference: str = details.get("Reference", "") class Op: @@ -99,23 +185,17 @@ class Op: #: identifier used when writing into the TEAL source program name: str #: list of arg types this op takes off the stack, encoded as a string - args: str + args: List[str] #: decoded list of incoming args arg_types: List[AVMType] #: list of arg types this op puts on the stack, encoded as a string - returns: str + returns: List[str] #: decoded list of outgoing args returns_types: List[AVMType] #: how many bytes this opcode takes up when assembled size: int #: describes the args to be passed as immediate arguments to this op - immediate_note: str - #: describes the list of names that can be used as immediate arguments - arg_enum: List[str] - #: describes the types returned when each arg enum is used - arg_enum_types: List[AVMType] - #: dictionary mapping the names in arg_enum to types in arg_enum_types - arg_enum_dict: Dict[str, AVMType] + immediate_args: List[ImmediateDetails] #: informational string about the op doc: str @@ -129,56 +209,49 @@ class Op: is_operator: bool - def __init__(self, op_def: Dict[str, Any]): - self.opcode = op_def["Opcode"] + def __init__(self, op_def: Dict[str, Any], stack_types: Dict[str, StackType]): + self.opcode = op_def.get("Opcode", 0) self.name = op_def["Name"] self.size = op_def["Size"] self.immediate_args_num = self.size - 1 self.is_operator = self.name in operators + self.immediate_args = [] + if "ImmediateDetails" in op_def: + self.immediate_args = [ + ImmediateDetails(id) for id in op_def["ImmediateDetails"] + ] + + self.args = [] + self.arg_types = [] if "Args" in op_def: - self.args = op_def["Args"] - self.arg_types = convert_args_to_types(self.args) - else: - self.args = "" - self.arg_types = [] + self.args: List[str] = op_def["Args"] + self.arg_types: List[AVMType] = convert_args_to_types( + self.args, stack_types + ) + self.returns = [] + self.returns_types = [] if "Returns" in op_def: self.returns = op_def["Returns"] - self.returns_types = convert_args_to_types(self.returns) - else: - self.returns = "" - self.returns_types = [] - - if "ImmediateNote" in op_def: - self.immediate_note = op_def["ImmediateNote"] - else: - self.immediate_note = "" - - if "ArgEnum" in op_def: - self.arg_enum = op_def["ArgEnum"] - if "ArgEnumTypes" in op_def: - self.arg_enum_types = convert_args_to_types(op_def["ArgEnumTypes"]) - else: - self.arg_enum_types = [AVMType.int] * len(self.arg_enum) - self.arg_enum_dict = dict(zip(self.arg_enum, self.arg_enum_types)) - else: - self.arg_enum = [] - self.arg_enum_types = [] - self.arg_enum_dict = {} + self.returns_types = convert_args_to_types(self.returns, stack_types) self.doc = op_def.get("Doc", "") self.doc_extra = op_def.get("DocExtra", "") - self.groups = op_def.get("groups", []) + self.groups = op_def.get("Groups", []) - arg_list = [f"{abc[i]}: {t.name}" for i, t in enumerate(self.arg_types)] - if len(self.arg_enum) > 0: - arg_list = ["F: field"] + arg_list - elif self.immediate_args_num > 0: - arg_list = (["i: int"] * self.immediate_args_num) + arg_list + arg_list = [f"{abc[i]}: {t}" for i, t in enumerate(self.arg_types)] + if len(self.immediate_args) > 0: + arg_list = [ + f"{imm.name}: {imm.encoding}" for imm in self.immediate_args + ] + arg_list arg_string = ", ".join(arg_list) + self.sig = f"{self.name}({arg_string})" + if len(self.returns_types) > 0: + self.sig += " " + ", ".join(self.returns_types) + if self.is_operator: if len(self.args) == 2: self.sig = f"A {self.name} B" @@ -200,17 +273,29 @@ class LangSpec: def __init__(self, spec: Dict[str, Any]) -> None: self.is_packaged = False self.spec = spec + self.stack_types: Dict[str, StackType] = { + name: StackType(st) + for name, st in cast(Dict[str, Any], spec["StackTypes"]).items() + } + + self.pseudo_ops: Dict[str, Op] = { + op["Name"]: Op(op, self.stack_types) for op in spec["PseudoOps"] + } + self.ops: Dict[str, Op] = { - op["Name"]: Op(op) for op in (spec["Ops"] + pseudo_ops) + op["Name"]: Op(op, self.stack_types) for op in spec["Ops"] } + self.ops.update(self.pseudo_ops) - self.fields: Dict[str, Any] = { - "Global": self.ops["global"].arg_enum_dict, - "Txn": self.ops["txn"].arg_enum_dict, + self.fields: Dict[str, FieldGroup] = { + name: FieldGroup(value) + for name, value in cast(Dict[str, Any], spec["Fields"]).items() } - self.global_fields = self.fields["Global"] - self.txn_fields = self.fields["Txn"] + self.global_fields = self.fields["global"].values + + self.txn_fields = self.fields["txn"].values + self.txn_fields.update(self.fields["txna"].values) def as_dict(self) -> Dict[str, Any]: return self.spec @@ -224,6 +309,9 @@ def lookup_op(self, name: str) -> Op: raise KeyError(f'Op "{name}" does not exist!') return self.ops[name] + def lookup_type(self, type: str) -> AVMType: + return self.stack_types[type].type + def lookup_avm_constant(self, name: str) -> Tuple[AVMType, Any]: if name not in constants: raise KeyError(f'Constant "{name}" does not exist!') diff --git a/tests/langspec_test.py b/tests/langspec_test.py new file mode 100644 index 0000000..58174f9 --- /dev/null +++ b/tests/langspec_test.py @@ -0,0 +1,7 @@ +from tealish import langspec + + +def test_langspec(): + ls = langspec.packaged_lang_spec + for op_name, op_spec in ls.ops.items(): + print(op_spec.sig)