diff --git a/.gitignore b/.gitignore index 8deb3a2d9f..b0f211512a 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ crypto/libs # doc intermediates data/transactions/logic/*.md +!data/transactions/logic/TEAL_opcodes*.md *.pem diff --git a/cmd/opdoc/opdoc.go b/cmd/opdoc/opdoc.go index 733d7420fc..58d32705b2 100644 --- a/cmd/opdoc/opdoc.go +++ b/cmd/opdoc/opdoc.go @@ -20,6 +20,7 @@ import ( "encoding/json" "fmt" "io" + "math" "os" "sort" "strings" @@ -29,8 +30,6 @@ import ( "github.com/algorand/go-algorand/protocol" ) -var docVersion = 10 - // OpImmediateNote returns a short string about immediate data which follows the op byte func opImmediateNoteSyntaxMarkdown(name string, oids []logic.OpImmediateDetails) string { if len(oids) == 0 { @@ -63,11 +62,11 @@ func opImmediateNoteEncoding(opcode byte, oids []logic.OpImmediateDetails) strin return fmt.Sprintf("0x%02x {%s}", opcode, strings.Join(notes, "}, {")) } -func opGroupMarkdownTable(names []string, out io.Writer) { +func opGroupMarkdownTable(names []string, out io.Writer, version uint64) { fmt.Fprint(out, `| Opcode | Description | | - | -- | `) - opSpecs := logic.OpsByName[docVersion] + opSpecs := logic.OpsByName[version] for _, opname := range names { spec, ok := opSpecs[opname] if !ok { @@ -113,20 +112,20 @@ func integerConstantsTableMarkdown(out io.Writer) { out.Write([]byte("\n")) } -func fieldGroupMarkdown(out io.Writer, group *logic.FieldGroup) { +func fieldGroupMarkdown(out io.Writer, group *logic.FieldGroup, version uint64) { showTypes := false showVers := false - opVer := uint64(0) + opVer := uint64(math.MaxUint64) for _, name := range group.Names { spec, ok := group.SpecByName(name) // reminder: group.Names can be "sparse" See: logic.TxnaFields - if !ok { + if !ok || spec.Version() > version { continue } if spec.Type().Typed() { showTypes = true } - if opVer == uint64(0) { + if opVer == math.MaxUint64 { opVer = spec.Version() } else if opVer != spec.Version() { showVers = true @@ -147,7 +146,7 @@ func fieldGroupMarkdown(out io.Writer, group *logic.FieldGroup) { fmt.Fprint(out, headers, widths) for i, name := range group.Names { spec, ok := group.SpecByName(name) - if !ok { + if !ok || spec.Version() > version { continue } str := fmt.Sprintf("| %d | %s", i, markdownTableEscape(name)) @@ -212,7 +211,7 @@ func stackMarkdown(op *logic.OpSpec) string { return out + "\n" } -func opToMarkdown(out io.Writer, op *logic.OpSpec, groupDocWritten map[string]bool) (err error) { +func opToMarkdown(out io.Writer, op *logic.OpSpec, groupDocWritten map[string]bool, version uint64) (err error) { deets := logic.OpImmediateDetailsFromSpec(*op) @@ -230,26 +229,9 @@ func opToMarkdown(out io.Writer, op *logic.OpSpec, groupDocWritten map[string]bo fmt.Fprintf(out, "\n## %s\n\n%s%s\n%s", op.Name, syntax, encoding, stackEffects) fmt.Fprintf(out, "- %s\n", logic.OpDoc(op.Name)) - // if cost changed with versions print all of them - costs := logic.OpAllCosts(op.Name) - if len(costs) > 1 { - fmt.Fprintf(out, "- **Cost**:\n") - for _, cost := range costs { - if cost.From == cost.To { - fmt.Fprintf(out, " - %s (v%d)\n", cost.Cost, cost.To) - } else { - if cost.To < docVersion { - fmt.Fprintf(out, " - %s (v%d - v%d)\n", cost.Cost, cost.From, cost.To) - } else { - fmt.Fprintf(out, " - %s (since v%d)\n", cost.Cost, cost.From) - } - } - } - } else { - cost := costs[0].Cost - if cost != "1" { - fmt.Fprintf(out, "- **Cost**: %s\n", cost) - } + cost := op.DocCost(version) + if cost != "1" { + fmt.Fprintf(out, "- **Cost**: %s\n", cost) } if op.Version > 1 { fmt.Fprintf(out, "- Availability: v%d\n", op.Version) @@ -262,7 +244,7 @@ func opToMarkdown(out io.Writer, op *logic.OpSpec, groupDocWritten map[string]bo group := op.OpDetails.Immediates[i].Group if group != nil && group.Doc != "" && !groupDocWritten[group.Name] { fmt.Fprintf(out, "\n### %s\n\n%s\n\n", group.Name, group.Doc) - fieldGroupMarkdown(out, group) + fieldGroupMarkdown(out, group, version) groupDocWritten[group.Name] = true } } @@ -273,17 +255,20 @@ func opToMarkdown(out io.Writer, op *logic.OpSpec, groupDocWritten map[string]bo return nil } -func opsToMarkdown(out io.Writer) (err error) { - out.Write([]byte("# Opcodes\n\nOps have a 'cost' of 1 unless otherwise specified.\n\n")) - opSpecs := logic.OpcodesByVersion(uint64(docVersion)) +func opsToMarkdown(out io.Writer, version uint64) error { + _, err := out.Write([]byte(fmt.Sprintf("# v%d Opcodes\n\nOps have a 'cost' of 1 unless otherwise specified.\n\n", version))) + if err != nil { + return err + } + opSpecs := logic.OpcodesByVersion(version) written := make(map[string]bool) for i := range opSpecs { - err = opToMarkdown(out, &opSpecs[i], written) + err := opToMarkdown(out, &opSpecs[i], written, version) if err != nil { - return + return err } } - return + return nil } // OpRecord is a consolidated record of things about an Op @@ -297,6 +282,8 @@ type OpRecord struct { ArgEnum []string `json:",omitempty"` ArgEnumTypes []string `json:",omitempty"` + DocCost string + Doc string DocExtra string `json:",omitempty"` ImmediateNote []logic.OpImmediateDetails `json:",omitempty"` @@ -342,7 +329,7 @@ func (nt namedType) boundString() string { // LanguageSpec records the ops of the language at some version type LanguageSpec struct { - EvalMaxVersion int + Version uint64 LogicSigVersion uint64 NamedTypes []namedType Ops []OpRecord @@ -369,12 +356,12 @@ func typeStrings(types logic.StackTypes) []string { return out } -func fieldsAndTypes(group logic.FieldGroup) ([]string, []string) { +func fieldsAndTypes(group logic.FieldGroup, version uint64) ([]string, []string) { // reminder: group.Names can be "sparse" See: logic.TxnaFields fields := make([]string, 0, len(group.Names)) types := make([]logic.StackType, 0, len(group.Names)) for _, name := range group.Names { - if spec, ok := group.SpecByName(name); ok { + if spec, ok := group.SpecByName(name); ok && spec.Version() <= version { fields = append(fields, name) types = append(types, spec.Type()) } @@ -382,46 +369,46 @@ func fieldsAndTypes(group logic.FieldGroup) ([]string, []string) { return fields, typeStrings(types) } -func argEnums(name string) ([]string, []string) { +func argEnums(name string, version uint64) ([]string, []string) { // reminder: this needs to be manually updated every time // a new opcode is added with an associated FieldGroup // it'd be nice to have this auto-update switch name { case "txn", "gtxn", "gtxns", "itxn", "gitxn": - return fieldsAndTypes(logic.TxnFields) + return fieldsAndTypes(logic.TxnFields, version) case "itxn_field": // itxn_field does not *return* a type depending on its immediate. It *takes* it. // but until a consumer cares, ArgEnumTypes will be overloaded for that meaning. - return fieldsAndTypes(logic.ItxnSettableFields) + return fieldsAndTypes(logic.ItxnSettableFields, version) case "global": - return fieldsAndTypes(logic.GlobalFields) + return fieldsAndTypes(logic.GlobalFields, version) case "txna", "gtxna", "gtxnsa", "txnas", "gtxnas", "gtxnsas", "itxna", "gitxna": - return fieldsAndTypes(logic.TxnArrayFields) + return fieldsAndTypes(logic.TxnArrayFields, version) case "asset_holding_get": - return fieldsAndTypes(logic.AssetHoldingFields) + return fieldsAndTypes(logic.AssetHoldingFields, version) case "asset_params_get": - return fieldsAndTypes(logic.AssetParamsFields) + return fieldsAndTypes(logic.AssetParamsFields, version) case "app_params_get": - return fieldsAndTypes(logic.AppParamsFields) + return fieldsAndTypes(logic.AppParamsFields, version) case "acct_params_get": - return fieldsAndTypes(logic.AcctParamsFields) + return fieldsAndTypes(logic.AcctParamsFields, version) case "block": - return fieldsAndTypes(logic.BlockFields) + return fieldsAndTypes(logic.BlockFields, version) case "json_ref": - return fieldsAndTypes(logic.JSONRefTypes) + return fieldsAndTypes(logic.JSONRefTypes, version) case "base64_decode": - return fieldsAndTypes(logic.Base64Encodings) + return fieldsAndTypes(logic.Base64Encodings, version) case "vrf_verify": - return fieldsAndTypes(logic.VrfStandards) + return fieldsAndTypes(logic.VrfStandards, version) case "ecdsa_pk_recover", "ecdsa_verify", "ecdsa_pk_decompress": - return fieldsAndTypes(logic.EcdsaCurves) + return fieldsAndTypes(logic.EcdsaCurves, version) default: return nil, nil } } -func buildLanguageSpec(opGroups map[string][]string, namedTypes []namedType) *LanguageSpec { - opSpecs := logic.OpcodesByVersion(uint64(docVersion)) +func buildLanguageSpec(opGroups map[string][]string, namedTypes []namedType, version uint64) *LanguageSpec { + opSpecs := logic.OpcodesByVersion(version) records := make([]OpRecord, len(opSpecs)) for i, spec := range opSpecs { records[i].Opcode = spec.Opcode @@ -429,7 +416,8 @@ func buildLanguageSpec(opGroups map[string][]string, namedTypes []namedType) *La records[i].Args = typeStrings(spec.Arg.Types) records[i].Returns = typeStrings(spec.Return.Types) records[i].Size = spec.OpDetails.Size - records[i].ArgEnum, records[i].ArgEnumTypes = argEnums(spec.Name) + records[i].DocCost = spec.DocCost(version) + records[i].ArgEnum, records[i].ArgEnumTypes = argEnums(spec.Name, version) records[i].Doc = strings.ReplaceAll(logic.OpDoc(spec.Name), "
", "\n") records[i].DocExtra = logic.OpDocExtra(spec.Name) records[i].ImmediateNote = logic.OpImmediateDetailsFromSpec(spec) @@ -438,7 +426,7 @@ func buildLanguageSpec(opGroups map[string][]string, namedTypes []namedType) *La } return &LanguageSpec{ - EvalMaxVersion: docVersion, + Version: version, LogicSigVersion: config.Consensus[protocol.ConsensusCurrentVersion].LogicSigVersion, NamedTypes: namedTypes, Ops: records, @@ -448,30 +436,26 @@ func buildLanguageSpec(opGroups map[string][]string, namedTypes []namedType) *La func create(file string) *os.File { f, err := os.Create(file) if err != nil { - fmt.Fprintf(os.Stderr, "Unable to create '%s': %v", file, err) + fmt.Fprintf(os.Stderr, "Unable to create '%s': %v\n", file, err) os.Exit(1) } return f } func main() { - opcodesMd := create("TEAL_opcodes.md") - opsToMarkdown(opcodesMd) - opcodesMd.Close() + const docVersion = uint64(10) + opGroups := make(map[string][]string, len(logic.OpSpecs)) for grp, names := range logic.OpGroups { fname := fmt.Sprintf("%s.md", grp) fname = strings.ReplaceAll(fname, " ", "_") fout := create(fname) - opGroupMarkdownTable(names, fout) + opGroupMarkdownTable(names, fout, docVersion) fout.Close() for _, opname := range names { opGroups[opname] = append(opGroups[opname], grp) } } - constants := create("named_integer_constants.md") - integerConstantsTableMarkdown(constants) - constants.Close() named := make([]namedType, 0, len(logic.AllStackTypes)) for abbr, t := range logic.AllStackTypes { @@ -484,6 +468,10 @@ func main() { } sort.Slice(named, func(i, j int) bool { return named[i].Name > named[j].Name }) + constants := create("named_integer_constants.md") + integerConstantsTableMarkdown(constants) + constants.Close() + namedStackTypes := create("named_stack_types.md") namedStackTypesMarkdown(namedStackTypes, named) namedStackTypes.Close() @@ -494,25 +482,37 @@ func main() { for _, imm := range spec.OpDetails.Immediates { if imm.Group != nil && !written[imm.Group.Name] { out := create(strings.ToLower(imm.Group.Name) + "_fields.md") - fieldGroupMarkdown(out, imm.Group) + fieldGroupMarkdown(out, imm.Group, docVersion) out.Close() written[imm.Group.Name] = true } } } - langspecjs := create("langspec.json") - enc := json.NewEncoder(langspecjs) - enc.SetIndent("", " ") - err := enc.Encode(buildLanguageSpec(opGroups, named)) - if err != nil { - panic(err.Error()) - } - langspecjs.Close() - tealtm := create("teal.tmLanguage.json") - enc = json.NewEncoder(tealtm) + enc := json.NewEncoder(tealtm) enc.SetIndent("", " ") - enc.Encode(buildSyntaxHighlight()) + if err := enc.Encode(buildSyntaxHighlight(docVersion)); err != nil { + fmt.Fprintf(os.Stderr, "error encoding teal.tmLanguage.json: % v\n", err) + os.Exit(1) + } tealtm.Close() + + for v := uint64(1); v <= docVersion; v++ { + langspecjs := create(fmt.Sprintf("langspec_v%d.json", v)) + enc := json.NewEncoder(langspecjs) + enc.SetIndent("", " ") + if err := enc.Encode(buildLanguageSpec(opGroups, named, v)); err != nil { + fmt.Fprintf(os.Stderr, "error encoding langspec JSON for version %d: %v\n", v, err) + os.Exit(1) + } + langspecjs.Close() + + opcodesMd := create(fmt.Sprintf("TEAL_opcodes_v%d.md", v)) + if err := opsToMarkdown(opcodesMd, v); err != nil { + fmt.Fprintf(os.Stderr, "error creating markdown for version %d: %v\n", v, err) + os.Exit(1) + } + opcodesMd.Close() + } } diff --git a/cmd/opdoc/tmLanguage.go b/cmd/opdoc/tmLanguage.go index a24c3dfd8f..fb14381016 100644 --- a/cmd/opdoc/tmLanguage.go +++ b/cmd/opdoc/tmLanguage.go @@ -52,7 +52,7 @@ type pattern struct { Patterns []pattern `json:"patterns,omitempty"` } -func buildSyntaxHighlight() *tmLanguage { +func buildSyntaxHighlight(version uint64) *tmLanguage { tm := tmLanguage{ Schema: "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", Name: "Algorand TEAL", @@ -126,11 +126,17 @@ func buildSyntaxHighlight() *tmLanguage { allNamedFields = append(allNamedFields, logic.TxnTypeNames[:]...) allNamedFields = append(allNamedFields, logic.OnCompletionNames[:]...) accumulated := make(map[string]bool) - opSpecs := logic.OpcodesByVersion(uint64(docVersion)) + opSpecs := logic.OpcodesByVersion(version) for _, spec := range opSpecs { for _, imm := range spec.OpDetails.Immediates { if imm.Group != nil && !accumulated[imm.Group.Name] { - allNamedFields = append(allNamedFields, imm.Group.Names...) + for _, name := range imm.Group.Names { + spec, ok := imm.Group.SpecByName(name) + if !ok || spec.Version() > version { + continue + } + allNamedFields = append(allNamedFields, name) + } accumulated[imm.Group.Name] = true } } diff --git a/data/transactions/logic/TEAL_opcodes_v1.md b/data/transactions/logic/TEAL_opcodes_v1.md new file mode 100644 index 0000000000..f9ef580cfc --- /dev/null +++ b/data/transactions/logic/TEAL_opcodes_v1.md @@ -0,0 +1,401 @@ +# v1 Opcodes + +Ops have a 'cost' of 1 unless otherwise specified. + + +## err + +- Bytecode: 0x00 +- Stack: ... → _exits_ +- Fail immediately. + +## sha256 + +- Bytecode: 0x01 +- Stack: ..., A: []byte → ..., [32]byte +- SHA256 hash of value A, yields [32]byte +- **Cost**: 7 + +## keccak256 + +- Bytecode: 0x02 +- Stack: ..., A: []byte → ..., [32]byte +- Keccak256 hash of value A, yields [32]byte +- **Cost**: 26 + +## sha512_256 + +- Bytecode: 0x03 +- Stack: ..., A: []byte → ..., [32]byte +- SHA512_256 hash of value A, yields [32]byte +- **Cost**: 9 + +## ed25519verify + +- Bytecode: 0x04 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1} +- **Cost**: 1900 +- Mode: Signature + +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. + +## + + +- Bytecode: 0x08 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A plus B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`. + +## - + +- Bytecode: 0x09 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A minus B. Fail if B > A. + +## / + +- Bytecode: 0x0a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by B (truncated division). Fail if B == 0. + +`divmodw` is available to divide the two-element values produced by `mulw` and `addw`. + +## * + +- Bytecode: 0x0b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`. + +## < + +- Bytecode: 0x0c +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than B => {0 or 1} + +## > + +- Bytecode: 0x0d +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than B => {0 or 1} + +## <= + +- Bytecode: 0x0e +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than or equal to B => {0 or 1} + +## >= + +- Bytecode: 0x0f +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than or equal to B => {0 or 1} + +## && + +- Bytecode: 0x10 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero and B is not zero => {0 or 1} + +## || + +- Bytecode: 0x11 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero or B is not zero => {0 or 1} + +## == + +- Bytecode: 0x12 +- Stack: ..., A, B → ..., bool +- A is equal to B => {0 or 1} + +## != + +- Bytecode: 0x13 +- Stack: ..., A, B → ..., bool +- A is not equal to B => {0 or 1} + +## ! + +- Bytecode: 0x14 +- Stack: ..., A: uint64 → ..., uint64 +- A == 0 yields 1; else 0 + +## len + +- Bytecode: 0x15 +- Stack: ..., A: []byte → ..., uint64 +- yields length of byte value A + +## itob + +- Bytecode: 0x16 +- Stack: ..., A: uint64 → ..., []byte +- converts uint64 A to big-endian byte array, always of length 8 + +## btoi + +- Bytecode: 0x17 +- Stack: ..., A: []byte → ..., uint64 +- converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8. + +`btoi` fails if the input is longer than 8 bytes. + +## % + +- Bytecode: 0x18 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A modulo B. Fail if B == 0. + +## | + +- Bytecode: 0x19 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-or B + +## & + +- Bytecode: 0x1a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-and B + +## ^ + +- Bytecode: 0x1b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-xor B + +## ~ + +- Bytecode: 0x1c +- Stack: ..., A: uint64 → ..., uint64 +- bitwise invert value A + +## mulw + +- Bytecode: 0x1d +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low + +## intcblock + +- Syntax: `intcblock UINT ...` ∋ UINT ...: a block of int constant values +- Bytecode: 0x20 {varuint count, [varuint ...]} +- Stack: ... → ... +- prepare block of uint64 constants for use by intc + +`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. + +## intc + +- Syntax: `intc I` ∋ I: an index in the intcblock +- Bytecode: 0x21 {uint8} +- Stack: ... → ..., uint64 +- Ith constant from intcblock + +## intc_0 + +- Bytecode: 0x22 +- Stack: ... → ..., uint64 +- constant 0 from intcblock + +## intc_1 + +- Bytecode: 0x23 +- Stack: ... → ..., uint64 +- constant 1 from intcblock + +## intc_2 + +- Bytecode: 0x24 +- Stack: ... → ..., uint64 +- constant 2 from intcblock + +## intc_3 + +- Bytecode: 0x25 +- Stack: ... → ..., uint64 +- constant 3 from intcblock + +## bytecblock + +- Syntax: `bytecblock BYTES ...` ∋ BYTES ...: a block of byte constant values +- Bytecode: 0x26 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ... +- prepare block of byte-array constants for use by bytec + +`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. + +## bytec + +- Syntax: `bytec I` ∋ I: an index in the bytecblock +- Bytecode: 0x27 {uint8} +- Stack: ... → ..., []byte +- Ith constant from bytecblock + +## bytec_0 + +- Bytecode: 0x28 +- Stack: ... → ..., []byte +- constant 0 from bytecblock + +## bytec_1 + +- Bytecode: 0x29 +- Stack: ... → ..., []byte +- constant 1 from bytecblock + +## bytec_2 + +- Bytecode: 0x2a +- Stack: ... → ..., []byte +- constant 2 from bytecblock + +## bytec_3 + +- Bytecode: 0x2b +- Stack: ... → ..., []byte +- constant 3 from bytecblock + +## arg + +- Syntax: `arg N` ∋ N: an arg index +- Bytecode: 0x2c {uint8} +- Stack: ... → ..., []byte +- Nth LogicSig argument +- Mode: Signature + +## arg_0 + +- Bytecode: 0x2d +- Stack: ... → ..., []byte +- LogicSig argument 0 +- Mode: Signature + +## arg_1 + +- Bytecode: 0x2e +- Stack: ... → ..., []byte +- LogicSig argument 1 +- Mode: Signature + +## arg_2 + +- Bytecode: 0x2f +- Stack: ... → ..., []byte +- LogicSig argument 2 +- Mode: Signature + +## arg_3 + +- Bytecode: 0x30 +- Stack: ... → ..., []byte +- LogicSig argument 3 +- Mode: Signature + +## txn + +- Syntax: `txn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x31 {uint8} +- Stack: ... → ..., any +- field F of current transaction + +### txn + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | Sender | address | 32 byte address | +| 1 | Fee | uint64 | microalgos | +| 2 | FirstValid | uint64 | round number | +| 4 | LastValid | uint64 | round number | +| 5 | Note | []byte | Any data up to 1024 bytes | +| 6 | Lease | [32]byte | 32 byte lease value | +| 7 | Receiver | address | 32 byte address | +| 8 | Amount | uint64 | microalgos | +| 9 | CloseRemainderTo | address | 32 byte address | +| 10 | VotePK | [32]byte | 32 byte address | +| 11 | SelectionPK | [32]byte | 32 byte address | +| 12 | VoteFirst | uint64 | The first round that the participation key is valid. | +| 13 | VoteLast | uint64 | The last round that the participation key is valid. | +| 14 | VoteKeyDilution | uint64 | Dilution for the 2-level participation key | +| 15 | Type | []byte | Transaction type as bytes | +| 16 | TypeEnum | uint64 | Transaction type as integer | +| 17 | XferAsset | uint64 | Asset ID | +| 18 | AssetAmount | uint64 | value in Asset's units | +| 19 | AssetSender | address | 32 byte address. Source of assets if Sender is the Asset's Clawback address. | +| 20 | AssetReceiver | address | 32 byte address | +| 21 | AssetCloseTo | address | 32 byte address | +| 22 | GroupIndex | uint64 | Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1 | +| 23 | TxID | [32]byte | The computed ID for this transaction. 32 bytes. | + + +## global + +- Syntax: `global F` ∋ F: [global](#field-group-global) +- Bytecode: 0x32 {uint8} +- Stack: ... → ..., any +- global field F + +### global + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | MinTxnFee | uint64 | microalgos | +| 1 | MinBalance | uint64 | microalgos | +| 2 | MaxTxnLife | uint64 | rounds | +| 3 | ZeroAddress | address | 32 byte address of all zero bytes | +| 4 | GroupSize | uint64 | Number of transactions in this atomic transaction group. At least 1 | + + +## gtxn + +- Syntax: `gtxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0x33 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the current group + +for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`. + +## load + +- Syntax: `load I` ∋ I: position in scratch space to load from +- Bytecode: 0x34 {uint8} +- Stack: ... → ..., any +- Ith scratch space value. All scratch spaces are 0 at program start. + +## store + +- Syntax: `store I` ∋ I: position in scratch space to store to +- Bytecode: 0x35 {uint8} +- Stack: ..., A → ... +- store A to the Ith scratch space + +## bnz + +- Syntax: `bnz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x40 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is not zero + +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. + +At 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.) + +## pop + +- Bytecode: 0x48 +- Stack: ..., A → ... +- discard A + +## dup + +- Bytecode: 0x49 +- Stack: ..., A → ..., A, A +- duplicate A diff --git a/data/transactions/logic/TEAL_opcodes.md b/data/transactions/logic/TEAL_opcodes_v10.md similarity index 98% rename from data/transactions/logic/TEAL_opcodes.md rename to data/transactions/logic/TEAL_opcodes_v10.md index a87e93a1de..31beb6c388 100644 --- a/data/transactions/logic/TEAL_opcodes.md +++ b/data/transactions/logic/TEAL_opcodes_v10.md @@ -1,4 +1,4 @@ -# Opcodes +# v10 Opcodes Ops have a 'cost' of 1 unless otherwise specified. @@ -14,27 +14,21 @@ Ops have a 'cost' of 1 unless otherwise specified. - Bytecode: 0x01 - Stack: ..., A: []byte → ..., [32]byte - SHA256 hash of value A, yields [32]byte -- **Cost**: - - 7 (v1) - - 35 (since v2) +- **Cost**: 35 ## keccak256 - Bytecode: 0x02 - Stack: ..., A: []byte → ..., [32]byte - Keccak256 hash of value A, yields [32]byte -- **Cost**: - - 26 (v1) - - 130 (since v2) +- **Cost**: 130 ## sha512_256 - Bytecode: 0x03 - Stack: ..., A: []byte → ..., [32]byte - SHA512_256 hash of value A, yields [32]byte -- **Cost**: - - 9 (v1) - - 45 (since v2) +- **Cost**: 45 ## ed25519verify @@ -51,7 +45,7 @@ The 32 byte public key is the last element on the stack, preceded by the 64 byte - Bytecode: 0x05 {uint8} - Stack: ..., A: []byte, B: []byte, C: []byte, D: []byte, E: []byte → ..., bool - for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1} -- **Cost**: Secp256k1=1700; Secp256r1=2500 +- **Cost**: Secp256k1=1700; Secp256r1=2500 - Availability: v5 ### ECDSA @@ -72,7 +66,7 @@ The 32 byte Y-component of a public key is the last element on the stack, preced - Bytecode: 0x06 {uint8} - Stack: ..., A: []byte → ..., X: []byte, Y: []byte - decompress pubkey A into components X, Y -- **Cost**: Secp256k1=650; Secp256r1=2400 +- **Cost**: Secp256k1=650; Secp256r1=2400 - Availability: v5 The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded. @@ -1653,7 +1647,7 @@ Fields - Bytecode: 0xe0 {uint8} - Stack: ..., A: []byte, B: []byte → ..., []byte - for curve points A and B, return the curve point A + B -- **Cost**: BN254g1=125; BN254g2=170; BLS12_381g1=205; BLS12_381g2=290 +- **Cost**: BN254g1=125; BN254g2=170; BLS12_381g1=205; BLS12_381g2=290 - Availability: v10 ### EC @@ -1685,7 +1679,7 @@ Does _not_ check if A and B are in the main prime-order subgroup. - Bytecode: 0xe1 {uint8} - Stack: ..., A: []byte, B: []byte → ..., []byte - for curve point A and scalar B, return the curve point BA, the point A multiplied by the scalar B. -- **Cost**: BN254g1=1810; BN254g2=3430; BLS12_381g1=2950; BLS12_381g2=6530 +- **Cost**: BN254g1=1810; BN254g2=3430; BLS12_381g1=2950; BLS12_381g2=6530 - Availability: v10 A is a curve point encoded and checked as described in `ec_add`. Scalar B is interpreted as a big-endian unsigned integer. Fails if B exceeds 32 bytes. @@ -1696,7 +1690,7 @@ A is a curve point encoded and checked as described in `ec_add`. Scalar B is int - Bytecode: 0xe2 {uint8} - Stack: ..., A: []byte, B: []byte → ..., bool - 1 if the product of the pairing of each point in A with its respective point in B is equal to the identity element of the target group Gt, else 0 -- **Cost**: BN254g1=8000 + 7400 per 64 bytes of B; BN254g2=8000 + 7400 per 128 bytes of B; BLS12_381g1=13000 + 10000 per 96 bytes of B; BLS12_381g2=13000 + 10000 per 192 bytes of B +- **Cost**: BN254g1=8000 + 7400 per 64 bytes of B; BN254g2=8000 + 7400 per 128 bytes of B; BLS12_381g1=13000 + 10000 per 96 bytes of B; BLS12_381g2=13000 + 10000 per 192 bytes of B - Availability: v10 A and B are concatenated points, encoded and checked as described in `ec_add`. A contains points of the group G, B contains points of the associated group (G2 if G is G1, and vice versa). Fails if A and B have a different number of points, or if any point is not in its described group or outside the main prime-order subgroup - a stronger condition than other opcodes. AVM values are limited to 4096 bytes, so `ec_pairing_check` is limited by the size of the points in the groups being operated upon. @@ -1707,7 +1701,7 @@ A and B are concatenated points, encoded and checked as described in `ec_add`. A - Bytecode: 0xe3 {uint8} - Stack: ..., A: []byte, B: []byte → ..., []byte - for curve points A and scalars B, return curve point B0A0 + B1A1 + B2A2 + ... + BnAn -- **Cost**: BN254g1=3600 + 90 per 32 bytes of B; BN254g2=7200 + 270 per 32 bytes of B; BLS12_381g1=6500 + 95 per 32 bytes of B; BLS12_381g2=14850 + 485 per 32 bytes of B +- **Cost**: BN254g1=3600 + 90 per 32 bytes of B; BN254g2=7200 + 270 per 32 bytes of B; BLS12_381g1=6500 + 95 per 32 bytes of B; BLS12_381g2=14850 + 485 per 32 bytes of B - Availability: v10 A is a list of concatenated points, encoded and checked as described in `ec_add`. B is a list of concatenated scalars which, unlike ec_scalar_mul, must all be exactly 32 bytes long. @@ -1719,7 +1713,7 @@ The name `ec_multi_scalar_mul` was chosen to reflect common usage, but a more co - Bytecode: 0xe4 {uint8} - Stack: ..., A: []byte → ..., bool - 1 if A is in the main prime-order subgroup of G (including the point at infinity) else 0. Program fails if A is not in G at all. -- **Cost**: BN254g1=20; BN254g2=3100; BLS12_381g1=1850; BLS12_381g2=2340 +- **Cost**: BN254g1=20; BN254g2=3100; BLS12_381g1=1850; BLS12_381g2=2340 - Availability: v10 ## ec_map_to @@ -1728,7 +1722,7 @@ The name `ec_multi_scalar_mul` was chosen to reflect common usage, but a more co - Bytecode: 0xe5 {uint8} - Stack: ..., A: []byte → ..., []byte - maps field element A to group G -- **Cost**: BN254g1=630; BN254g2=3300; BLS12_381g1=1950; BLS12_381g2=8150 +- **Cost**: BN254g1=630; BN254g2=3300; BLS12_381g1=1950; BLS12_381g2=8150 - Availability: v10 BN254 points are mapped by the SVDW map. BLS12-381 points are mapped by the SSWU map. diff --git a/data/transactions/logic/TEAL_opcodes_v2.md b/data/transactions/logic/TEAL_opcodes_v2.md new file mode 100644 index 0000000000..52e65591bc --- /dev/null +++ b/data/transactions/logic/TEAL_opcodes_v2.md @@ -0,0 +1,671 @@ +# v2 Opcodes + +Ops have a 'cost' of 1 unless otherwise specified. + + +## err + +- Bytecode: 0x00 +- Stack: ... → _exits_ +- Fail immediately. + +## sha256 + +- Bytecode: 0x01 +- Stack: ..., A: []byte → ..., [32]byte +- SHA256 hash of value A, yields [32]byte +- **Cost**: 35 + +## keccak256 + +- Bytecode: 0x02 +- Stack: ..., A: []byte → ..., [32]byte +- Keccak256 hash of value A, yields [32]byte +- **Cost**: 130 + +## sha512_256 + +- Bytecode: 0x03 +- Stack: ..., A: []byte → ..., [32]byte +- SHA512_256 hash of value A, yields [32]byte +- **Cost**: 45 + +## ed25519verify + +- Bytecode: 0x04 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1} +- **Cost**: 1900 +- Mode: Signature + +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. + +## + + +- Bytecode: 0x08 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A plus B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`. + +## - + +- Bytecode: 0x09 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A minus B. Fail if B > A. + +## / + +- Bytecode: 0x0a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by B (truncated division). Fail if B == 0. + +`divmodw` is available to divide the two-element values produced by `mulw` and `addw`. + +## * + +- Bytecode: 0x0b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`. + +## < + +- Bytecode: 0x0c +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than B => {0 or 1} + +## > + +- Bytecode: 0x0d +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than B => {0 or 1} + +## <= + +- Bytecode: 0x0e +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than or equal to B => {0 or 1} + +## >= + +- Bytecode: 0x0f +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than or equal to B => {0 or 1} + +## && + +- Bytecode: 0x10 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero and B is not zero => {0 or 1} + +## || + +- Bytecode: 0x11 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero or B is not zero => {0 or 1} + +## == + +- Bytecode: 0x12 +- Stack: ..., A, B → ..., bool +- A is equal to B => {0 or 1} + +## != + +- Bytecode: 0x13 +- Stack: ..., A, B → ..., bool +- A is not equal to B => {0 or 1} + +## ! + +- Bytecode: 0x14 +- Stack: ..., A: uint64 → ..., uint64 +- A == 0 yields 1; else 0 + +## len + +- Bytecode: 0x15 +- Stack: ..., A: []byte → ..., uint64 +- yields length of byte value A + +## itob + +- Bytecode: 0x16 +- Stack: ..., A: uint64 → ..., []byte +- converts uint64 A to big-endian byte array, always of length 8 + +## btoi + +- Bytecode: 0x17 +- Stack: ..., A: []byte → ..., uint64 +- converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8. + +`btoi` fails if the input is longer than 8 bytes. + +## % + +- Bytecode: 0x18 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A modulo B. Fail if B == 0. + +## | + +- Bytecode: 0x19 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-or B + +## & + +- Bytecode: 0x1a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-and B + +## ^ + +- Bytecode: 0x1b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-xor B + +## ~ + +- Bytecode: 0x1c +- Stack: ..., A: uint64 → ..., uint64 +- bitwise invert value A + +## mulw + +- Bytecode: 0x1d +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low + +## addw + +- Bytecode: 0x1e +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits. +- Availability: v2 + +## intcblock + +- Syntax: `intcblock UINT ...` ∋ UINT ...: a block of int constant values +- Bytecode: 0x20 {varuint count, [varuint ...]} +- Stack: ... → ... +- prepare block of uint64 constants for use by intc + +`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. + +## intc + +- Syntax: `intc I` ∋ I: an index in the intcblock +- Bytecode: 0x21 {uint8} +- Stack: ... → ..., uint64 +- Ith constant from intcblock + +## intc_0 + +- Bytecode: 0x22 +- Stack: ... → ..., uint64 +- constant 0 from intcblock + +## intc_1 + +- Bytecode: 0x23 +- Stack: ... → ..., uint64 +- constant 1 from intcblock + +## intc_2 + +- Bytecode: 0x24 +- Stack: ... → ..., uint64 +- constant 2 from intcblock + +## intc_3 + +- Bytecode: 0x25 +- Stack: ... → ..., uint64 +- constant 3 from intcblock + +## bytecblock + +- Syntax: `bytecblock BYTES ...` ∋ BYTES ...: a block of byte constant values +- Bytecode: 0x26 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ... +- prepare block of byte-array constants for use by bytec + +`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. + +## bytec + +- Syntax: `bytec I` ∋ I: an index in the bytecblock +- Bytecode: 0x27 {uint8} +- Stack: ... → ..., []byte +- Ith constant from bytecblock + +## bytec_0 + +- Bytecode: 0x28 +- Stack: ... → ..., []byte +- constant 0 from bytecblock + +## bytec_1 + +- Bytecode: 0x29 +- Stack: ... → ..., []byte +- constant 1 from bytecblock + +## bytec_2 + +- Bytecode: 0x2a +- Stack: ... → ..., []byte +- constant 2 from bytecblock + +## bytec_3 + +- Bytecode: 0x2b +- Stack: ... → ..., []byte +- constant 3 from bytecblock + +## arg + +- Syntax: `arg N` ∋ N: an arg index +- Bytecode: 0x2c {uint8} +- Stack: ... → ..., []byte +- Nth LogicSig argument +- Mode: Signature + +## arg_0 + +- Bytecode: 0x2d +- Stack: ... → ..., []byte +- LogicSig argument 0 +- Mode: Signature + +## arg_1 + +- Bytecode: 0x2e +- Stack: ... → ..., []byte +- LogicSig argument 1 +- Mode: Signature + +## arg_2 + +- Bytecode: 0x2f +- Stack: ... → ..., []byte +- LogicSig argument 2 +- Mode: Signature + +## arg_3 + +- Bytecode: 0x30 +- Stack: ... → ..., []byte +- LogicSig argument 3 +- Mode: Signature + +## txn + +- Syntax: `txn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x31 {uint8} +- Stack: ... → ..., any +- field F of current transaction + +### txn + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | Sender | address | | 32 byte address | +| 1 | Fee | uint64 | | microalgos | +| 2 | FirstValid | uint64 | | round number | +| 4 | LastValid | uint64 | | round number | +| 5 | Note | []byte | | Any data up to 1024 bytes | +| 6 | Lease | [32]byte | | 32 byte lease value | +| 7 | Receiver | address | | 32 byte address | +| 8 | Amount | uint64 | | microalgos | +| 9 | CloseRemainderTo | address | | 32 byte address | +| 10 | VotePK | [32]byte | | 32 byte address | +| 11 | SelectionPK | [32]byte | | 32 byte address | +| 12 | VoteFirst | uint64 | | The first round that the participation key is valid. | +| 13 | VoteLast | uint64 | | The last round that the participation key is valid. | +| 14 | VoteKeyDilution | uint64 | | Dilution for the 2-level participation key | +| 15 | Type | []byte | | Transaction type as bytes | +| 16 | TypeEnum | uint64 | | Transaction type as integer | +| 17 | XferAsset | uint64 | | Asset ID | +| 18 | AssetAmount | uint64 | | value in Asset's units | +| 19 | AssetSender | address | | 32 byte address. Source of assets if Sender is the Asset's Clawback address. | +| 20 | AssetReceiver | address | | 32 byte address | +| 21 | AssetCloseTo | address | | 32 byte address | +| 22 | GroupIndex | uint64 | | Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1 | +| 23 | TxID | [32]byte | | The computed ID for this transaction. 32 bytes. | +| 24 | ApplicationID | uint64 | v2 | ApplicationID from ApplicationCall transaction | +| 25 | OnCompletion | uint64 | v2 | ApplicationCall transaction on completion action | +| 27 | NumAppArgs | uint64 | v2 | Number of ApplicationArgs | +| 29 | NumAccounts | uint64 | v2 | Number of Accounts | +| 30 | ApprovalProgram | []byte | v2 | Approval program | +| 31 | ClearStateProgram | []byte | v2 | Clear state program | +| 32 | RekeyTo | address | v2 | 32 byte Sender's new AuthAddr | +| 33 | ConfigAsset | uint64 | v2 | Asset ID in asset config transaction | +| 34 | ConfigAssetTotal | uint64 | v2 | Total number of units of this asset created | +| 35 | ConfigAssetDecimals | uint64 | v2 | Number of digits to display after the decimal place when displaying the asset | +| 36 | ConfigAssetDefaultFrozen | bool | v2 | Whether the asset's slots are frozen by default or not, 0 or 1 | +| 37 | ConfigAssetUnitName | []byte | v2 | Unit name of the asset | +| 38 | ConfigAssetName | []byte | v2 | The asset name | +| 39 | ConfigAssetURL | []byte | v2 | URL | +| 40 | ConfigAssetMetadataHash | [32]byte | v2 | 32 byte commitment to unspecified asset metadata | +| 41 | ConfigAssetManager | address | v2 | 32 byte address | +| 42 | ConfigAssetReserve | address | v2 | 32 byte address | +| 43 | ConfigAssetFreeze | address | v2 | 32 byte address | +| 44 | ConfigAssetClawback | address | v2 | 32 byte address | +| 45 | FreezeAsset | uint64 | v2 | Asset ID being frozen or un-frozen | +| 46 | FreezeAssetAccount | address | v2 | 32 byte address of the account whose asset slot is being frozen or un-frozen | +| 47 | FreezeAssetFrozen | bool | v2 | The new frozen value, 0 or 1 | + + +## global + +- Syntax: `global F` ∋ F: [global](#field-group-global) +- Bytecode: 0x32 {uint8} +- Stack: ... → ..., any +- global field F + +### global + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | MinTxnFee | uint64 | | microalgos | +| 1 | MinBalance | uint64 | | microalgos | +| 2 | MaxTxnLife | uint64 | | rounds | +| 3 | ZeroAddress | address | | 32 byte address of all zero bytes | +| 4 | GroupSize | uint64 | | Number of transactions in this atomic transaction group. At least 1 | +| 5 | LogicSigVersion | uint64 | v2 | Maximum supported version | +| 6 | Round | uint64 | v2 | Current round number. Application mode only. | +| 7 | LatestTimestamp | uint64 | v2 | Last confirmed block UNIX timestamp. Fails if negative. Application mode only. | +| 8 | CurrentApplicationID | uint64 | v2 | ID of current application executing. Application mode only. | + + +## gtxn + +- Syntax: `gtxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0x33 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the current group + +for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`. + +## load + +- Syntax: `load I` ∋ I: position in scratch space to load from +- Bytecode: 0x34 {uint8} +- Stack: ... → ..., any +- Ith scratch space value. All scratch spaces are 0 at program start. + +## store + +- Syntax: `store I` ∋ I: position in scratch space to store to +- Bytecode: 0x35 {uint8} +- Stack: ..., A → ... +- store A to the Ith scratch space + +## txna + +- Syntax: `txna F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x36 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the current transaction
`txna` can be called using `txn` with 2 immediates. +- Availability: v2 + +### txna + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 26 | ApplicationArgs | []byte | Arguments passed to the application in the ApplicationCall transaction | +| 28 | Accounts | address | Accounts listed in the ApplicationCall transaction | + + +## gtxna + +- Syntax: `gtxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x37 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the current group
`gtxna` can be called using `gtxn` with 3 immediates. +- Availability: v2 + +## bnz + +- Syntax: `bnz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x40 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is not zero + +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. + +At 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.) + +## bz + +- Syntax: `bz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x41 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is zero +- Availability: v2 + +See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`. + +## b + +- Syntax: `b TARGET` ∋ TARGET: branch offset +- Bytecode: 0x42 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET +- Availability: v2 + +See `bnz` for details on how branches work. `b` always jumps to the offset. + +## return + +- Bytecode: 0x43 +- Stack: ..., A: uint64 → _exits_ +- use A as success value; end +- Availability: v2 + +## pop + +- Bytecode: 0x48 +- Stack: ..., A → ... +- discard A + +## dup + +- Bytecode: 0x49 +- Stack: ..., A → ..., A, A +- duplicate A + +## dup2 + +- Bytecode: 0x4a +- Stack: ..., A, B → ..., A, B, A, B +- duplicate A and B +- Availability: v2 + +## concat + +- Bytecode: 0x50 +- Stack: ..., A: []byte, B: []byte → ..., []byte +- join A and B +- Availability: v2 + +`concat` fails if the result would be greater than 4096 bytes. + +## substring + +- Syntax: `substring S E` ∋ S: start position, E: end position +- Bytecode: 0x51 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v2 + +## substring3 + +- Bytecode: 0x52 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v2 + +## balance + +- Bytecode: 0x60 +- Stack: ..., A: uint64 → ..., uint64 +- 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` +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## app_opted_in + +- Bytecode: 0x61 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- 1 if account A is opted in to application B, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_get + +- Bytecode: 0x62 +- Stack: ..., A: uint64, B: []byte → ..., any +- local state of the key B in the current application in account A +- Availability: v2 +- Mode: Application + +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. + +## app_local_get_ex + +- Bytecode: 0x63 +- Stack: ..., A: uint64, B: uint64, C: []byte → ..., X: any, Y: bool +- X is the local state of application B, key C in account A. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_global_get + +- Bytecode: 0x64 +- Stack: ..., A: []byte → ..., any +- global state of the key A in the current application +- Availability: v2 +- Mode: Application + +params: state key. Return: value. The value is zero (of type uint64) if the key does not exist. + +## app_global_get_ex + +- Bytecode: 0x65 +- Stack: ..., A: uint64, B: []byte → ..., X: any, Y: bool +- X is the global state of application A, key B. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_put + +- Bytecode: 0x66 +- Stack: ..., A: uint64, B: []byte, C → ... +- write C to key B in account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value. + +## app_global_put + +- Bytecode: 0x67 +- Stack: ..., A: []byte, B → ... +- write B to key A in the global state of the current application +- Availability: v2 +- Mode: Application + +## app_local_del + +- Bytecode: 0x68 +- Stack: ..., A: uint64, B: []byte → ... +- delete key B from account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. + +Deleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.) + +## app_global_del + +- Bytecode: 0x69 +- Stack: ..., A: []byte → ... +- delete key A from the global state of the current application +- Availability: v2 +- Mode: Application + +params: state key. + +Deleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.) + +## asset_holding_get + +- Syntax: `asset_holding_get F` ∋ F: [asset_holding](#field-group-asset_holding) +- Bytecode: 0x70 {uint8} +- Stack: ..., A: uint64, B: uint64 → ..., X: any, Y: bool +- X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0 +- Availability: v2 +- Mode: Application + +### asset_holding + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetBalance | uint64 | Amount of the asset unit held by this account | +| 1 | AssetFrozen | bool | Is the asset frozen or not | + + +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. + +## asset_params_get + +- Syntax: `asset_params_get F` ∋ F: [asset_params](#field-group-asset_params) +- Bytecode: 0x71 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from asset A. Y is 1 if A exists, else 0 +- Availability: v2 +- Mode: Application + +### asset_params + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetTotal | uint64 | Total number of units of this asset | +| 1 | AssetDecimals | uint64 | See AssetParams.Decimals | +| 2 | AssetDefaultFrozen | bool | Frozen by default or not | +| 3 | AssetUnitName | []byte | Asset unit name | +| 4 | AssetName | []byte | Asset name | +| 5 | AssetURL | []byte | URL with additional info about the asset | +| 6 | AssetMetadataHash | [32]byte | Arbitrary commitment | +| 7 | AssetManager | address | Manager address | +| 8 | AssetReserve | address | Reserve address | +| 9 | AssetFreeze | address | Freeze address | +| 10 | AssetClawback | address | Clawback address | + + +params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value. diff --git a/data/transactions/logic/TEAL_opcodes_v3.md b/data/transactions/logic/TEAL_opcodes_v3.md new file mode 100644 index 0000000000..c09a75df18 --- /dev/null +++ b/data/transactions/logic/TEAL_opcodes_v3.md @@ -0,0 +1,789 @@ +# v3 Opcodes + +Ops have a 'cost' of 1 unless otherwise specified. + + +## err + +- Bytecode: 0x00 +- Stack: ... → _exits_ +- Fail immediately. + +## sha256 + +- Bytecode: 0x01 +- Stack: ..., A: []byte → ..., [32]byte +- SHA256 hash of value A, yields [32]byte +- **Cost**: 35 + +## keccak256 + +- Bytecode: 0x02 +- Stack: ..., A: []byte → ..., [32]byte +- Keccak256 hash of value A, yields [32]byte +- **Cost**: 130 + +## sha512_256 + +- Bytecode: 0x03 +- Stack: ..., A: []byte → ..., [32]byte +- SHA512_256 hash of value A, yields [32]byte +- **Cost**: 45 + +## ed25519verify + +- Bytecode: 0x04 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1} +- **Cost**: 1900 +- Mode: Signature + +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. + +## + + +- Bytecode: 0x08 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A plus B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`. + +## - + +- Bytecode: 0x09 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A minus B. Fail if B > A. + +## / + +- Bytecode: 0x0a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by B (truncated division). Fail if B == 0. + +`divmodw` is available to divide the two-element values produced by `mulw` and `addw`. + +## * + +- Bytecode: 0x0b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`. + +## < + +- Bytecode: 0x0c +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than B => {0 or 1} + +## > + +- Bytecode: 0x0d +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than B => {0 or 1} + +## <= + +- Bytecode: 0x0e +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than or equal to B => {0 or 1} + +## >= + +- Bytecode: 0x0f +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than or equal to B => {0 or 1} + +## && + +- Bytecode: 0x10 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero and B is not zero => {0 or 1} + +## || + +- Bytecode: 0x11 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero or B is not zero => {0 or 1} + +## == + +- Bytecode: 0x12 +- Stack: ..., A, B → ..., bool +- A is equal to B => {0 or 1} + +## != + +- Bytecode: 0x13 +- Stack: ..., A, B → ..., bool +- A is not equal to B => {0 or 1} + +## ! + +- Bytecode: 0x14 +- Stack: ..., A: uint64 → ..., uint64 +- A == 0 yields 1; else 0 + +## len + +- Bytecode: 0x15 +- Stack: ..., A: []byte → ..., uint64 +- yields length of byte value A + +## itob + +- Bytecode: 0x16 +- Stack: ..., A: uint64 → ..., []byte +- converts uint64 A to big-endian byte array, always of length 8 + +## btoi + +- Bytecode: 0x17 +- Stack: ..., A: []byte → ..., uint64 +- converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8. + +`btoi` fails if the input is longer than 8 bytes. + +## % + +- Bytecode: 0x18 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A modulo B. Fail if B == 0. + +## | + +- Bytecode: 0x19 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-or B + +## & + +- Bytecode: 0x1a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-and B + +## ^ + +- Bytecode: 0x1b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-xor B + +## ~ + +- Bytecode: 0x1c +- Stack: ..., A: uint64 → ..., uint64 +- bitwise invert value A + +## mulw + +- Bytecode: 0x1d +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low + +## addw + +- Bytecode: 0x1e +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits. +- Availability: v2 + +## intcblock + +- Syntax: `intcblock UINT ...` ∋ UINT ...: a block of int constant values +- Bytecode: 0x20 {varuint count, [varuint ...]} +- Stack: ... → ... +- prepare block of uint64 constants for use by intc + +`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. + +## intc + +- Syntax: `intc I` ∋ I: an index in the intcblock +- Bytecode: 0x21 {uint8} +- Stack: ... → ..., uint64 +- Ith constant from intcblock + +## intc_0 + +- Bytecode: 0x22 +- Stack: ... → ..., uint64 +- constant 0 from intcblock + +## intc_1 + +- Bytecode: 0x23 +- Stack: ... → ..., uint64 +- constant 1 from intcblock + +## intc_2 + +- Bytecode: 0x24 +- Stack: ... → ..., uint64 +- constant 2 from intcblock + +## intc_3 + +- Bytecode: 0x25 +- Stack: ... → ..., uint64 +- constant 3 from intcblock + +## bytecblock + +- Syntax: `bytecblock BYTES ...` ∋ BYTES ...: a block of byte constant values +- Bytecode: 0x26 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ... +- prepare block of byte-array constants for use by bytec + +`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. + +## bytec + +- Syntax: `bytec I` ∋ I: an index in the bytecblock +- Bytecode: 0x27 {uint8} +- Stack: ... → ..., []byte +- Ith constant from bytecblock + +## bytec_0 + +- Bytecode: 0x28 +- Stack: ... → ..., []byte +- constant 0 from bytecblock + +## bytec_1 + +- Bytecode: 0x29 +- Stack: ... → ..., []byte +- constant 1 from bytecblock + +## bytec_2 + +- Bytecode: 0x2a +- Stack: ... → ..., []byte +- constant 2 from bytecblock + +## bytec_3 + +- Bytecode: 0x2b +- Stack: ... → ..., []byte +- constant 3 from bytecblock + +## arg + +- Syntax: `arg N` ∋ N: an arg index +- Bytecode: 0x2c {uint8} +- Stack: ... → ..., []byte +- Nth LogicSig argument +- Mode: Signature + +## arg_0 + +- Bytecode: 0x2d +- Stack: ... → ..., []byte +- LogicSig argument 0 +- Mode: Signature + +## arg_1 + +- Bytecode: 0x2e +- Stack: ... → ..., []byte +- LogicSig argument 1 +- Mode: Signature + +## arg_2 + +- Bytecode: 0x2f +- Stack: ... → ..., []byte +- LogicSig argument 2 +- Mode: Signature + +## arg_3 + +- Bytecode: 0x30 +- Stack: ... → ..., []byte +- LogicSig argument 3 +- Mode: Signature + +## txn + +- Syntax: `txn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x31 {uint8} +- Stack: ... → ..., any +- field F of current transaction + +### txn + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | Sender | address | | 32 byte address | +| 1 | Fee | uint64 | | microalgos | +| 2 | FirstValid | uint64 | | round number | +| 4 | LastValid | uint64 | | round number | +| 5 | Note | []byte | | Any data up to 1024 bytes | +| 6 | Lease | [32]byte | | 32 byte lease value | +| 7 | Receiver | address | | 32 byte address | +| 8 | Amount | uint64 | | microalgos | +| 9 | CloseRemainderTo | address | | 32 byte address | +| 10 | VotePK | [32]byte | | 32 byte address | +| 11 | SelectionPK | [32]byte | | 32 byte address | +| 12 | VoteFirst | uint64 | | The first round that the participation key is valid. | +| 13 | VoteLast | uint64 | | The last round that the participation key is valid. | +| 14 | VoteKeyDilution | uint64 | | Dilution for the 2-level participation key | +| 15 | Type | []byte | | Transaction type as bytes | +| 16 | TypeEnum | uint64 | | Transaction type as integer | +| 17 | XferAsset | uint64 | | Asset ID | +| 18 | AssetAmount | uint64 | | value in Asset's units | +| 19 | AssetSender | address | | 32 byte address. Source of assets if Sender is the Asset's Clawback address. | +| 20 | AssetReceiver | address | | 32 byte address | +| 21 | AssetCloseTo | address | | 32 byte address | +| 22 | GroupIndex | uint64 | | Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1 | +| 23 | TxID | [32]byte | | The computed ID for this transaction. 32 bytes. | +| 24 | ApplicationID | uint64 | v2 | ApplicationID from ApplicationCall transaction | +| 25 | OnCompletion | uint64 | v2 | ApplicationCall transaction on completion action | +| 27 | NumAppArgs | uint64 | v2 | Number of ApplicationArgs | +| 29 | NumAccounts | uint64 | v2 | Number of Accounts | +| 30 | ApprovalProgram | []byte | v2 | Approval program | +| 31 | ClearStateProgram | []byte | v2 | Clear state program | +| 32 | RekeyTo | address | v2 | 32 byte Sender's new AuthAddr | +| 33 | ConfigAsset | uint64 | v2 | Asset ID in asset config transaction | +| 34 | ConfigAssetTotal | uint64 | v2 | Total number of units of this asset created | +| 35 | ConfigAssetDecimals | uint64 | v2 | Number of digits to display after the decimal place when displaying the asset | +| 36 | ConfigAssetDefaultFrozen | bool | v2 | Whether the asset's slots are frozen by default or not, 0 or 1 | +| 37 | ConfigAssetUnitName | []byte | v2 | Unit name of the asset | +| 38 | ConfigAssetName | []byte | v2 | The asset name | +| 39 | ConfigAssetURL | []byte | v2 | URL | +| 40 | ConfigAssetMetadataHash | [32]byte | v2 | 32 byte commitment to unspecified asset metadata | +| 41 | ConfigAssetManager | address | v2 | 32 byte address | +| 42 | ConfigAssetReserve | address | v2 | 32 byte address | +| 43 | ConfigAssetFreeze | address | v2 | 32 byte address | +| 44 | ConfigAssetClawback | address | v2 | 32 byte address | +| 45 | FreezeAsset | uint64 | v2 | Asset ID being frozen or un-frozen | +| 46 | FreezeAssetAccount | address | v2 | 32 byte address of the account whose asset slot is being frozen or un-frozen | +| 47 | FreezeAssetFrozen | bool | v2 | The new frozen value, 0 or 1 | +| 49 | NumAssets | uint64 | v3 | Number of Assets | +| 51 | NumApplications | uint64 | v3 | Number of Applications | +| 52 | GlobalNumUint | uint64 | v3 | Number of global state integers in ApplicationCall | +| 53 | GlobalNumByteSlice | uint64 | v3 | Number of global state byteslices in ApplicationCall | +| 54 | LocalNumUint | uint64 | v3 | Number of local state integers in ApplicationCall | +| 55 | LocalNumByteSlice | uint64 | v3 | Number of local state byteslices in ApplicationCall | + + +## global + +- Syntax: `global F` ∋ F: [global](#field-group-global) +- Bytecode: 0x32 {uint8} +- Stack: ... → ..., any +- global field F + +### global + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | MinTxnFee | uint64 | | microalgos | +| 1 | MinBalance | uint64 | | microalgos | +| 2 | MaxTxnLife | uint64 | | rounds | +| 3 | ZeroAddress | address | | 32 byte address of all zero bytes | +| 4 | GroupSize | uint64 | | Number of transactions in this atomic transaction group. At least 1 | +| 5 | LogicSigVersion | uint64 | v2 | Maximum supported version | +| 6 | Round | uint64 | v2 | Current round number. Application mode only. | +| 7 | LatestTimestamp | uint64 | v2 | Last confirmed block UNIX timestamp. Fails if negative. Application mode only. | +| 8 | CurrentApplicationID | uint64 | v2 | ID of current application executing. Application mode only. | +| 9 | CreatorAddress | address | v3 | Address of the creator of the current application. Application mode only. | + + +## gtxn + +- Syntax: `gtxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0x33 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the current group + +for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`. + +## load + +- Syntax: `load I` ∋ I: position in scratch space to load from +- Bytecode: 0x34 {uint8} +- Stack: ... → ..., any +- Ith scratch space value. All scratch spaces are 0 at program start. + +## store + +- Syntax: `store I` ∋ I: position in scratch space to store to +- Bytecode: 0x35 {uint8} +- Stack: ..., A → ... +- store A to the Ith scratch space + +## txna + +- Syntax: `txna F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x36 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the current transaction
`txna` can be called using `txn` with 2 immediates. +- Availability: v2 + +### txna + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 26 | ApplicationArgs | []byte | v2 | Arguments passed to the application in the ApplicationCall transaction | +| 28 | Accounts | address | v2 | Accounts listed in the ApplicationCall transaction | +| 48 | Assets | uint64 | v3 | Foreign Assets listed in the ApplicationCall transaction | +| 50 | Applications | uint64 | v3 | Foreign Apps listed in the ApplicationCall transaction | + + +## gtxna + +- Syntax: `gtxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x37 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the current group
`gtxna` can be called using `gtxn` with 3 immediates. +- Availability: v2 + +## gtxns + +- Syntax: `gtxns F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x38 {uint8} +- Stack: ..., A: uint64 → ..., any +- field F of the Ath transaction in the current group +- Availability: v3 + +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. + +## gtxnsa + +- Syntax: `gtxnsa F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x39 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith value of the array field F from the Ath transaction in the current group
`gtxnsa` can be called using `gtxns` with 2 immediates. +- Availability: v3 + +## bnz + +- Syntax: `bnz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x40 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is not zero + +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. + +At 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.) + +## bz + +- Syntax: `bz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x41 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is zero +- Availability: v2 + +See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`. + +## b + +- Syntax: `b TARGET` ∋ TARGET: branch offset +- Bytecode: 0x42 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET +- Availability: v2 + +See `bnz` for details on how branches work. `b` always jumps to the offset. + +## return + +- Bytecode: 0x43 +- Stack: ..., A: uint64 → _exits_ +- use A as success value; end +- Availability: v2 + +## assert + +- Bytecode: 0x44 +- Stack: ..., A: uint64 → ... +- immediately fail unless A is a non-zero number +- Availability: v3 + +## pop + +- Bytecode: 0x48 +- Stack: ..., A → ... +- discard A + +## dup + +- Bytecode: 0x49 +- Stack: ..., A → ..., A, A +- duplicate A + +## dup2 + +- Bytecode: 0x4a +- Stack: ..., A, B → ..., A, B, A, B +- duplicate A and B +- Availability: v2 + +## dig + +- Syntax: `dig N` ∋ N: depth +- Bytecode: 0x4b {uint8} +- Stack: ..., A, [N items] → ..., A, [N items], A +- Nth value from the top of the stack. dig 0 is equivalent to dup +- Availability: v3 + +## swap + +- Bytecode: 0x4c +- Stack: ..., A, B → ..., B, A +- swaps A and B on stack +- Availability: v3 + +## select + +- Bytecode: 0x4d +- Stack: ..., A, B, C: uint64 → ..., A or B +- selects one of two values based on top-of-stack: B if C != 0, else A +- Availability: v3 + +## concat + +- Bytecode: 0x50 +- Stack: ..., A: []byte, B: []byte → ..., []byte +- join A and B +- Availability: v2 + +`concat` fails if the result would be greater than 4096 bytes. + +## substring + +- Syntax: `substring S E` ∋ S: start position, E: end position +- Bytecode: 0x51 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v2 + +## substring3 + +- Bytecode: 0x52 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v2 + +## getbit + +- Bytecode: 0x53 +- Stack: ..., A, B: uint64 → ..., uint64 +- 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 +- Availability: v3 + +see explanation of bit ordering in setbit + +## setbit + +- Bytecode: 0x54 +- Stack: ..., A, B: uint64, C: uint64 → ..., any +- 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 +- Availability: v3 + +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. + +## getbyte + +- Bytecode: 0x55 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails +- Availability: v3 + +## setbyte + +- Bytecode: 0x56 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v3 + +## balance + +- Bytecode: 0x60 +- Stack: ..., A: uint64 → ..., uint64 +- 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` +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## app_opted_in + +- Bytecode: 0x61 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- 1 if account A is opted in to application B, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_get + +- Bytecode: 0x62 +- Stack: ..., A: uint64, B: []byte → ..., any +- local state of the key B in the current application in account A +- Availability: v2 +- Mode: Application + +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. + +## app_local_get_ex + +- Bytecode: 0x63 +- Stack: ..., A: uint64, B: uint64, C: []byte → ..., X: any, Y: bool +- X is the local state of application B, key C in account A. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_global_get + +- Bytecode: 0x64 +- Stack: ..., A: []byte → ..., any +- global state of the key A in the current application +- Availability: v2 +- Mode: Application + +params: state key. Return: value. The value is zero (of type uint64) if the key does not exist. + +## app_global_get_ex + +- Bytecode: 0x65 +- Stack: ..., A: uint64, B: []byte → ..., X: any, Y: bool +- X is the global state of application A, key B. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_put + +- Bytecode: 0x66 +- Stack: ..., A: uint64, B: []byte, C → ... +- write C to key B in account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value. + +## app_global_put + +- Bytecode: 0x67 +- Stack: ..., A: []byte, B → ... +- write B to key A in the global state of the current application +- Availability: v2 +- Mode: Application + +## app_local_del + +- Bytecode: 0x68 +- Stack: ..., A: uint64, B: []byte → ... +- delete key B from account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. + +Deleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.) + +## app_global_del + +- Bytecode: 0x69 +- Stack: ..., A: []byte → ... +- delete key A from the global state of the current application +- Availability: v2 +- Mode: Application + +params: state key. + +Deleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.) + +## asset_holding_get + +- Syntax: `asset_holding_get F` ∋ F: [asset_holding](#field-group-asset_holding) +- Bytecode: 0x70 {uint8} +- Stack: ..., A: uint64, B: uint64 → ..., X: any, Y: bool +- X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0 +- Availability: v2 +- Mode: Application + +### asset_holding + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetBalance | uint64 | Amount of the asset unit held by this account | +| 1 | AssetFrozen | bool | Is the asset frozen or not | + + +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. + +## asset_params_get + +- Syntax: `asset_params_get F` ∋ F: [asset_params](#field-group-asset_params) +- Bytecode: 0x71 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from asset A. Y is 1 if A exists, else 0 +- Availability: v2 +- Mode: Application + +### asset_params + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetTotal | uint64 | Total number of units of this asset | +| 1 | AssetDecimals | uint64 | See AssetParams.Decimals | +| 2 | AssetDefaultFrozen | bool | Frozen by default or not | +| 3 | AssetUnitName | []byte | Asset unit name | +| 4 | AssetName | []byte | Asset name | +| 5 | AssetURL | []byte | URL with additional info about the asset | +| 6 | AssetMetadataHash | [32]byte | Arbitrary commitment | +| 7 | AssetManager | address | Manager address | +| 8 | AssetReserve | address | Reserve address | +| 9 | AssetFreeze | address | Freeze address | +| 10 | AssetClawback | address | Clawback address | + + +params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value. + +## min_balance + +- Bytecode: 0x78 +- Stack: ..., A: uint64 → ..., uint64 +- 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. +- Availability: v3 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## pushbytes + +- Syntax: `pushbytes BYTES` ∋ BYTES: a byte constant +- Bytecode: 0x80 {varuint length, bytes} +- Stack: ... → ..., []byte +- immediate BYTES +- Availability: v3 + +pushbytes args are not added to the bytecblock during assembly processes + +## pushint + +- Syntax: `pushint UINT` ∋ UINT: an int constant +- Bytecode: 0x81 {varuint} +- Stack: ... → ..., uint64 +- immediate UINT +- Availability: v3 + +pushint args are not added to the intcblock during assembly processes diff --git a/data/transactions/logic/TEAL_opcodes_v4.md b/data/transactions/logic/TEAL_opcodes_v4.md new file mode 100644 index 0000000000..96e51dee04 --- /dev/null +++ b/data/transactions/logic/TEAL_opcodes_v4.md @@ -0,0 +1,1029 @@ +# v4 Opcodes + +Ops have a 'cost' of 1 unless otherwise specified. + + +## err + +- Bytecode: 0x00 +- Stack: ... → _exits_ +- Fail immediately. + +## sha256 + +- Bytecode: 0x01 +- Stack: ..., A: []byte → ..., [32]byte +- SHA256 hash of value A, yields [32]byte +- **Cost**: 35 + +## keccak256 + +- Bytecode: 0x02 +- Stack: ..., A: []byte → ..., [32]byte +- Keccak256 hash of value A, yields [32]byte +- **Cost**: 130 + +## sha512_256 + +- Bytecode: 0x03 +- Stack: ..., A: []byte → ..., [32]byte +- SHA512_256 hash of value A, yields [32]byte +- **Cost**: 45 + +## ed25519verify + +- Bytecode: 0x04 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1} +- **Cost**: 1900 +- Mode: Signature + +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. + +## + + +- Bytecode: 0x08 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A plus B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`. + +## - + +- Bytecode: 0x09 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A minus B. Fail if B > A. + +## / + +- Bytecode: 0x0a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by B (truncated division). Fail if B == 0. + +`divmodw` is available to divide the two-element values produced by `mulw` and `addw`. + +## * + +- Bytecode: 0x0b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`. + +## < + +- Bytecode: 0x0c +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than B => {0 or 1} + +## > + +- Bytecode: 0x0d +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than B => {0 or 1} + +## <= + +- Bytecode: 0x0e +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than or equal to B => {0 or 1} + +## >= + +- Bytecode: 0x0f +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than or equal to B => {0 or 1} + +## && + +- Bytecode: 0x10 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero and B is not zero => {0 or 1} + +## || + +- Bytecode: 0x11 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero or B is not zero => {0 or 1} + +## == + +- Bytecode: 0x12 +- Stack: ..., A, B → ..., bool +- A is equal to B => {0 or 1} + +## != + +- Bytecode: 0x13 +- Stack: ..., A, B → ..., bool +- A is not equal to B => {0 or 1} + +## ! + +- Bytecode: 0x14 +- Stack: ..., A: uint64 → ..., uint64 +- A == 0 yields 1; else 0 + +## len + +- Bytecode: 0x15 +- Stack: ..., A: []byte → ..., uint64 +- yields length of byte value A + +## itob + +- Bytecode: 0x16 +- Stack: ..., A: uint64 → ..., []byte +- converts uint64 A to big-endian byte array, always of length 8 + +## btoi + +- Bytecode: 0x17 +- Stack: ..., A: []byte → ..., uint64 +- converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8. + +`btoi` fails if the input is longer than 8 bytes. + +## % + +- Bytecode: 0x18 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A modulo B. Fail if B == 0. + +## | + +- Bytecode: 0x19 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-or B + +## & + +- Bytecode: 0x1a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-and B + +## ^ + +- Bytecode: 0x1b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-xor B + +## ~ + +- Bytecode: 0x1c +- Stack: ..., A: uint64 → ..., uint64 +- bitwise invert value A + +## mulw + +- Bytecode: 0x1d +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low + +## addw + +- Bytecode: 0x1e +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits. +- Availability: v2 + +## divmodw + +- Bytecode: 0x1f +- Stack: ..., A: uint64, B: uint64, C: uint64, D: uint64 → ..., W: uint64, X: uint64, Y: uint64, Z: uint64 +- W,X = (A,B / C,D); Y,Z = (A,B modulo C,D) +- **Cost**: 20 +- Availability: v4 + +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. + +## intcblock + +- Syntax: `intcblock UINT ...` ∋ UINT ...: a block of int constant values +- Bytecode: 0x20 {varuint count, [varuint ...]} +- Stack: ... → ... +- prepare block of uint64 constants for use by intc + +`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. + +## intc + +- Syntax: `intc I` ∋ I: an index in the intcblock +- Bytecode: 0x21 {uint8} +- Stack: ... → ..., uint64 +- Ith constant from intcblock + +## intc_0 + +- Bytecode: 0x22 +- Stack: ... → ..., uint64 +- constant 0 from intcblock + +## intc_1 + +- Bytecode: 0x23 +- Stack: ... → ..., uint64 +- constant 1 from intcblock + +## intc_2 + +- Bytecode: 0x24 +- Stack: ... → ..., uint64 +- constant 2 from intcblock + +## intc_3 + +- Bytecode: 0x25 +- Stack: ... → ..., uint64 +- constant 3 from intcblock + +## bytecblock + +- Syntax: `bytecblock BYTES ...` ∋ BYTES ...: a block of byte constant values +- Bytecode: 0x26 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ... +- prepare block of byte-array constants for use by bytec + +`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. + +## bytec + +- Syntax: `bytec I` ∋ I: an index in the bytecblock +- Bytecode: 0x27 {uint8} +- Stack: ... → ..., []byte +- Ith constant from bytecblock + +## bytec_0 + +- Bytecode: 0x28 +- Stack: ... → ..., []byte +- constant 0 from bytecblock + +## bytec_1 + +- Bytecode: 0x29 +- Stack: ... → ..., []byte +- constant 1 from bytecblock + +## bytec_2 + +- Bytecode: 0x2a +- Stack: ... → ..., []byte +- constant 2 from bytecblock + +## bytec_3 + +- Bytecode: 0x2b +- Stack: ... → ..., []byte +- constant 3 from bytecblock + +## arg + +- Syntax: `arg N` ∋ N: an arg index +- Bytecode: 0x2c {uint8} +- Stack: ... → ..., []byte +- Nth LogicSig argument +- Mode: Signature + +## arg_0 + +- Bytecode: 0x2d +- Stack: ... → ..., []byte +- LogicSig argument 0 +- Mode: Signature + +## arg_1 + +- Bytecode: 0x2e +- Stack: ... → ..., []byte +- LogicSig argument 1 +- Mode: Signature + +## arg_2 + +- Bytecode: 0x2f +- Stack: ... → ..., []byte +- LogicSig argument 2 +- Mode: Signature + +## arg_3 + +- Bytecode: 0x30 +- Stack: ... → ..., []byte +- LogicSig argument 3 +- Mode: Signature + +## txn + +- Syntax: `txn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x31 {uint8} +- Stack: ... → ..., any +- field F of current transaction + +### txn + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | Sender | address | | 32 byte address | +| 1 | Fee | uint64 | | microalgos | +| 2 | FirstValid | uint64 | | round number | +| 4 | LastValid | uint64 | | round number | +| 5 | Note | []byte | | Any data up to 1024 bytes | +| 6 | Lease | [32]byte | | 32 byte lease value | +| 7 | Receiver | address | | 32 byte address | +| 8 | Amount | uint64 | | microalgos | +| 9 | CloseRemainderTo | address | | 32 byte address | +| 10 | VotePK | [32]byte | | 32 byte address | +| 11 | SelectionPK | [32]byte | | 32 byte address | +| 12 | VoteFirst | uint64 | | The first round that the participation key is valid. | +| 13 | VoteLast | uint64 | | The last round that the participation key is valid. | +| 14 | VoteKeyDilution | uint64 | | Dilution for the 2-level participation key | +| 15 | Type | []byte | | Transaction type as bytes | +| 16 | TypeEnum | uint64 | | Transaction type as integer | +| 17 | XferAsset | uint64 | | Asset ID | +| 18 | AssetAmount | uint64 | | value in Asset's units | +| 19 | AssetSender | address | | 32 byte address. Source of assets if Sender is the Asset's Clawback address. | +| 20 | AssetReceiver | address | | 32 byte address | +| 21 | AssetCloseTo | address | | 32 byte address | +| 22 | GroupIndex | uint64 | | Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1 | +| 23 | TxID | [32]byte | | The computed ID for this transaction. 32 bytes. | +| 24 | ApplicationID | uint64 | v2 | ApplicationID from ApplicationCall transaction | +| 25 | OnCompletion | uint64 | v2 | ApplicationCall transaction on completion action | +| 27 | NumAppArgs | uint64 | v2 | Number of ApplicationArgs | +| 29 | NumAccounts | uint64 | v2 | Number of Accounts | +| 30 | ApprovalProgram | []byte | v2 | Approval program | +| 31 | ClearStateProgram | []byte | v2 | Clear state program | +| 32 | RekeyTo | address | v2 | 32 byte Sender's new AuthAddr | +| 33 | ConfigAsset | uint64 | v2 | Asset ID in asset config transaction | +| 34 | ConfigAssetTotal | uint64 | v2 | Total number of units of this asset created | +| 35 | ConfigAssetDecimals | uint64 | v2 | Number of digits to display after the decimal place when displaying the asset | +| 36 | ConfigAssetDefaultFrozen | bool | v2 | Whether the asset's slots are frozen by default or not, 0 or 1 | +| 37 | ConfigAssetUnitName | []byte | v2 | Unit name of the asset | +| 38 | ConfigAssetName | []byte | v2 | The asset name | +| 39 | ConfigAssetURL | []byte | v2 | URL | +| 40 | ConfigAssetMetadataHash | [32]byte | v2 | 32 byte commitment to unspecified asset metadata | +| 41 | ConfigAssetManager | address | v2 | 32 byte address | +| 42 | ConfigAssetReserve | address | v2 | 32 byte address | +| 43 | ConfigAssetFreeze | address | v2 | 32 byte address | +| 44 | ConfigAssetClawback | address | v2 | 32 byte address | +| 45 | FreezeAsset | uint64 | v2 | Asset ID being frozen or un-frozen | +| 46 | FreezeAssetAccount | address | v2 | 32 byte address of the account whose asset slot is being frozen or un-frozen | +| 47 | FreezeAssetFrozen | bool | v2 | The new frozen value, 0 or 1 | +| 49 | NumAssets | uint64 | v3 | Number of Assets | +| 51 | NumApplications | uint64 | v3 | Number of Applications | +| 52 | GlobalNumUint | uint64 | v3 | Number of global state integers in ApplicationCall | +| 53 | GlobalNumByteSlice | uint64 | v3 | Number of global state byteslices in ApplicationCall | +| 54 | LocalNumUint | uint64 | v3 | Number of local state integers in ApplicationCall | +| 55 | LocalNumByteSlice | uint64 | v3 | Number of local state byteslices in ApplicationCall | +| 56 | ExtraProgramPages | uint64 | v4 | Number of additional pages for each of the application's approval and clear state programs. An ExtraProgramPages of 1 means 2048 more total bytes, or 1024 for each program. | + + +## global + +- Syntax: `global F` ∋ F: [global](#field-group-global) +- Bytecode: 0x32 {uint8} +- Stack: ... → ..., any +- global field F + +### global + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | MinTxnFee | uint64 | | microalgos | +| 1 | MinBalance | uint64 | | microalgos | +| 2 | MaxTxnLife | uint64 | | rounds | +| 3 | ZeroAddress | address | | 32 byte address of all zero bytes | +| 4 | GroupSize | uint64 | | Number of transactions in this atomic transaction group. At least 1 | +| 5 | LogicSigVersion | uint64 | v2 | Maximum supported version | +| 6 | Round | uint64 | v2 | Current round number. Application mode only. | +| 7 | LatestTimestamp | uint64 | v2 | Last confirmed block UNIX timestamp. Fails if negative. Application mode only. | +| 8 | CurrentApplicationID | uint64 | v2 | ID of current application executing. Application mode only. | +| 9 | CreatorAddress | address | v3 | Address of the creator of the current application. Application mode only. | + + +## gtxn + +- Syntax: `gtxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0x33 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the current group + +for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`. + +## load + +- Syntax: `load I` ∋ I: position in scratch space to load from +- Bytecode: 0x34 {uint8} +- Stack: ... → ..., any +- Ith scratch space value. All scratch spaces are 0 at program start. + +## store + +- Syntax: `store I` ∋ I: position in scratch space to store to +- Bytecode: 0x35 {uint8} +- Stack: ..., A → ... +- store A to the Ith scratch space + +## txna + +- Syntax: `txna F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x36 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the current transaction
`txna` can be called using `txn` with 2 immediates. +- Availability: v2 + +### txna + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 26 | ApplicationArgs | []byte | v2 | Arguments passed to the application in the ApplicationCall transaction | +| 28 | Accounts | address | v2 | Accounts listed in the ApplicationCall transaction | +| 48 | Assets | uint64 | v3 | Foreign Assets listed in the ApplicationCall transaction | +| 50 | Applications | uint64 | v3 | Foreign Apps listed in the ApplicationCall transaction | + + +## gtxna + +- Syntax: `gtxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x37 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the current group
`gtxna` can be called using `gtxn` with 3 immediates. +- Availability: v2 + +## gtxns + +- Syntax: `gtxns F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x38 {uint8} +- Stack: ..., A: uint64 → ..., any +- field F of the Ath transaction in the current group +- Availability: v3 + +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. + +## gtxnsa + +- Syntax: `gtxnsa F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x39 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith value of the array field F from the Ath transaction in the current group
`gtxnsa` can be called using `gtxns` with 2 immediates. +- Availability: v3 + +## gload + +- Syntax: `gload T I` ∋ T: transaction group index, I: position in scratch space to load from +- Bytecode: 0x3a {uint8}, {uint8} +- Stack: ... → ..., any +- Ith scratch space value of the Tth transaction in the current group +- Availability: v4 +- Mode: Application + +`gload` fails unless the requested transaction is an ApplicationCall and T < GroupIndex. + +## gloads + +- Syntax: `gloads I` ∋ I: position in scratch space to load from +- Bytecode: 0x3b {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith scratch space value of the Ath transaction in the current group +- Availability: v4 +- Mode: Application + +`gloads` fails unless the requested transaction is an ApplicationCall and A < GroupIndex. + +## gaid + +- Syntax: `gaid T` ∋ T: transaction group index +- Bytecode: 0x3c {uint8} +- Stack: ... → ..., uint64 +- ID of the asset or application created in the Tth transaction of the current group +- Availability: v4 +- Mode: Application + +`gaid` fails unless the requested transaction created an asset or application and T < GroupIndex. + +## gaids + +- Bytecode: 0x3d +- Stack: ..., A: uint64 → ..., uint64 +- ID of the asset or application created in the Ath transaction of the current group +- Availability: v4 +- Mode: Application + +`gaids` fails unless the requested transaction created an asset or application and A < GroupIndex. + +## bnz + +- Syntax: `bnz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x40 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is not zero + +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. + +At 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.) + +## bz + +- Syntax: `bz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x41 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is zero +- Availability: v2 + +See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`. + +## b + +- Syntax: `b TARGET` ∋ TARGET: branch offset +- Bytecode: 0x42 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET +- Availability: v2 + +See `bnz` for details on how branches work. `b` always jumps to the offset. + +## return + +- Bytecode: 0x43 +- Stack: ..., A: uint64 → _exits_ +- use A as success value; end +- Availability: v2 + +## assert + +- Bytecode: 0x44 +- Stack: ..., A: uint64 → ... +- immediately fail unless A is a non-zero number +- Availability: v3 + +## pop + +- Bytecode: 0x48 +- Stack: ..., A → ... +- discard A + +## dup + +- Bytecode: 0x49 +- Stack: ..., A → ..., A, A +- duplicate A + +## dup2 + +- Bytecode: 0x4a +- Stack: ..., A, B → ..., A, B, A, B +- duplicate A and B +- Availability: v2 + +## dig + +- Syntax: `dig N` ∋ N: depth +- Bytecode: 0x4b {uint8} +- Stack: ..., A, [N items] → ..., A, [N items], A +- Nth value from the top of the stack. dig 0 is equivalent to dup +- Availability: v3 + +## swap + +- Bytecode: 0x4c +- Stack: ..., A, B → ..., B, A +- swaps A and B on stack +- Availability: v3 + +## select + +- Bytecode: 0x4d +- Stack: ..., A, B, C: uint64 → ..., A or B +- selects one of two values based on top-of-stack: B if C != 0, else A +- Availability: v3 + +## concat + +- Bytecode: 0x50 +- Stack: ..., A: []byte, B: []byte → ..., []byte +- join A and B +- Availability: v2 + +`concat` fails if the result would be greater than 4096 bytes. + +## substring + +- Syntax: `substring S E` ∋ S: start position, E: end position +- Bytecode: 0x51 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v2 + +## substring3 + +- Bytecode: 0x52 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v2 + +## getbit + +- Bytecode: 0x53 +- Stack: ..., A, B: uint64 → ..., uint64 +- 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 +- Availability: v3 + +see explanation of bit ordering in setbit + +## setbit + +- Bytecode: 0x54 +- Stack: ..., A, B: uint64, C: uint64 → ..., any +- 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 +- Availability: v3 + +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. + +## getbyte + +- Bytecode: 0x55 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails +- Availability: v3 + +## setbyte + +- Bytecode: 0x56 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v3 + +## balance + +- Bytecode: 0x60 +- Stack: ..., A → ..., uint64 +- 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` +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## app_opted_in + +- Bytecode: 0x61 +- Stack: ..., A, B: uint64 → ..., bool +- 1 if account A is opted in to application B, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_get + +- Bytecode: 0x62 +- Stack: ..., A, B: []byte → ..., any +- local state of the key B in the current application in account A +- Availability: v2 +- Mode: Application + +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. + +## app_local_get_ex + +- Bytecode: 0x63 +- Stack: ..., A, B: uint64, C: []byte → ..., X: any, Y: bool +- X is the local state of application B, key C in account A. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_global_get + +- Bytecode: 0x64 +- Stack: ..., A: []byte → ..., any +- global state of the key A in the current application +- Availability: v2 +- Mode: Application + +params: state key. Return: value. The value is zero (of type uint64) if the key does not exist. + +## app_global_get_ex + +- Bytecode: 0x65 +- Stack: ..., A: uint64, B: []byte → ..., X: any, Y: bool +- X is the global state of application A, key B. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_put + +- Bytecode: 0x66 +- Stack: ..., A, B: []byte, C → ... +- write C to key B in account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value. + +## app_global_put + +- Bytecode: 0x67 +- Stack: ..., A: []byte, B → ... +- write B to key A in the global state of the current application +- Availability: v2 +- Mode: Application + +## app_local_del + +- Bytecode: 0x68 +- Stack: ..., A, B: []byte → ... +- delete key B from account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. + +Deleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.) + +## app_global_del + +- Bytecode: 0x69 +- Stack: ..., A: []byte → ... +- delete key A from the global state of the current application +- Availability: v2 +- Mode: Application + +params: state key. + +Deleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.) + +## asset_holding_get + +- Syntax: `asset_holding_get F` ∋ F: [asset_holding](#field-group-asset_holding) +- Bytecode: 0x70 {uint8} +- Stack: ..., A, B: uint64 → ..., X: any, Y: bool +- X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0 +- Availability: v2 +- Mode: Application + +### asset_holding + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetBalance | uint64 | Amount of the asset unit held by this account | +| 1 | AssetFrozen | bool | Is the asset frozen or not | + + +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. + +## asset_params_get + +- Syntax: `asset_params_get F` ∋ F: [asset_params](#field-group-asset_params) +- Bytecode: 0x71 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from asset A. Y is 1 if A exists, else 0 +- Availability: v2 +- Mode: Application + +### asset_params + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetTotal | uint64 | Total number of units of this asset | +| 1 | AssetDecimals | uint64 | See AssetParams.Decimals | +| 2 | AssetDefaultFrozen | bool | Frozen by default or not | +| 3 | AssetUnitName | []byte | Asset unit name | +| 4 | AssetName | []byte | Asset name | +| 5 | AssetURL | []byte | URL with additional info about the asset | +| 6 | AssetMetadataHash | [32]byte | Arbitrary commitment | +| 7 | AssetManager | address | Manager address | +| 8 | AssetReserve | address | Reserve address | +| 9 | AssetFreeze | address | Freeze address | +| 10 | AssetClawback | address | Clawback address | + + +params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value. + +## min_balance + +- Bytecode: 0x78 +- Stack: ..., A → ..., uint64 +- 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. +- Availability: v3 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## pushbytes + +- Syntax: `pushbytes BYTES` ∋ BYTES: a byte constant +- Bytecode: 0x80 {varuint length, bytes} +- Stack: ... → ..., []byte +- immediate BYTES +- Availability: v3 + +pushbytes args are not added to the bytecblock during assembly processes + +## pushint + +- Syntax: `pushint UINT` ∋ UINT: an int constant +- Bytecode: 0x81 {varuint} +- Stack: ... → ..., uint64 +- immediate UINT +- Availability: v3 + +pushint args are not added to the intcblock during assembly processes + +## callsub + +- Syntax: `callsub TARGET` ∋ TARGET: branch offset +- Bytecode: 0x88 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET, saving the next instruction on the call stack +- Availability: v4 + +The call stack is separate from the data stack. Only `callsub`, `retsub`, and `proto` manipulate it. + +## retsub + +- Bytecode: 0x89 +- Stack: ... → ... +- pop the top instruction from the call stack and branch to it +- Availability: v4 + +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. + +## shl + +- Bytecode: 0x90 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times 2^B, modulo 2^64 +- Availability: v4 + +## shr + +- Bytecode: 0x91 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by 2^B +- Availability: v4 + +## sqrt + +- Bytecode: 0x92 +- Stack: ..., A: uint64 → ..., uint64 +- The largest integer I such that I^2 <= A +- **Cost**: 4 +- Availability: v4 + +## bitlen + +- Bytecode: 0x93 +- Stack: ..., A → ..., uint64 +- 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 +- Availability: v4 + +bitlen interprets arrays as big-endian integers, unlike setbit/getbit + +## exp + +- Bytecode: 0x94 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A raised to the Bth power. Fail if A == B == 0 and on overflow +- Availability: v4 + +## expw + +- Bytecode: 0x95 +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- 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 +- **Cost**: 10 +- Availability: v4 + +## b+ + +- Bytecode: 0xa0 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A plus B. A and B are interpreted as big-endian unsigned integers +- **Cost**: 10 +- Availability: v4 + +## b- + +- Bytecode: 0xa1 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow. +- **Cost**: 10 +- Availability: v4 + +## b/ + +- Bytecode: 0xa2 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b* + +- Bytecode: 0xa3 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A times B. A and B are interpreted as big-endian unsigned integers. +- **Cost**: 20 +- Availability: v4 + +## b< + +- Bytecode: 0xa4 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b> + +- Bytecode: 0xa5 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b<= + +- Bytecode: 0xa6 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b>= + +- Bytecode: 0xa7 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b== + +- Bytecode: 0xa8 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b!= + +- Bytecode: 0xa9 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b% + +- Bytecode: 0xaa +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b| + +- Bytecode: 0xab +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-or B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b& + +- Bytecode: 0xac +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-and B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b^ + +- Bytecode: 0xad +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-xor B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b~ + +- Bytecode: 0xae +- Stack: ..., A: []byte → ..., []byte +- A with all bits inverted +- **Cost**: 4 +- Availability: v4 + +## bzero + +- Bytecode: 0xaf +- Stack: ..., A: uint64 → ..., []byte +- zero filled byte-array of length A +- Availability: v4 diff --git a/data/transactions/logic/TEAL_opcodes_v5.md b/data/transactions/logic/TEAL_opcodes_v5.md new file mode 100644 index 0000000000..012d504ce1 --- /dev/null +++ b/data/transactions/logic/TEAL_opcodes_v5.md @@ -0,0 +1,1263 @@ +# v5 Opcodes + +Ops have a 'cost' of 1 unless otherwise specified. + + +## err + +- Bytecode: 0x00 +- Stack: ... → _exits_ +- Fail immediately. + +## sha256 + +- Bytecode: 0x01 +- Stack: ..., A: []byte → ..., [32]byte +- SHA256 hash of value A, yields [32]byte +- **Cost**: 35 + +## keccak256 + +- Bytecode: 0x02 +- Stack: ..., A: []byte → ..., [32]byte +- Keccak256 hash of value A, yields [32]byte +- **Cost**: 130 + +## sha512_256 + +- Bytecode: 0x03 +- Stack: ..., A: []byte → ..., [32]byte +- SHA512_256 hash of value A, yields [32]byte +- **Cost**: 45 + +## ed25519verify + +- Bytecode: 0x04 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1} +- **Cost**: 1900 + +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. + +## ecdsa_verify + +- Syntax: `ecdsa_verify V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x05 {uint8} +- Stack: ..., A: []byte, B: []byte, C: []byte, D: []byte, E: []byte → ..., bool +- for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1} +- **Cost**: Secp256k1=1700 +- Availability: v5 + +### ECDSA + +Curves + +| Index | Name | Notes | +| - | ------ | --------- | +| 0 | Secp256k1 | secp256k1 curve, used in Bitcoin | + + +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. + +## ecdsa_pk_decompress + +- Syntax: `ecdsa_pk_decompress V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x06 {uint8} +- Stack: ..., A: []byte → ..., X: []byte, Y: []byte +- decompress pubkey A into components X, Y +- **Cost**: Secp256k1=650 +- Availability: v5 + +The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded. + +## ecdsa_pk_recover + +- Syntax: `ecdsa_pk_recover V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x07 {uint8} +- Stack: ..., A: []byte, B: uint64, C: []byte, D: []byte → ..., X: []byte, Y: []byte +- for (data A, recovery id B, signature C, D) recover a public key +- **Cost**: 2000 +- Availability: v5 + +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. + +## + + +- Bytecode: 0x08 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A plus B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`. + +## - + +- Bytecode: 0x09 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A minus B. Fail if B > A. + +## / + +- Bytecode: 0x0a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by B (truncated division). Fail if B == 0. + +`divmodw` is available to divide the two-element values produced by `mulw` and `addw`. + +## * + +- Bytecode: 0x0b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`. + +## < + +- Bytecode: 0x0c +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than B => {0 or 1} + +## > + +- Bytecode: 0x0d +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than B => {0 or 1} + +## <= + +- Bytecode: 0x0e +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than or equal to B => {0 or 1} + +## >= + +- Bytecode: 0x0f +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than or equal to B => {0 or 1} + +## && + +- Bytecode: 0x10 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero and B is not zero => {0 or 1} + +## || + +- Bytecode: 0x11 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero or B is not zero => {0 or 1} + +## == + +- Bytecode: 0x12 +- Stack: ..., A, B → ..., bool +- A is equal to B => {0 or 1} + +## != + +- Bytecode: 0x13 +- Stack: ..., A, B → ..., bool +- A is not equal to B => {0 or 1} + +## ! + +- Bytecode: 0x14 +- Stack: ..., A: uint64 → ..., uint64 +- A == 0 yields 1; else 0 + +## len + +- Bytecode: 0x15 +- Stack: ..., A: []byte → ..., uint64 +- yields length of byte value A + +## itob + +- Bytecode: 0x16 +- Stack: ..., A: uint64 → ..., []byte +- converts uint64 A to big-endian byte array, always of length 8 + +## btoi + +- Bytecode: 0x17 +- Stack: ..., A: []byte → ..., uint64 +- converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8. + +`btoi` fails if the input is longer than 8 bytes. + +## % + +- Bytecode: 0x18 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A modulo B. Fail if B == 0. + +## | + +- Bytecode: 0x19 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-or B + +## & + +- Bytecode: 0x1a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-and B + +## ^ + +- Bytecode: 0x1b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-xor B + +## ~ + +- Bytecode: 0x1c +- Stack: ..., A: uint64 → ..., uint64 +- bitwise invert value A + +## mulw + +- Bytecode: 0x1d +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low + +## addw + +- Bytecode: 0x1e +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits. +- Availability: v2 + +## divmodw + +- Bytecode: 0x1f +- Stack: ..., A: uint64, B: uint64, C: uint64, D: uint64 → ..., W: uint64, X: uint64, Y: uint64, Z: uint64 +- W,X = (A,B / C,D); Y,Z = (A,B modulo C,D) +- **Cost**: 20 +- Availability: v4 + +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. + +## intcblock + +- Syntax: `intcblock UINT ...` ∋ UINT ...: a block of int constant values +- Bytecode: 0x20 {varuint count, [varuint ...]} +- Stack: ... → ... +- prepare block of uint64 constants for use by intc + +`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. + +## intc + +- Syntax: `intc I` ∋ I: an index in the intcblock +- Bytecode: 0x21 {uint8} +- Stack: ... → ..., uint64 +- Ith constant from intcblock + +## intc_0 + +- Bytecode: 0x22 +- Stack: ... → ..., uint64 +- constant 0 from intcblock + +## intc_1 + +- Bytecode: 0x23 +- Stack: ... → ..., uint64 +- constant 1 from intcblock + +## intc_2 + +- Bytecode: 0x24 +- Stack: ... → ..., uint64 +- constant 2 from intcblock + +## intc_3 + +- Bytecode: 0x25 +- Stack: ... → ..., uint64 +- constant 3 from intcblock + +## bytecblock + +- Syntax: `bytecblock BYTES ...` ∋ BYTES ...: a block of byte constant values +- Bytecode: 0x26 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ... +- prepare block of byte-array constants for use by bytec + +`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. + +## bytec + +- Syntax: `bytec I` ∋ I: an index in the bytecblock +- Bytecode: 0x27 {uint8} +- Stack: ... → ..., []byte +- Ith constant from bytecblock + +## bytec_0 + +- Bytecode: 0x28 +- Stack: ... → ..., []byte +- constant 0 from bytecblock + +## bytec_1 + +- Bytecode: 0x29 +- Stack: ... → ..., []byte +- constant 1 from bytecblock + +## bytec_2 + +- Bytecode: 0x2a +- Stack: ... → ..., []byte +- constant 2 from bytecblock + +## bytec_3 + +- Bytecode: 0x2b +- Stack: ... → ..., []byte +- constant 3 from bytecblock + +## arg + +- Syntax: `arg N` ∋ N: an arg index +- Bytecode: 0x2c {uint8} +- Stack: ... → ..., []byte +- Nth LogicSig argument +- Mode: Signature + +## arg_0 + +- Bytecode: 0x2d +- Stack: ... → ..., []byte +- LogicSig argument 0 +- Mode: Signature + +## arg_1 + +- Bytecode: 0x2e +- Stack: ... → ..., []byte +- LogicSig argument 1 +- Mode: Signature + +## arg_2 + +- Bytecode: 0x2f +- Stack: ... → ..., []byte +- LogicSig argument 2 +- Mode: Signature + +## arg_3 + +- Bytecode: 0x30 +- Stack: ... → ..., []byte +- LogicSig argument 3 +- Mode: Signature + +## txn + +- Syntax: `txn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x31 {uint8} +- Stack: ... → ..., any +- field F of current transaction + +### txn + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | Sender | address | | 32 byte address | +| 1 | Fee | uint64 | | microalgos | +| 2 | FirstValid | uint64 | | round number | +| 4 | LastValid | uint64 | | round number | +| 5 | Note | []byte | | Any data up to 1024 bytes | +| 6 | Lease | [32]byte | | 32 byte lease value | +| 7 | Receiver | address | | 32 byte address | +| 8 | Amount | uint64 | | microalgos | +| 9 | CloseRemainderTo | address | | 32 byte address | +| 10 | VotePK | [32]byte | | 32 byte address | +| 11 | SelectionPK | [32]byte | | 32 byte address | +| 12 | VoteFirst | uint64 | | The first round that the participation key is valid. | +| 13 | VoteLast | uint64 | | The last round that the participation key is valid. | +| 14 | VoteKeyDilution | uint64 | | Dilution for the 2-level participation key | +| 15 | Type | []byte | | Transaction type as bytes | +| 16 | TypeEnum | uint64 | | Transaction type as integer | +| 17 | XferAsset | uint64 | | Asset ID | +| 18 | AssetAmount | uint64 | | value in Asset's units | +| 19 | AssetSender | address | | 32 byte address. Source of assets if Sender is the Asset's Clawback address. | +| 20 | AssetReceiver | address | | 32 byte address | +| 21 | AssetCloseTo | address | | 32 byte address | +| 22 | GroupIndex | uint64 | | Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1 | +| 23 | TxID | [32]byte | | The computed ID for this transaction. 32 bytes. | +| 24 | ApplicationID | uint64 | v2 | ApplicationID from ApplicationCall transaction | +| 25 | OnCompletion | uint64 | v2 | ApplicationCall transaction on completion action | +| 27 | NumAppArgs | uint64 | v2 | Number of ApplicationArgs | +| 29 | NumAccounts | uint64 | v2 | Number of Accounts | +| 30 | ApprovalProgram | []byte | v2 | Approval program | +| 31 | ClearStateProgram | []byte | v2 | Clear state program | +| 32 | RekeyTo | address | v2 | 32 byte Sender's new AuthAddr | +| 33 | ConfigAsset | uint64 | v2 | Asset ID in asset config transaction | +| 34 | ConfigAssetTotal | uint64 | v2 | Total number of units of this asset created | +| 35 | ConfigAssetDecimals | uint64 | v2 | Number of digits to display after the decimal place when displaying the asset | +| 36 | ConfigAssetDefaultFrozen | bool | v2 | Whether the asset's slots are frozen by default or not, 0 or 1 | +| 37 | ConfigAssetUnitName | []byte | v2 | Unit name of the asset | +| 38 | ConfigAssetName | []byte | v2 | The asset name | +| 39 | ConfigAssetURL | []byte | v2 | URL | +| 40 | ConfigAssetMetadataHash | [32]byte | v2 | 32 byte commitment to unspecified asset metadata | +| 41 | ConfigAssetManager | address | v2 | 32 byte address | +| 42 | ConfigAssetReserve | address | v2 | 32 byte address | +| 43 | ConfigAssetFreeze | address | v2 | 32 byte address | +| 44 | ConfigAssetClawback | address | v2 | 32 byte address | +| 45 | FreezeAsset | uint64 | v2 | Asset ID being frozen or un-frozen | +| 46 | FreezeAssetAccount | address | v2 | 32 byte address of the account whose asset slot is being frozen or un-frozen | +| 47 | FreezeAssetFrozen | bool | v2 | The new frozen value, 0 or 1 | +| 49 | NumAssets | uint64 | v3 | Number of Assets | +| 51 | NumApplications | uint64 | v3 | Number of Applications | +| 52 | GlobalNumUint | uint64 | v3 | Number of global state integers in ApplicationCall | +| 53 | GlobalNumByteSlice | uint64 | v3 | Number of global state byteslices in ApplicationCall | +| 54 | LocalNumUint | uint64 | v3 | Number of local state integers in ApplicationCall | +| 55 | LocalNumByteSlice | uint64 | v3 | Number of local state byteslices in ApplicationCall | +| 56 | ExtraProgramPages | uint64 | v4 | Number of additional pages for each of the application's approval and clear state programs. An ExtraProgramPages of 1 means 2048 more total bytes, or 1024 for each program. | +| 57 | Nonparticipation | bool | v5 | Marks an account nonparticipating for rewards | +| 59 | NumLogs | uint64 | v5 | Number of Logs (only with `itxn` in v5). Application mode only | +| 60 | CreatedAssetID | uint64 | v5 | Asset ID allocated by the creation of an ASA (only with `itxn` in v5). Application mode only | +| 61 | CreatedApplicationID | uint64 | v5 | ApplicationID allocated by the creation of an application (only with `itxn` in v5). Application mode only | + + +## global + +- Syntax: `global F` ∋ F: [global](#field-group-global) +- Bytecode: 0x32 {uint8} +- Stack: ... → ..., any +- global field F + +### global + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | MinTxnFee | uint64 | | microalgos | +| 1 | MinBalance | uint64 | | microalgos | +| 2 | MaxTxnLife | uint64 | | rounds | +| 3 | ZeroAddress | address | | 32 byte address of all zero bytes | +| 4 | GroupSize | uint64 | | Number of transactions in this atomic transaction group. At least 1 | +| 5 | LogicSigVersion | uint64 | v2 | Maximum supported version | +| 6 | Round | uint64 | v2 | Current round number. Application mode only. | +| 7 | LatestTimestamp | uint64 | v2 | Last confirmed block UNIX timestamp. Fails if negative. Application mode only. | +| 8 | CurrentApplicationID | uint64 | v2 | ID of current application executing. Application mode only. | +| 9 | CreatorAddress | address | v3 | Address of the creator of the current application. Application mode only. | +| 10 | CurrentApplicationAddress | address | v5 | Address that the current application controls. Application mode only. | +| 11 | GroupID | [32]byte | v5 | ID of the transaction group. 32 zero bytes if the transaction is not part of a group. | + + +## gtxn + +- Syntax: `gtxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0x33 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the current group + +for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`. + +## load + +- Syntax: `load I` ∋ I: position in scratch space to load from +- Bytecode: 0x34 {uint8} +- Stack: ... → ..., any +- Ith scratch space value. All scratch spaces are 0 at program start. + +## store + +- Syntax: `store I` ∋ I: position in scratch space to store to +- Bytecode: 0x35 {uint8} +- Stack: ..., A → ... +- store A to the Ith scratch space + +## txna + +- Syntax: `txna F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x36 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the current transaction
`txna` can be called using `txn` with 2 immediates. +- Availability: v2 + +### txna + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 26 | ApplicationArgs | []byte | v2 | Arguments passed to the application in the ApplicationCall transaction | +| 28 | Accounts | address | v2 | Accounts listed in the ApplicationCall transaction | +| 48 | Assets | uint64 | v3 | Foreign Assets listed in the ApplicationCall transaction | +| 50 | Applications | uint64 | v3 | Foreign Apps listed in the ApplicationCall transaction | +| 58 | Logs | []byte | v5 | Log messages emitted by an application call (only with `itxn` in v5). Application mode only | + + +## gtxna + +- Syntax: `gtxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x37 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the current group
`gtxna` can be called using `gtxn` with 3 immediates. +- Availability: v2 + +## gtxns + +- Syntax: `gtxns F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x38 {uint8} +- Stack: ..., A: uint64 → ..., any +- field F of the Ath transaction in the current group +- Availability: v3 + +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. + +## gtxnsa + +- Syntax: `gtxnsa F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x39 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith value of the array field F from the Ath transaction in the current group
`gtxnsa` can be called using `gtxns` with 2 immediates. +- Availability: v3 + +## gload + +- Syntax: `gload T I` ∋ T: transaction group index, I: position in scratch space to load from +- Bytecode: 0x3a {uint8}, {uint8} +- Stack: ... → ..., any +- Ith scratch space value of the Tth transaction in the current group +- Availability: v4 +- Mode: Application + +`gload` fails unless the requested transaction is an ApplicationCall and T < GroupIndex. + +## gloads + +- Syntax: `gloads I` ∋ I: position in scratch space to load from +- Bytecode: 0x3b {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith scratch space value of the Ath transaction in the current group +- Availability: v4 +- Mode: Application + +`gloads` fails unless the requested transaction is an ApplicationCall and A < GroupIndex. + +## gaid + +- Syntax: `gaid T` ∋ T: transaction group index +- Bytecode: 0x3c {uint8} +- Stack: ... → ..., uint64 +- ID of the asset or application created in the Tth transaction of the current group +- Availability: v4 +- Mode: Application + +`gaid` fails unless the requested transaction created an asset or application and T < GroupIndex. + +## gaids + +- Bytecode: 0x3d +- Stack: ..., A: uint64 → ..., uint64 +- ID of the asset or application created in the Ath transaction of the current group +- Availability: v4 +- Mode: Application + +`gaids` fails unless the requested transaction created an asset or application and A < GroupIndex. + +## loads + +- Bytecode: 0x3e +- Stack: ..., A: uint64 → ..., any +- Ath scratch space value. All scratch spaces are 0 at program start. +- Availability: v5 + +## stores + +- Bytecode: 0x3f +- Stack: ..., A: uint64, B → ... +- store B to the Ath scratch space +- Availability: v5 + +## bnz + +- Syntax: `bnz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x40 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is not zero + +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. + +At 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.) + +## bz + +- Syntax: `bz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x41 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is zero +- Availability: v2 + +See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`. + +## b + +- Syntax: `b TARGET` ∋ TARGET: branch offset +- Bytecode: 0x42 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET +- Availability: v2 + +See `bnz` for details on how branches work. `b` always jumps to the offset. + +## return + +- Bytecode: 0x43 +- Stack: ..., A: uint64 → _exits_ +- use A as success value; end +- Availability: v2 + +## assert + +- Bytecode: 0x44 +- Stack: ..., A: uint64 → ... +- immediately fail unless A is a non-zero number +- Availability: v3 + +## pop + +- Bytecode: 0x48 +- Stack: ..., A → ... +- discard A + +## dup + +- Bytecode: 0x49 +- Stack: ..., A → ..., A, A +- duplicate A + +## dup2 + +- Bytecode: 0x4a +- Stack: ..., A, B → ..., A, B, A, B +- duplicate A and B +- Availability: v2 + +## dig + +- Syntax: `dig N` ∋ N: depth +- Bytecode: 0x4b {uint8} +- Stack: ..., A, [N items] → ..., A, [N items], A +- Nth value from the top of the stack. dig 0 is equivalent to dup +- Availability: v3 + +## swap + +- Bytecode: 0x4c +- Stack: ..., A, B → ..., B, A +- swaps A and B on stack +- Availability: v3 + +## select + +- Bytecode: 0x4d +- Stack: ..., A, B, C: uint64 → ..., A or B +- selects one of two values based on top-of-stack: B if C != 0, else A +- Availability: v3 + +## cover + +- Syntax: `cover N` ∋ N: depth +- Bytecode: 0x4e {uint8} +- Stack: ..., [N items], A → ..., A, [N items] +- remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth <= N. +- Availability: v5 + +## uncover + +- Syntax: `uncover N` ∋ N: depth +- Bytecode: 0x4f {uint8} +- Stack: ..., A, [N items] → ..., [N items], A +- 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. +- Availability: v5 + +## concat + +- Bytecode: 0x50 +- Stack: ..., A: []byte, B: []byte → ..., []byte +- join A and B +- Availability: v2 + +`concat` fails if the result would be greater than 4096 bytes. + +## substring + +- Syntax: `substring S E` ∋ S: start position, E: end position +- Bytecode: 0x51 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v2 + +## substring3 + +- Bytecode: 0x52 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v2 + +## getbit + +- Bytecode: 0x53 +- Stack: ..., A, B: uint64 → ..., uint64 +- 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 +- Availability: v3 + +see explanation of bit ordering in setbit + +## setbit + +- Bytecode: 0x54 +- Stack: ..., A, B: uint64, C: uint64 → ..., any +- 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 +- Availability: v3 + +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. + +## getbyte + +- Bytecode: 0x55 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails +- Availability: v3 + +## setbyte + +- Bytecode: 0x56 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v3 + +## extract + +- Syntax: `extract S L` ∋ S: start position, L: length +- Bytecode: 0x57 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v5 + +## extract3 + +- Bytecode: 0x58 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- A range of bytes from A starting at B up to but not including B+C. If B+C is larger than the array length, the program fails
`extract3` can be called using `extract` with no immediates. +- Availability: v5 + +## extract_uint16 + +- Bytecode: 0x59 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- 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 +- Availability: v5 + +## extract_uint32 + +- Bytecode: 0x5a +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- 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 +- Availability: v5 + +## extract_uint64 + +- Bytecode: 0x5b +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- A uint64 formed from a range of big-endian bytes from A starting at B up to but not including B+8. If B+8 is larger than the array length, the program fails +- Availability: v5 + +## balance + +- Bytecode: 0x60 +- Stack: ..., A → ..., uint64 +- 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` +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## app_opted_in + +- Bytecode: 0x61 +- Stack: ..., A, B: uint64 → ..., bool +- 1 if account A is opted in to application B, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_get + +- Bytecode: 0x62 +- Stack: ..., A, B: []byte → ..., any +- local state of the key B in the current application in account A +- Availability: v2 +- Mode: Application + +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. + +## app_local_get_ex + +- Bytecode: 0x63 +- Stack: ..., A, B: uint64, C: []byte → ..., X: any, Y: bool +- X is the local state of application B, key C in account A. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_global_get + +- Bytecode: 0x64 +- Stack: ..., A: []byte → ..., any +- global state of the key A in the current application +- Availability: v2 +- Mode: Application + +params: state key. Return: value. The value is zero (of type uint64) if the key does not exist. + +## app_global_get_ex + +- Bytecode: 0x65 +- Stack: ..., A: uint64, B: []byte → ..., X: any, Y: bool +- X is the global state of application A, key B. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_put + +- Bytecode: 0x66 +- Stack: ..., A, B: []byte, C → ... +- write C to key B in account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value. + +## app_global_put + +- Bytecode: 0x67 +- Stack: ..., A: []byte, B → ... +- write B to key A in the global state of the current application +- Availability: v2 +- Mode: Application + +## app_local_del + +- Bytecode: 0x68 +- Stack: ..., A, B: []byte → ... +- delete key B from account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. + +Deleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.) + +## app_global_del + +- Bytecode: 0x69 +- Stack: ..., A: []byte → ... +- delete key A from the global state of the current application +- Availability: v2 +- Mode: Application + +params: state key. + +Deleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.) + +## asset_holding_get + +- Syntax: `asset_holding_get F` ∋ F: [asset_holding](#field-group-asset_holding) +- Bytecode: 0x70 {uint8} +- Stack: ..., A, B: uint64 → ..., X: any, Y: bool +- X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0 +- Availability: v2 +- Mode: Application + +### asset_holding + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetBalance | uint64 | Amount of the asset unit held by this account | +| 1 | AssetFrozen | bool | Is the asset frozen or not | + + +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. + +## asset_params_get + +- Syntax: `asset_params_get F` ∋ F: [asset_params](#field-group-asset_params) +- Bytecode: 0x71 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from asset A. Y is 1 if A exists, else 0 +- Availability: v2 +- Mode: Application + +### asset_params + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | AssetTotal | uint64 | | Total number of units of this asset | +| 1 | AssetDecimals | uint64 | | See AssetParams.Decimals | +| 2 | AssetDefaultFrozen | bool | | Frozen by default or not | +| 3 | AssetUnitName | []byte | | Asset unit name | +| 4 | AssetName | []byte | | Asset name | +| 5 | AssetURL | []byte | | URL with additional info about the asset | +| 6 | AssetMetadataHash | [32]byte | | Arbitrary commitment | +| 7 | AssetManager | address | | Manager address | +| 8 | AssetReserve | address | | Reserve address | +| 9 | AssetFreeze | address | | Freeze address | +| 10 | AssetClawback | address | | Clawback address | +| 11 | AssetCreator | address | v5 | Creator address | + + +params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value. + +## app_params_get + +- Syntax: `app_params_get F` ∋ F: [app_params](#field-group-app_params) +- Bytecode: 0x72 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from app A. Y is 1 if A exists, else 0 +- Availability: v5 +- Mode: Application + +### app_params + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AppApprovalProgram | []byte | Bytecode of Approval Program | +| 1 | AppClearStateProgram | []byte | Bytecode of Clear State Program | +| 2 | AppGlobalNumUint | uint64 | Number of uint64 values allowed in Global State | +| 3 | AppGlobalNumByteSlice | uint64 | Number of byte array values allowed in Global State | +| 4 | AppLocalNumUint | uint64 | Number of uint64 values allowed in Local State | +| 5 | AppLocalNumByteSlice | uint64 | Number of byte array values allowed in Local State | +| 6 | AppExtraProgramPages | uint64 | Number of Extra Program Pages of code space | +| 7 | AppCreator | address | Creator address | +| 8 | AppAddress | address | Address for which this application has authority | + + +params: Txn.ForeignApps offset or an _available_ app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value. + +## min_balance + +- Bytecode: 0x78 +- Stack: ..., A → ..., uint64 +- 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. +- Availability: v3 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## pushbytes + +- Syntax: `pushbytes BYTES` ∋ BYTES: a byte constant +- Bytecode: 0x80 {varuint length, bytes} +- Stack: ... → ..., []byte +- immediate BYTES +- Availability: v3 + +pushbytes args are not added to the bytecblock during assembly processes + +## pushint + +- Syntax: `pushint UINT` ∋ UINT: an int constant +- Bytecode: 0x81 {varuint} +- Stack: ... → ..., uint64 +- immediate UINT +- Availability: v3 + +pushint args are not added to the intcblock during assembly processes + +## callsub + +- Syntax: `callsub TARGET` ∋ TARGET: branch offset +- Bytecode: 0x88 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET, saving the next instruction on the call stack +- Availability: v4 + +The call stack is separate from the data stack. Only `callsub`, `retsub`, and `proto` manipulate it. + +## retsub + +- Bytecode: 0x89 +- Stack: ... → ... +- pop the top instruction from the call stack and branch to it +- Availability: v4 + +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. + +## shl + +- Bytecode: 0x90 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times 2^B, modulo 2^64 +- Availability: v4 + +## shr + +- Bytecode: 0x91 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by 2^B +- Availability: v4 + +## sqrt + +- Bytecode: 0x92 +- Stack: ..., A: uint64 → ..., uint64 +- The largest integer I such that I^2 <= A +- **Cost**: 4 +- Availability: v4 + +## bitlen + +- Bytecode: 0x93 +- Stack: ..., A → ..., uint64 +- 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 +- Availability: v4 + +bitlen interprets arrays as big-endian integers, unlike setbit/getbit + +## exp + +- Bytecode: 0x94 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A raised to the Bth power. Fail if A == B == 0 and on overflow +- Availability: v4 + +## expw + +- Bytecode: 0x95 +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- 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 +- **Cost**: 10 +- Availability: v4 + +## b+ + +- Bytecode: 0xa0 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A plus B. A and B are interpreted as big-endian unsigned integers +- **Cost**: 10 +- Availability: v4 + +## b- + +- Bytecode: 0xa1 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow. +- **Cost**: 10 +- Availability: v4 + +## b/ + +- Bytecode: 0xa2 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b* + +- Bytecode: 0xa3 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A times B. A and B are interpreted as big-endian unsigned integers. +- **Cost**: 20 +- Availability: v4 + +## b< + +- Bytecode: 0xa4 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b> + +- Bytecode: 0xa5 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b<= + +- Bytecode: 0xa6 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b>= + +- Bytecode: 0xa7 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b== + +- Bytecode: 0xa8 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b!= + +- Bytecode: 0xa9 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b% + +- Bytecode: 0xaa +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b| + +- Bytecode: 0xab +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-or B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b& + +- Bytecode: 0xac +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-and B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b^ + +- Bytecode: 0xad +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-xor B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b~ + +- Bytecode: 0xae +- Stack: ..., A: []byte → ..., []byte +- A with all bits inverted +- **Cost**: 4 +- Availability: v4 + +## bzero + +- Bytecode: 0xaf +- Stack: ..., A: uint64 → ..., []byte +- zero filled byte-array of length A +- Availability: v4 + +## log + +- Bytecode: 0xb0 +- Stack: ..., A: []byte → ... +- write A to log state of the current application +- Availability: v5 +- Mode: Application + +`log` fails if called more than MaxLogCalls times in a program, or if the sum of logged bytes exceeds 1024 bytes. + +## itxn_begin + +- Bytecode: 0xb1 +- Stack: ... → ... +- begin preparation of a new inner transaction in a new transaction group +- Availability: v5 +- Mode: Application + +`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. + +## itxn_field + +- Syntax: `itxn_field F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0xb2 {uint8} +- Stack: ..., A → ... +- set field F of the current inner transaction to A +- Availability: v5 +- Mode: Application + +`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_.) + +## itxn_submit + +- Bytecode: 0xb3 +- Stack: ... → ... +- 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. +- Availability: v5 +- Mode: Application + +`itxn_submit` resets the current transaction so that it can not be resubmitted. A new `itxn_begin` is required to prepare another inner transaction. + +## itxn + +- Syntax: `itxn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0xb4 {uint8} +- Stack: ... → ..., any +- field F of the last inner transaction +- Availability: v5 +- Mode: Application + +## itxna + +- Syntax: `itxna F I` ∋ F: [txna](#field-group-txna), I: a transaction field array index +- Bytecode: 0xb5 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the last inner transaction +- Availability: v5 +- Mode: Application + +## txnas + +- Syntax: `txnas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc0 {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F of the current transaction +- Availability: v5 + +## gtxnas + +- Syntax: `gtxnas T F` ∋ T: transaction group index, F: [txna](#field-group-txna) +- Bytecode: 0xc1 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F from the Tth transaction in the current group +- Availability: v5 + +## gtxnsas + +- Syntax: `gtxnsas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc2 {uint8} +- Stack: ..., A: uint64, B: uint64 → ..., any +- Bth value of the array field F from the Ath transaction in the current group +- Availability: v5 + +## args + +- Bytecode: 0xc3 +- Stack: ..., A: uint64 → ..., []byte +- Ath LogicSig argument +- Availability: v5 +- Mode: Signature diff --git a/data/transactions/logic/TEAL_opcodes_v6.md b/data/transactions/logic/TEAL_opcodes_v6.md new file mode 100644 index 0000000000..d21931430c --- /dev/null +++ b/data/transactions/logic/TEAL_opcodes_v6.md @@ -0,0 +1,1359 @@ +# v6 Opcodes + +Ops have a 'cost' of 1 unless otherwise specified. + + +## err + +- Bytecode: 0x00 +- Stack: ... → _exits_ +- Fail immediately. + +## sha256 + +- Bytecode: 0x01 +- Stack: ..., A: []byte → ..., [32]byte +- SHA256 hash of value A, yields [32]byte +- **Cost**: 35 + +## keccak256 + +- Bytecode: 0x02 +- Stack: ..., A: []byte → ..., [32]byte +- Keccak256 hash of value A, yields [32]byte +- **Cost**: 130 + +## sha512_256 + +- Bytecode: 0x03 +- Stack: ..., A: []byte → ..., [32]byte +- SHA512_256 hash of value A, yields [32]byte +- **Cost**: 45 + +## ed25519verify + +- Bytecode: 0x04 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1} +- **Cost**: 1900 + +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. + +## ecdsa_verify + +- Syntax: `ecdsa_verify V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x05 {uint8} +- Stack: ..., A: []byte, B: []byte, C: []byte, D: []byte, E: []byte → ..., bool +- for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1} +- **Cost**: Secp256k1=1700 +- Availability: v5 + +### ECDSA + +Curves + +| Index | Name | Notes | +| - | ------ | --------- | +| 0 | Secp256k1 | secp256k1 curve, used in Bitcoin | + + +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. + +## ecdsa_pk_decompress + +- Syntax: `ecdsa_pk_decompress V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x06 {uint8} +- Stack: ..., A: []byte → ..., X: []byte, Y: []byte +- decompress pubkey A into components X, Y +- **Cost**: Secp256k1=650 +- Availability: v5 + +The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded. + +## ecdsa_pk_recover + +- Syntax: `ecdsa_pk_recover V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x07 {uint8} +- Stack: ..., A: []byte, B: uint64, C: []byte, D: []byte → ..., X: []byte, Y: []byte +- for (data A, recovery id B, signature C, D) recover a public key +- **Cost**: 2000 +- Availability: v5 + +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. + +## + + +- Bytecode: 0x08 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A plus B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`. + +## - + +- Bytecode: 0x09 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A minus B. Fail if B > A. + +## / + +- Bytecode: 0x0a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by B (truncated division). Fail if B == 0. + +`divmodw` is available to divide the two-element values produced by `mulw` and `addw`. + +## * + +- Bytecode: 0x0b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`. + +## < + +- Bytecode: 0x0c +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than B => {0 or 1} + +## > + +- Bytecode: 0x0d +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than B => {0 or 1} + +## <= + +- Bytecode: 0x0e +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than or equal to B => {0 or 1} + +## >= + +- Bytecode: 0x0f +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than or equal to B => {0 or 1} + +## && + +- Bytecode: 0x10 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero and B is not zero => {0 or 1} + +## || + +- Bytecode: 0x11 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero or B is not zero => {0 or 1} + +## == + +- Bytecode: 0x12 +- Stack: ..., A, B → ..., bool +- A is equal to B => {0 or 1} + +## != + +- Bytecode: 0x13 +- Stack: ..., A, B → ..., bool +- A is not equal to B => {0 or 1} + +## ! + +- Bytecode: 0x14 +- Stack: ..., A: uint64 → ..., uint64 +- A == 0 yields 1; else 0 + +## len + +- Bytecode: 0x15 +- Stack: ..., A: []byte → ..., uint64 +- yields length of byte value A + +## itob + +- Bytecode: 0x16 +- Stack: ..., A: uint64 → ..., []byte +- converts uint64 A to big-endian byte array, always of length 8 + +## btoi + +- Bytecode: 0x17 +- Stack: ..., A: []byte → ..., uint64 +- converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8. + +`btoi` fails if the input is longer than 8 bytes. + +## % + +- Bytecode: 0x18 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A modulo B. Fail if B == 0. + +## | + +- Bytecode: 0x19 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-or B + +## & + +- Bytecode: 0x1a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-and B + +## ^ + +- Bytecode: 0x1b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-xor B + +## ~ + +- Bytecode: 0x1c +- Stack: ..., A: uint64 → ..., uint64 +- bitwise invert value A + +## mulw + +- Bytecode: 0x1d +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low + +## addw + +- Bytecode: 0x1e +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits. +- Availability: v2 + +## divmodw + +- Bytecode: 0x1f +- Stack: ..., A: uint64, B: uint64, C: uint64, D: uint64 → ..., W: uint64, X: uint64, Y: uint64, Z: uint64 +- W,X = (A,B / C,D); Y,Z = (A,B modulo C,D) +- **Cost**: 20 +- Availability: v4 + +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. + +## intcblock + +- Syntax: `intcblock UINT ...` ∋ UINT ...: a block of int constant values +- Bytecode: 0x20 {varuint count, [varuint ...]} +- Stack: ... → ... +- prepare block of uint64 constants for use by intc + +`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. + +## intc + +- Syntax: `intc I` ∋ I: an index in the intcblock +- Bytecode: 0x21 {uint8} +- Stack: ... → ..., uint64 +- Ith constant from intcblock + +## intc_0 + +- Bytecode: 0x22 +- Stack: ... → ..., uint64 +- constant 0 from intcblock + +## intc_1 + +- Bytecode: 0x23 +- Stack: ... → ..., uint64 +- constant 1 from intcblock + +## intc_2 + +- Bytecode: 0x24 +- Stack: ... → ..., uint64 +- constant 2 from intcblock + +## intc_3 + +- Bytecode: 0x25 +- Stack: ... → ..., uint64 +- constant 3 from intcblock + +## bytecblock + +- Syntax: `bytecblock BYTES ...` ∋ BYTES ...: a block of byte constant values +- Bytecode: 0x26 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ... +- prepare block of byte-array constants for use by bytec + +`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. + +## bytec + +- Syntax: `bytec I` ∋ I: an index in the bytecblock +- Bytecode: 0x27 {uint8} +- Stack: ... → ..., []byte +- Ith constant from bytecblock + +## bytec_0 + +- Bytecode: 0x28 +- Stack: ... → ..., []byte +- constant 0 from bytecblock + +## bytec_1 + +- Bytecode: 0x29 +- Stack: ... → ..., []byte +- constant 1 from bytecblock + +## bytec_2 + +- Bytecode: 0x2a +- Stack: ... → ..., []byte +- constant 2 from bytecblock + +## bytec_3 + +- Bytecode: 0x2b +- Stack: ... → ..., []byte +- constant 3 from bytecblock + +## arg + +- Syntax: `arg N` ∋ N: an arg index +- Bytecode: 0x2c {uint8} +- Stack: ... → ..., []byte +- Nth LogicSig argument +- Mode: Signature + +## arg_0 + +- Bytecode: 0x2d +- Stack: ... → ..., []byte +- LogicSig argument 0 +- Mode: Signature + +## arg_1 + +- Bytecode: 0x2e +- Stack: ... → ..., []byte +- LogicSig argument 1 +- Mode: Signature + +## arg_2 + +- Bytecode: 0x2f +- Stack: ... → ..., []byte +- LogicSig argument 2 +- Mode: Signature + +## arg_3 + +- Bytecode: 0x30 +- Stack: ... → ..., []byte +- LogicSig argument 3 +- Mode: Signature + +## txn + +- Syntax: `txn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x31 {uint8} +- Stack: ... → ..., any +- field F of current transaction + +### txn + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | Sender | address | | 32 byte address | +| 1 | Fee | uint64 | | microalgos | +| 2 | FirstValid | uint64 | | round number | +| 4 | LastValid | uint64 | | round number | +| 5 | Note | []byte | | Any data up to 1024 bytes | +| 6 | Lease | [32]byte | | 32 byte lease value | +| 7 | Receiver | address | | 32 byte address | +| 8 | Amount | uint64 | | microalgos | +| 9 | CloseRemainderTo | address | | 32 byte address | +| 10 | VotePK | [32]byte | | 32 byte address | +| 11 | SelectionPK | [32]byte | | 32 byte address | +| 12 | VoteFirst | uint64 | | The first round that the participation key is valid. | +| 13 | VoteLast | uint64 | | The last round that the participation key is valid. | +| 14 | VoteKeyDilution | uint64 | | Dilution for the 2-level participation key | +| 15 | Type | []byte | | Transaction type as bytes | +| 16 | TypeEnum | uint64 | | Transaction type as integer | +| 17 | XferAsset | uint64 | | Asset ID | +| 18 | AssetAmount | uint64 | | value in Asset's units | +| 19 | AssetSender | address | | 32 byte address. Source of assets if Sender is the Asset's Clawback address. | +| 20 | AssetReceiver | address | | 32 byte address | +| 21 | AssetCloseTo | address | | 32 byte address | +| 22 | GroupIndex | uint64 | | Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1 | +| 23 | TxID | [32]byte | | The computed ID for this transaction. 32 bytes. | +| 24 | ApplicationID | uint64 | v2 | ApplicationID from ApplicationCall transaction | +| 25 | OnCompletion | uint64 | v2 | ApplicationCall transaction on completion action | +| 27 | NumAppArgs | uint64 | v2 | Number of ApplicationArgs | +| 29 | NumAccounts | uint64 | v2 | Number of Accounts | +| 30 | ApprovalProgram | []byte | v2 | Approval program | +| 31 | ClearStateProgram | []byte | v2 | Clear state program | +| 32 | RekeyTo | address | v2 | 32 byte Sender's new AuthAddr | +| 33 | ConfigAsset | uint64 | v2 | Asset ID in asset config transaction | +| 34 | ConfigAssetTotal | uint64 | v2 | Total number of units of this asset created | +| 35 | ConfigAssetDecimals | uint64 | v2 | Number of digits to display after the decimal place when displaying the asset | +| 36 | ConfigAssetDefaultFrozen | bool | v2 | Whether the asset's slots are frozen by default or not, 0 or 1 | +| 37 | ConfigAssetUnitName | []byte | v2 | Unit name of the asset | +| 38 | ConfigAssetName | []byte | v2 | The asset name | +| 39 | ConfigAssetURL | []byte | v2 | URL | +| 40 | ConfigAssetMetadataHash | [32]byte | v2 | 32 byte commitment to unspecified asset metadata | +| 41 | ConfigAssetManager | address | v2 | 32 byte address | +| 42 | ConfigAssetReserve | address | v2 | 32 byte address | +| 43 | ConfigAssetFreeze | address | v2 | 32 byte address | +| 44 | ConfigAssetClawback | address | v2 | 32 byte address | +| 45 | FreezeAsset | uint64 | v2 | Asset ID being frozen or un-frozen | +| 46 | FreezeAssetAccount | address | v2 | 32 byte address of the account whose asset slot is being frozen or un-frozen | +| 47 | FreezeAssetFrozen | bool | v2 | The new frozen value, 0 or 1 | +| 49 | NumAssets | uint64 | v3 | Number of Assets | +| 51 | NumApplications | uint64 | v3 | Number of Applications | +| 52 | GlobalNumUint | uint64 | v3 | Number of global state integers in ApplicationCall | +| 53 | GlobalNumByteSlice | uint64 | v3 | Number of global state byteslices in ApplicationCall | +| 54 | LocalNumUint | uint64 | v3 | Number of local state integers in ApplicationCall | +| 55 | LocalNumByteSlice | uint64 | v3 | Number of local state byteslices in ApplicationCall | +| 56 | ExtraProgramPages | uint64 | v4 | Number of additional pages for each of the application's approval and clear state programs. An ExtraProgramPages of 1 means 2048 more total bytes, or 1024 for each program. | +| 57 | Nonparticipation | bool | v5 | Marks an account nonparticipating for rewards | +| 59 | NumLogs | uint64 | v5 | Number of Logs (only with `itxn` in v5). Application mode only | +| 60 | CreatedAssetID | uint64 | v5 | Asset ID allocated by the creation of an ASA (only with `itxn` in v5). Application mode only | +| 61 | CreatedApplicationID | uint64 | v5 | ApplicationID allocated by the creation of an application (only with `itxn` in v5). Application mode only | +| 62 | LastLog | []byte | v6 | The last message emitted. Empty bytes if none were emitted. Application mode only | +| 63 | StateProofPK | []byte | v6 | 64 byte state proof public key | + + +## global + +- Syntax: `global F` ∋ F: [global](#field-group-global) +- Bytecode: 0x32 {uint8} +- Stack: ... → ..., any +- global field F + +### global + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | MinTxnFee | uint64 | | microalgos | +| 1 | MinBalance | uint64 | | microalgos | +| 2 | MaxTxnLife | uint64 | | rounds | +| 3 | ZeroAddress | address | | 32 byte address of all zero bytes | +| 4 | GroupSize | uint64 | | Number of transactions in this atomic transaction group. At least 1 | +| 5 | LogicSigVersion | uint64 | v2 | Maximum supported version | +| 6 | Round | uint64 | v2 | Current round number. Application mode only. | +| 7 | LatestTimestamp | uint64 | v2 | Last confirmed block UNIX timestamp. Fails if negative. Application mode only. | +| 8 | CurrentApplicationID | uint64 | v2 | ID of current application executing. Application mode only. | +| 9 | CreatorAddress | address | v3 | Address of the creator of the current application. Application mode only. | +| 10 | CurrentApplicationAddress | address | v5 | Address that the current application controls. Application mode only. | +| 11 | GroupID | [32]byte | v5 | ID of the transaction group. 32 zero bytes if the transaction is not part of a group. | +| 12 | OpcodeBudget | uint64 | v6 | The remaining cost that can be spent by opcodes in this program. | +| 13 | CallerApplicationID | uint64 | v6 | The application ID of the application that called this application. 0 if this application is at the top-level. Application mode only. | +| 14 | CallerApplicationAddress | address | v6 | The application address of the application that called this application. ZeroAddress if this application is at the top-level. Application mode only. | + + +## gtxn + +- Syntax: `gtxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0x33 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the current group + +for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`. + +## load + +- Syntax: `load I` ∋ I: position in scratch space to load from +- Bytecode: 0x34 {uint8} +- Stack: ... → ..., any +- Ith scratch space value. All scratch spaces are 0 at program start. + +## store + +- Syntax: `store I` ∋ I: position in scratch space to store to +- Bytecode: 0x35 {uint8} +- Stack: ..., A → ... +- store A to the Ith scratch space + +## txna + +- Syntax: `txna F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x36 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the current transaction
`txna` can be called using `txn` with 2 immediates. +- Availability: v2 + +### txna + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 26 | ApplicationArgs | []byte | v2 | Arguments passed to the application in the ApplicationCall transaction | +| 28 | Accounts | address | v2 | Accounts listed in the ApplicationCall transaction | +| 48 | Assets | uint64 | v3 | Foreign Assets listed in the ApplicationCall transaction | +| 50 | Applications | uint64 | v3 | Foreign Apps listed in the ApplicationCall transaction | +| 58 | Logs | []byte | v5 | Log messages emitted by an application call (only with `itxn` in v5). Application mode only | + + +## gtxna + +- Syntax: `gtxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x37 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the current group
`gtxna` can be called using `gtxn` with 3 immediates. +- Availability: v2 + +## gtxns + +- Syntax: `gtxns F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x38 {uint8} +- Stack: ..., A: uint64 → ..., any +- field F of the Ath transaction in the current group +- Availability: v3 + +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. + +## gtxnsa + +- Syntax: `gtxnsa F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x39 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith value of the array field F from the Ath transaction in the current group
`gtxnsa` can be called using `gtxns` with 2 immediates. +- Availability: v3 + +## gload + +- Syntax: `gload T I` ∋ T: transaction group index, I: position in scratch space to load from +- Bytecode: 0x3a {uint8}, {uint8} +- Stack: ... → ..., any +- Ith scratch space value of the Tth transaction in the current group +- Availability: v4 +- Mode: Application + +`gload` fails unless the requested transaction is an ApplicationCall and T < GroupIndex. + +## gloads + +- Syntax: `gloads I` ∋ I: position in scratch space to load from +- Bytecode: 0x3b {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith scratch space value of the Ath transaction in the current group +- Availability: v4 +- Mode: Application + +`gloads` fails unless the requested transaction is an ApplicationCall and A < GroupIndex. + +## gaid + +- Syntax: `gaid T` ∋ T: transaction group index +- Bytecode: 0x3c {uint8} +- Stack: ... → ..., uint64 +- ID of the asset or application created in the Tth transaction of the current group +- Availability: v4 +- Mode: Application + +`gaid` fails unless the requested transaction created an asset or application and T < GroupIndex. + +## gaids + +- Bytecode: 0x3d +- Stack: ..., A: uint64 → ..., uint64 +- ID of the asset or application created in the Ath transaction of the current group +- Availability: v4 +- Mode: Application + +`gaids` fails unless the requested transaction created an asset or application and A < GroupIndex. + +## loads + +- Bytecode: 0x3e +- Stack: ..., A: uint64 → ..., any +- Ath scratch space value. All scratch spaces are 0 at program start. +- Availability: v5 + +## stores + +- Bytecode: 0x3f +- Stack: ..., A: uint64, B → ... +- store B to the Ath scratch space +- Availability: v5 + +## bnz + +- Syntax: `bnz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x40 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is not zero + +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. + +At 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.) + +## bz + +- Syntax: `bz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x41 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is zero +- Availability: v2 + +See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`. + +## b + +- Syntax: `b TARGET` ∋ TARGET: branch offset +- Bytecode: 0x42 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET +- Availability: v2 + +See `bnz` for details on how branches work. `b` always jumps to the offset. + +## return + +- Bytecode: 0x43 +- Stack: ..., A: uint64 → _exits_ +- use A as success value; end +- Availability: v2 + +## assert + +- Bytecode: 0x44 +- Stack: ..., A: uint64 → ... +- immediately fail unless A is a non-zero number +- Availability: v3 + +## pop + +- Bytecode: 0x48 +- Stack: ..., A → ... +- discard A + +## dup + +- Bytecode: 0x49 +- Stack: ..., A → ..., A, A +- duplicate A + +## dup2 + +- Bytecode: 0x4a +- Stack: ..., A, B → ..., A, B, A, B +- duplicate A and B +- Availability: v2 + +## dig + +- Syntax: `dig N` ∋ N: depth +- Bytecode: 0x4b {uint8} +- Stack: ..., A, [N items] → ..., A, [N items], A +- Nth value from the top of the stack. dig 0 is equivalent to dup +- Availability: v3 + +## swap + +- Bytecode: 0x4c +- Stack: ..., A, B → ..., B, A +- swaps A and B on stack +- Availability: v3 + +## select + +- Bytecode: 0x4d +- Stack: ..., A, B, C: uint64 → ..., A or B +- selects one of two values based on top-of-stack: B if C != 0, else A +- Availability: v3 + +## cover + +- Syntax: `cover N` ∋ N: depth +- Bytecode: 0x4e {uint8} +- Stack: ..., [N items], A → ..., A, [N items] +- remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth <= N. +- Availability: v5 + +## uncover + +- Syntax: `uncover N` ∋ N: depth +- Bytecode: 0x4f {uint8} +- Stack: ..., A, [N items] → ..., [N items], A +- 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. +- Availability: v5 + +## concat + +- Bytecode: 0x50 +- Stack: ..., A: []byte, B: []byte → ..., []byte +- join A and B +- Availability: v2 + +`concat` fails if the result would be greater than 4096 bytes. + +## substring + +- Syntax: `substring S E` ∋ S: start position, E: end position +- Bytecode: 0x51 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v2 + +## substring3 + +- Bytecode: 0x52 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v2 + +## getbit + +- Bytecode: 0x53 +- Stack: ..., A, B: uint64 → ..., uint64 +- 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 +- Availability: v3 + +see explanation of bit ordering in setbit + +## setbit + +- Bytecode: 0x54 +- Stack: ..., A, B: uint64, C: uint64 → ..., any +- 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 +- Availability: v3 + +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. + +## getbyte + +- Bytecode: 0x55 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails +- Availability: v3 + +## setbyte + +- Bytecode: 0x56 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v3 + +## extract + +- Syntax: `extract S L` ∋ S: start position, L: length +- Bytecode: 0x57 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v5 + +## extract3 + +- Bytecode: 0x58 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- A range of bytes from A starting at B up to but not including B+C. If B+C is larger than the array length, the program fails
`extract3` can be called using `extract` with no immediates. +- Availability: v5 + +## extract_uint16 + +- Bytecode: 0x59 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- 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 +- Availability: v5 + +## extract_uint32 + +- Bytecode: 0x5a +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- 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 +- Availability: v5 + +## extract_uint64 + +- Bytecode: 0x5b +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- A uint64 formed from a range of big-endian bytes from A starting at B up to but not including B+8. If B+8 is larger than the array length, the program fails +- Availability: v5 + +## balance + +- Bytecode: 0x60 +- Stack: ..., A → ..., uint64 +- 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` +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## app_opted_in + +- Bytecode: 0x61 +- Stack: ..., A, B: uint64 → ..., bool +- 1 if account A is opted in to application B, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_get + +- Bytecode: 0x62 +- Stack: ..., A, B: []byte → ..., any +- local state of the key B in the current application in account A +- Availability: v2 +- Mode: Application + +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. + +## app_local_get_ex + +- Bytecode: 0x63 +- Stack: ..., A, B: uint64, C: []byte → ..., X: any, Y: bool +- X is the local state of application B, key C in account A. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_global_get + +- Bytecode: 0x64 +- Stack: ..., A: []byte → ..., any +- global state of the key A in the current application +- Availability: v2 +- Mode: Application + +params: state key. Return: value. The value is zero (of type uint64) if the key does not exist. + +## app_global_get_ex + +- Bytecode: 0x65 +- Stack: ..., A: uint64, B: []byte → ..., X: any, Y: bool +- X is the global state of application A, key B. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_put + +- Bytecode: 0x66 +- Stack: ..., A, B: []byte, C → ... +- write C to key B in account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value. + +## app_global_put + +- Bytecode: 0x67 +- Stack: ..., A: []byte, B → ... +- write B to key A in the global state of the current application +- Availability: v2 +- Mode: Application + +## app_local_del + +- Bytecode: 0x68 +- Stack: ..., A, B: []byte → ... +- delete key B from account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. + +Deleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.) + +## app_global_del + +- Bytecode: 0x69 +- Stack: ..., A: []byte → ... +- delete key A from the global state of the current application +- Availability: v2 +- Mode: Application + +params: state key. + +Deleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.) + +## asset_holding_get + +- Syntax: `asset_holding_get F` ∋ F: [asset_holding](#field-group-asset_holding) +- Bytecode: 0x70 {uint8} +- Stack: ..., A, B: uint64 → ..., X: any, Y: bool +- X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0 +- Availability: v2 +- Mode: Application + +### asset_holding + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetBalance | uint64 | Amount of the asset unit held by this account | +| 1 | AssetFrozen | bool | Is the asset frozen or not | + + +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. + +## asset_params_get + +- Syntax: `asset_params_get F` ∋ F: [asset_params](#field-group-asset_params) +- Bytecode: 0x71 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from asset A. Y is 1 if A exists, else 0 +- Availability: v2 +- Mode: Application + +### asset_params + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | AssetTotal | uint64 | | Total number of units of this asset | +| 1 | AssetDecimals | uint64 | | See AssetParams.Decimals | +| 2 | AssetDefaultFrozen | bool | | Frozen by default or not | +| 3 | AssetUnitName | []byte | | Asset unit name | +| 4 | AssetName | []byte | | Asset name | +| 5 | AssetURL | []byte | | URL with additional info about the asset | +| 6 | AssetMetadataHash | [32]byte | | Arbitrary commitment | +| 7 | AssetManager | address | | Manager address | +| 8 | AssetReserve | address | | Reserve address | +| 9 | AssetFreeze | address | | Freeze address | +| 10 | AssetClawback | address | | Clawback address | +| 11 | AssetCreator | address | v5 | Creator address | + + +params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value. + +## app_params_get + +- Syntax: `app_params_get F` ∋ F: [app_params](#field-group-app_params) +- Bytecode: 0x72 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from app A. Y is 1 if A exists, else 0 +- Availability: v5 +- Mode: Application + +### app_params + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AppApprovalProgram | []byte | Bytecode of Approval Program | +| 1 | AppClearStateProgram | []byte | Bytecode of Clear State Program | +| 2 | AppGlobalNumUint | uint64 | Number of uint64 values allowed in Global State | +| 3 | AppGlobalNumByteSlice | uint64 | Number of byte array values allowed in Global State | +| 4 | AppLocalNumUint | uint64 | Number of uint64 values allowed in Local State | +| 5 | AppLocalNumByteSlice | uint64 | Number of byte array values allowed in Local State | +| 6 | AppExtraProgramPages | uint64 | Number of Extra Program Pages of code space | +| 7 | AppCreator | address | Creator address | +| 8 | AppAddress | address | Address for which this application has authority | + + +params: Txn.ForeignApps offset or an _available_ app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value. + +## acct_params_get + +- Syntax: `acct_params_get F` ∋ F: [acct_params](#field-group-acct_params) +- Bytecode: 0x73 {uint8} +- Stack: ..., A → ..., X: any, Y: bool +- X is field F from account A. Y is 1 if A owns positive algos, else 0 +- Availability: v6 +- Mode: Application + +### acct_params + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AcctBalance | uint64 | Account balance in microalgos | +| 1 | AcctMinBalance | uint64 | Minimum required balance for account, in microalgos | +| 2 | AcctAuthAddr | address | Address the account is rekeyed to. | + + +## min_balance + +- Bytecode: 0x78 +- Stack: ..., A → ..., uint64 +- 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. +- Availability: v3 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## pushbytes + +- Syntax: `pushbytes BYTES` ∋ BYTES: a byte constant +- Bytecode: 0x80 {varuint length, bytes} +- Stack: ... → ..., []byte +- immediate BYTES +- Availability: v3 + +pushbytes args are not added to the bytecblock during assembly processes + +## pushint + +- Syntax: `pushint UINT` ∋ UINT: an int constant +- Bytecode: 0x81 {varuint} +- Stack: ... → ..., uint64 +- immediate UINT +- Availability: v3 + +pushint args are not added to the intcblock during assembly processes + +## callsub + +- Syntax: `callsub TARGET` ∋ TARGET: branch offset +- Bytecode: 0x88 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET, saving the next instruction on the call stack +- Availability: v4 + +The call stack is separate from the data stack. Only `callsub`, `retsub`, and `proto` manipulate it. + +## retsub + +- Bytecode: 0x89 +- Stack: ... → ... +- pop the top instruction from the call stack and branch to it +- Availability: v4 + +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. + +## shl + +- Bytecode: 0x90 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times 2^B, modulo 2^64 +- Availability: v4 + +## shr + +- Bytecode: 0x91 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by 2^B +- Availability: v4 + +## sqrt + +- Bytecode: 0x92 +- Stack: ..., A: uint64 → ..., uint64 +- The largest integer I such that I^2 <= A +- **Cost**: 4 +- Availability: v4 + +## bitlen + +- Bytecode: 0x93 +- Stack: ..., A → ..., uint64 +- 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 +- Availability: v4 + +bitlen interprets arrays as big-endian integers, unlike setbit/getbit + +## exp + +- Bytecode: 0x94 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A raised to the Bth power. Fail if A == B == 0 and on overflow +- Availability: v4 + +## expw + +- Bytecode: 0x95 +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- 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 +- **Cost**: 10 +- Availability: v4 + +## bsqrt + +- Bytecode: 0x96 +- Stack: ..., A: []byte → ..., []byte +- The largest integer I such that I^2 <= A. A and I are interpreted as big-endian unsigned integers +- **Cost**: 40 +- Availability: v6 + +## divw + +- Bytecode: 0x97 +- Stack: ..., A: uint64, B: uint64, C: uint64 → ..., uint64 +- A,B / C. Fail if C == 0 or if result overflows. +- Availability: v6 + +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. + +## b+ + +- Bytecode: 0xa0 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A plus B. A and B are interpreted as big-endian unsigned integers +- **Cost**: 10 +- Availability: v4 + +## b- + +- Bytecode: 0xa1 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow. +- **Cost**: 10 +- Availability: v4 + +## b/ + +- Bytecode: 0xa2 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b* + +- Bytecode: 0xa3 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A times B. A and B are interpreted as big-endian unsigned integers. +- **Cost**: 20 +- Availability: v4 + +## b< + +- Bytecode: 0xa4 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b> + +- Bytecode: 0xa5 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b<= + +- Bytecode: 0xa6 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b>= + +- Bytecode: 0xa7 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b== + +- Bytecode: 0xa8 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b!= + +- Bytecode: 0xa9 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b% + +- Bytecode: 0xaa +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b| + +- Bytecode: 0xab +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-or B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b& + +- Bytecode: 0xac +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-and B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b^ + +- Bytecode: 0xad +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-xor B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b~ + +- Bytecode: 0xae +- Stack: ..., A: []byte → ..., []byte +- A with all bits inverted +- **Cost**: 4 +- Availability: v4 + +## bzero + +- Bytecode: 0xaf +- Stack: ..., A: uint64 → ..., []byte +- zero filled byte-array of length A +- Availability: v4 + +## log + +- Bytecode: 0xb0 +- Stack: ..., A: []byte → ... +- write A to log state of the current application +- Availability: v5 +- Mode: Application + +`log` fails if called more than MaxLogCalls times in a program, or if the sum of logged bytes exceeds 1024 bytes. + +## itxn_begin + +- Bytecode: 0xb1 +- Stack: ... → ... +- begin preparation of a new inner transaction in a new transaction group +- Availability: v5 +- Mode: Application + +`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. + +## itxn_field + +- Syntax: `itxn_field F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0xb2 {uint8} +- Stack: ..., A → ... +- set field F of the current inner transaction to A +- Availability: v5 +- Mode: Application + +`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_.) + +## itxn_submit + +- Bytecode: 0xb3 +- Stack: ... → ... +- 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. +- Availability: v5 +- Mode: Application + +`itxn_submit` resets the current transaction so that it can not be resubmitted. A new `itxn_begin` is required to prepare another inner transaction. + +## itxn + +- Syntax: `itxn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0xb4 {uint8} +- Stack: ... → ..., any +- field F of the last inner transaction +- Availability: v5 +- Mode: Application + +## itxna + +- Syntax: `itxna F I` ∋ F: [txna](#field-group-txna), I: a transaction field array index +- Bytecode: 0xb5 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the last inner transaction +- Availability: v5 +- Mode: Application + +## itxn_next + +- Bytecode: 0xb6 +- Stack: ... → ... +- begin preparation of a new inner transaction in the same transaction group +- Availability: v6 +- Mode: Application + +`itxn_next` initializes the transaction exactly as `itxn_begin` does + +## gitxn + +- Syntax: `gitxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0xb7 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## gitxna + +- Syntax: `gitxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0xb8 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## txnas + +- Syntax: `txnas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc0 {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F of the current transaction +- Availability: v5 + +## gtxnas + +- Syntax: `gtxnas T F` ∋ T: transaction group index, F: [txna](#field-group-txna) +- Bytecode: 0xc1 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F from the Tth transaction in the current group +- Availability: v5 + +## gtxnsas + +- Syntax: `gtxnsas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc2 {uint8} +- Stack: ..., A: uint64, B: uint64 → ..., any +- Bth value of the array field F from the Ath transaction in the current group +- Availability: v5 + +## args + +- Bytecode: 0xc3 +- Stack: ..., A: uint64 → ..., []byte +- Ath LogicSig argument +- Availability: v5 +- Mode: Signature + +## gloadss + +- Bytecode: 0xc4 +- Stack: ..., A: uint64, B: uint64 → ..., any +- Bth scratch space value of the Ath transaction in the current group +- Availability: v6 +- Mode: Application + +## itxnas + +- Syntax: `itxnas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc5 {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F of the last inner transaction +- Availability: v6 +- Mode: Application + +## gitxnas + +- Syntax: `gitxnas T F` ∋ T: transaction group index, F: [txna](#field-group-txna) +- Bytecode: 0xc6 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F from the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application diff --git a/data/transactions/logic/TEAL_opcodes_v7.md b/data/transactions/logic/TEAL_opcodes_v7.md new file mode 100644 index 0000000000..41b1468ae5 --- /dev/null +++ b/data/transactions/logic/TEAL_opcodes_v7.md @@ -0,0 +1,1481 @@ +# v7 Opcodes + +Ops have a 'cost' of 1 unless otherwise specified. + + +## err + +- Bytecode: 0x00 +- Stack: ... → _exits_ +- Fail immediately. + +## sha256 + +- Bytecode: 0x01 +- Stack: ..., A: []byte → ..., [32]byte +- SHA256 hash of value A, yields [32]byte +- **Cost**: 35 + +## keccak256 + +- Bytecode: 0x02 +- Stack: ..., A: []byte → ..., [32]byte +- Keccak256 hash of value A, yields [32]byte +- **Cost**: 130 + +## sha512_256 + +- Bytecode: 0x03 +- Stack: ..., A: []byte → ..., [32]byte +- SHA512_256 hash of value A, yields [32]byte +- **Cost**: 45 + +## ed25519verify + +- Bytecode: 0x04 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1} +- **Cost**: 1900 + +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. + +## ecdsa_verify + +- Syntax: `ecdsa_verify V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x05 {uint8} +- Stack: ..., A: []byte, B: []byte, C: []byte, D: []byte, E: []byte → ..., bool +- for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1} +- **Cost**: Secp256k1=1700; Secp256r1=2500 +- Availability: v5 + +### ECDSA + +Curves + +| Index | Name | In | Notes | +| - | ------ | - | --------- | +| 0 | Secp256k1 | | secp256k1 curve, used in Bitcoin | +| 1 | Secp256r1 | v7 | secp256r1 curve, NIST standard | + + +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. + +## ecdsa_pk_decompress + +- Syntax: `ecdsa_pk_decompress V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x06 {uint8} +- Stack: ..., A: []byte → ..., X: []byte, Y: []byte +- decompress pubkey A into components X, Y +- **Cost**: Secp256k1=650; Secp256r1=2400 +- Availability: v5 + +The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded. + +## ecdsa_pk_recover + +- Syntax: `ecdsa_pk_recover V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x07 {uint8} +- Stack: ..., A: []byte, B: uint64, C: []byte, D: []byte → ..., X: []byte, Y: []byte +- for (data A, recovery id B, signature C, D) recover a public key +- **Cost**: 2000 +- Availability: v5 + +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. + +## + + +- Bytecode: 0x08 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A plus B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`. + +## - + +- Bytecode: 0x09 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A minus B. Fail if B > A. + +## / + +- Bytecode: 0x0a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by B (truncated division). Fail if B == 0. + +`divmodw` is available to divide the two-element values produced by `mulw` and `addw`. + +## * + +- Bytecode: 0x0b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`. + +## < + +- Bytecode: 0x0c +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than B => {0 or 1} + +## > + +- Bytecode: 0x0d +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than B => {0 or 1} + +## <= + +- Bytecode: 0x0e +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than or equal to B => {0 or 1} + +## >= + +- Bytecode: 0x0f +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than or equal to B => {0 or 1} + +## && + +- Bytecode: 0x10 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero and B is not zero => {0 or 1} + +## || + +- Bytecode: 0x11 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero or B is not zero => {0 or 1} + +## == + +- Bytecode: 0x12 +- Stack: ..., A, B → ..., bool +- A is equal to B => {0 or 1} + +## != + +- Bytecode: 0x13 +- Stack: ..., A, B → ..., bool +- A is not equal to B => {0 or 1} + +## ! + +- Bytecode: 0x14 +- Stack: ..., A: uint64 → ..., uint64 +- A == 0 yields 1; else 0 + +## len + +- Bytecode: 0x15 +- Stack: ..., A: []byte → ..., uint64 +- yields length of byte value A + +## itob + +- Bytecode: 0x16 +- Stack: ..., A: uint64 → ..., []byte +- converts uint64 A to big-endian byte array, always of length 8 + +## btoi + +- Bytecode: 0x17 +- Stack: ..., A: []byte → ..., uint64 +- converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8. + +`btoi` fails if the input is longer than 8 bytes. + +## % + +- Bytecode: 0x18 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A modulo B. Fail if B == 0. + +## | + +- Bytecode: 0x19 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-or B + +## & + +- Bytecode: 0x1a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-and B + +## ^ + +- Bytecode: 0x1b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-xor B + +## ~ + +- Bytecode: 0x1c +- Stack: ..., A: uint64 → ..., uint64 +- bitwise invert value A + +## mulw + +- Bytecode: 0x1d +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low + +## addw + +- Bytecode: 0x1e +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits. +- Availability: v2 + +## divmodw + +- Bytecode: 0x1f +- Stack: ..., A: uint64, B: uint64, C: uint64, D: uint64 → ..., W: uint64, X: uint64, Y: uint64, Z: uint64 +- W,X = (A,B / C,D); Y,Z = (A,B modulo C,D) +- **Cost**: 20 +- Availability: v4 + +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. + +## intcblock + +- Syntax: `intcblock UINT ...` ∋ UINT ...: a block of int constant values +- Bytecode: 0x20 {varuint count, [varuint ...]} +- Stack: ... → ... +- prepare block of uint64 constants for use by intc + +`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. + +## intc + +- Syntax: `intc I` ∋ I: an index in the intcblock +- Bytecode: 0x21 {uint8} +- Stack: ... → ..., uint64 +- Ith constant from intcblock + +## intc_0 + +- Bytecode: 0x22 +- Stack: ... → ..., uint64 +- constant 0 from intcblock + +## intc_1 + +- Bytecode: 0x23 +- Stack: ... → ..., uint64 +- constant 1 from intcblock + +## intc_2 + +- Bytecode: 0x24 +- Stack: ... → ..., uint64 +- constant 2 from intcblock + +## intc_3 + +- Bytecode: 0x25 +- Stack: ... → ..., uint64 +- constant 3 from intcblock + +## bytecblock + +- Syntax: `bytecblock BYTES ...` ∋ BYTES ...: a block of byte constant values +- Bytecode: 0x26 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ... +- prepare block of byte-array constants for use by bytec + +`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. + +## bytec + +- Syntax: `bytec I` ∋ I: an index in the bytecblock +- Bytecode: 0x27 {uint8} +- Stack: ... → ..., []byte +- Ith constant from bytecblock + +## bytec_0 + +- Bytecode: 0x28 +- Stack: ... → ..., []byte +- constant 0 from bytecblock + +## bytec_1 + +- Bytecode: 0x29 +- Stack: ... → ..., []byte +- constant 1 from bytecblock + +## bytec_2 + +- Bytecode: 0x2a +- Stack: ... → ..., []byte +- constant 2 from bytecblock + +## bytec_3 + +- Bytecode: 0x2b +- Stack: ... → ..., []byte +- constant 3 from bytecblock + +## arg + +- Syntax: `arg N` ∋ N: an arg index +- Bytecode: 0x2c {uint8} +- Stack: ... → ..., []byte +- Nth LogicSig argument +- Mode: Signature + +## arg_0 + +- Bytecode: 0x2d +- Stack: ... → ..., []byte +- LogicSig argument 0 +- Mode: Signature + +## arg_1 + +- Bytecode: 0x2e +- Stack: ... → ..., []byte +- LogicSig argument 1 +- Mode: Signature + +## arg_2 + +- Bytecode: 0x2f +- Stack: ... → ..., []byte +- LogicSig argument 2 +- Mode: Signature + +## arg_3 + +- Bytecode: 0x30 +- Stack: ... → ..., []byte +- LogicSig argument 3 +- Mode: Signature + +## txn + +- Syntax: `txn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x31 {uint8} +- Stack: ... → ..., any +- field F of current transaction + +### txn + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | Sender | address | | 32 byte address | +| 1 | Fee | uint64 | | microalgos | +| 2 | FirstValid | uint64 | | round number | +| 3 | FirstValidTime | uint64 | v7 | UNIX timestamp of block before txn.FirstValid. Fails if negative | +| 4 | LastValid | uint64 | | round number | +| 5 | Note | []byte | | Any data up to 1024 bytes | +| 6 | Lease | [32]byte | | 32 byte lease value | +| 7 | Receiver | address | | 32 byte address | +| 8 | Amount | uint64 | | microalgos | +| 9 | CloseRemainderTo | address | | 32 byte address | +| 10 | VotePK | [32]byte | | 32 byte address | +| 11 | SelectionPK | [32]byte | | 32 byte address | +| 12 | VoteFirst | uint64 | | The first round that the participation key is valid. | +| 13 | VoteLast | uint64 | | The last round that the participation key is valid. | +| 14 | VoteKeyDilution | uint64 | | Dilution for the 2-level participation key | +| 15 | Type | []byte | | Transaction type as bytes | +| 16 | TypeEnum | uint64 | | Transaction type as integer | +| 17 | XferAsset | uint64 | | Asset ID | +| 18 | AssetAmount | uint64 | | value in Asset's units | +| 19 | AssetSender | address | | 32 byte address. Source of assets if Sender is the Asset's Clawback address. | +| 20 | AssetReceiver | address | | 32 byte address | +| 21 | AssetCloseTo | address | | 32 byte address | +| 22 | GroupIndex | uint64 | | Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1 | +| 23 | TxID | [32]byte | | The computed ID for this transaction. 32 bytes. | +| 24 | ApplicationID | uint64 | v2 | ApplicationID from ApplicationCall transaction | +| 25 | OnCompletion | uint64 | v2 | ApplicationCall transaction on completion action | +| 27 | NumAppArgs | uint64 | v2 | Number of ApplicationArgs | +| 29 | NumAccounts | uint64 | v2 | Number of Accounts | +| 30 | ApprovalProgram | []byte | v2 | Approval program | +| 31 | ClearStateProgram | []byte | v2 | Clear state program | +| 32 | RekeyTo | address | v2 | 32 byte Sender's new AuthAddr | +| 33 | ConfigAsset | uint64 | v2 | Asset ID in asset config transaction | +| 34 | ConfigAssetTotal | uint64 | v2 | Total number of units of this asset created | +| 35 | ConfigAssetDecimals | uint64 | v2 | Number of digits to display after the decimal place when displaying the asset | +| 36 | ConfigAssetDefaultFrozen | bool | v2 | Whether the asset's slots are frozen by default or not, 0 or 1 | +| 37 | ConfigAssetUnitName | []byte | v2 | Unit name of the asset | +| 38 | ConfigAssetName | []byte | v2 | The asset name | +| 39 | ConfigAssetURL | []byte | v2 | URL | +| 40 | ConfigAssetMetadataHash | [32]byte | v2 | 32 byte commitment to unspecified asset metadata | +| 41 | ConfigAssetManager | address | v2 | 32 byte address | +| 42 | ConfigAssetReserve | address | v2 | 32 byte address | +| 43 | ConfigAssetFreeze | address | v2 | 32 byte address | +| 44 | ConfigAssetClawback | address | v2 | 32 byte address | +| 45 | FreezeAsset | uint64 | v2 | Asset ID being frozen or un-frozen | +| 46 | FreezeAssetAccount | address | v2 | 32 byte address of the account whose asset slot is being frozen or un-frozen | +| 47 | FreezeAssetFrozen | bool | v2 | The new frozen value, 0 or 1 | +| 49 | NumAssets | uint64 | v3 | Number of Assets | +| 51 | NumApplications | uint64 | v3 | Number of Applications | +| 52 | GlobalNumUint | uint64 | v3 | Number of global state integers in ApplicationCall | +| 53 | GlobalNumByteSlice | uint64 | v3 | Number of global state byteslices in ApplicationCall | +| 54 | LocalNumUint | uint64 | v3 | Number of local state integers in ApplicationCall | +| 55 | LocalNumByteSlice | uint64 | v3 | Number of local state byteslices in ApplicationCall | +| 56 | ExtraProgramPages | uint64 | v4 | Number of additional pages for each of the application's approval and clear state programs. An ExtraProgramPages of 1 means 2048 more total bytes, or 1024 for each program. | +| 57 | Nonparticipation | bool | v5 | Marks an account nonparticipating for rewards | +| 59 | NumLogs | uint64 | v5 | Number of Logs (only with `itxn` in v5). Application mode only | +| 60 | CreatedAssetID | uint64 | v5 | Asset ID allocated by the creation of an ASA (only with `itxn` in v5). Application mode only | +| 61 | CreatedApplicationID | uint64 | v5 | ApplicationID allocated by the creation of an application (only with `itxn` in v5). Application mode only | +| 62 | LastLog | []byte | v6 | The last message emitted. Empty bytes if none were emitted. Application mode only | +| 63 | StateProofPK | []byte | v6 | 64 byte state proof public key | +| 65 | NumApprovalProgramPages | uint64 | v7 | Number of Approval Program pages | +| 67 | NumClearStateProgramPages | uint64 | v7 | Number of ClearState Program pages | + + +## global + +- Syntax: `global F` ∋ F: [global](#field-group-global) +- Bytecode: 0x32 {uint8} +- Stack: ... → ..., any +- global field F + +### global + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | MinTxnFee | uint64 | | microalgos | +| 1 | MinBalance | uint64 | | microalgos | +| 2 | MaxTxnLife | uint64 | | rounds | +| 3 | ZeroAddress | address | | 32 byte address of all zero bytes | +| 4 | GroupSize | uint64 | | Number of transactions in this atomic transaction group. At least 1 | +| 5 | LogicSigVersion | uint64 | v2 | Maximum supported version | +| 6 | Round | uint64 | v2 | Current round number. Application mode only. | +| 7 | LatestTimestamp | uint64 | v2 | Last confirmed block UNIX timestamp. Fails if negative. Application mode only. | +| 8 | CurrentApplicationID | uint64 | v2 | ID of current application executing. Application mode only. | +| 9 | CreatorAddress | address | v3 | Address of the creator of the current application. Application mode only. | +| 10 | CurrentApplicationAddress | address | v5 | Address that the current application controls. Application mode only. | +| 11 | GroupID | [32]byte | v5 | ID of the transaction group. 32 zero bytes if the transaction is not part of a group. | +| 12 | OpcodeBudget | uint64 | v6 | The remaining cost that can be spent by opcodes in this program. | +| 13 | CallerApplicationID | uint64 | v6 | The application ID of the application that called this application. 0 if this application is at the top-level. Application mode only. | +| 14 | CallerApplicationAddress | address | v6 | The application address of the application that called this application. ZeroAddress if this application is at the top-level. Application mode only. | + + +## gtxn + +- Syntax: `gtxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0x33 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the current group + +for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`. + +## load + +- Syntax: `load I` ∋ I: position in scratch space to load from +- Bytecode: 0x34 {uint8} +- Stack: ... → ..., any +- Ith scratch space value. All scratch spaces are 0 at program start. + +## store + +- Syntax: `store I` ∋ I: position in scratch space to store to +- Bytecode: 0x35 {uint8} +- Stack: ..., A → ... +- store A to the Ith scratch space + +## txna + +- Syntax: `txna F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x36 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the current transaction
`txna` can be called using `txn` with 2 immediates. +- Availability: v2 + +### txna + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 26 | ApplicationArgs | []byte | v2 | Arguments passed to the application in the ApplicationCall transaction | +| 28 | Accounts | address | v2 | Accounts listed in the ApplicationCall transaction | +| 48 | Assets | uint64 | v3 | Foreign Assets listed in the ApplicationCall transaction | +| 50 | Applications | uint64 | v3 | Foreign Apps listed in the ApplicationCall transaction | +| 58 | Logs | []byte | v5 | Log messages emitted by an application call (only with `itxn` in v5). Application mode only | +| 64 | ApprovalProgramPages | []byte | v7 | Approval Program as an array of pages | +| 66 | ClearStateProgramPages | []byte | v7 | ClearState Program as an array of pages | + + +## gtxna + +- Syntax: `gtxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x37 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the current group
`gtxna` can be called using `gtxn` with 3 immediates. +- Availability: v2 + +## gtxns + +- Syntax: `gtxns F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x38 {uint8} +- Stack: ..., A: uint64 → ..., any +- field F of the Ath transaction in the current group +- Availability: v3 + +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. + +## gtxnsa + +- Syntax: `gtxnsa F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x39 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith value of the array field F from the Ath transaction in the current group
`gtxnsa` can be called using `gtxns` with 2 immediates. +- Availability: v3 + +## gload + +- Syntax: `gload T I` ∋ T: transaction group index, I: position in scratch space to load from +- Bytecode: 0x3a {uint8}, {uint8} +- Stack: ... → ..., any +- Ith scratch space value of the Tth transaction in the current group +- Availability: v4 +- Mode: Application + +`gload` fails unless the requested transaction is an ApplicationCall and T < GroupIndex. + +## gloads + +- Syntax: `gloads I` ∋ I: position in scratch space to load from +- Bytecode: 0x3b {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith scratch space value of the Ath transaction in the current group +- Availability: v4 +- Mode: Application + +`gloads` fails unless the requested transaction is an ApplicationCall and A < GroupIndex. + +## gaid + +- Syntax: `gaid T` ∋ T: transaction group index +- Bytecode: 0x3c {uint8} +- Stack: ... → ..., uint64 +- ID of the asset or application created in the Tth transaction of the current group +- Availability: v4 +- Mode: Application + +`gaid` fails unless the requested transaction created an asset or application and T < GroupIndex. + +## gaids + +- Bytecode: 0x3d +- Stack: ..., A: uint64 → ..., uint64 +- ID of the asset or application created in the Ath transaction of the current group +- Availability: v4 +- Mode: Application + +`gaids` fails unless the requested transaction created an asset or application and A < GroupIndex. + +## loads + +- Bytecode: 0x3e +- Stack: ..., A: uint64 → ..., any +- Ath scratch space value. All scratch spaces are 0 at program start. +- Availability: v5 + +## stores + +- Bytecode: 0x3f +- Stack: ..., A: uint64, B → ... +- store B to the Ath scratch space +- Availability: v5 + +## bnz + +- Syntax: `bnz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x40 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is not zero + +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. + +At 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.) + +## bz + +- Syntax: `bz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x41 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is zero +- Availability: v2 + +See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`. + +## b + +- Syntax: `b TARGET` ∋ TARGET: branch offset +- Bytecode: 0x42 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET +- Availability: v2 + +See `bnz` for details on how branches work. `b` always jumps to the offset. + +## return + +- Bytecode: 0x43 +- Stack: ..., A: uint64 → _exits_ +- use A as success value; end +- Availability: v2 + +## assert + +- Bytecode: 0x44 +- Stack: ..., A: uint64 → ... +- immediately fail unless A is a non-zero number +- Availability: v3 + +## pop + +- Bytecode: 0x48 +- Stack: ..., A → ... +- discard A + +## dup + +- Bytecode: 0x49 +- Stack: ..., A → ..., A, A +- duplicate A + +## dup2 + +- Bytecode: 0x4a +- Stack: ..., A, B → ..., A, B, A, B +- duplicate A and B +- Availability: v2 + +## dig + +- Syntax: `dig N` ∋ N: depth +- Bytecode: 0x4b {uint8} +- Stack: ..., A, [N items] → ..., A, [N items], A +- Nth value from the top of the stack. dig 0 is equivalent to dup +- Availability: v3 + +## swap + +- Bytecode: 0x4c +- Stack: ..., A, B → ..., B, A +- swaps A and B on stack +- Availability: v3 + +## select + +- Bytecode: 0x4d +- Stack: ..., A, B, C: uint64 → ..., A or B +- selects one of two values based on top-of-stack: B if C != 0, else A +- Availability: v3 + +## cover + +- Syntax: `cover N` ∋ N: depth +- Bytecode: 0x4e {uint8} +- Stack: ..., [N items], A → ..., A, [N items] +- remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth <= N. +- Availability: v5 + +## uncover + +- Syntax: `uncover N` ∋ N: depth +- Bytecode: 0x4f {uint8} +- Stack: ..., A, [N items] → ..., [N items], A +- 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. +- Availability: v5 + +## concat + +- Bytecode: 0x50 +- Stack: ..., A: []byte, B: []byte → ..., []byte +- join A and B +- Availability: v2 + +`concat` fails if the result would be greater than 4096 bytes. + +## substring + +- Syntax: `substring S E` ∋ S: start position, E: end position +- Bytecode: 0x51 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v2 + +## substring3 + +- Bytecode: 0x52 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v2 + +## getbit + +- Bytecode: 0x53 +- Stack: ..., A, B: uint64 → ..., uint64 +- 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 +- Availability: v3 + +see explanation of bit ordering in setbit + +## setbit + +- Bytecode: 0x54 +- Stack: ..., A, B: uint64, C: uint64 → ..., any +- 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 +- Availability: v3 + +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. + +## getbyte + +- Bytecode: 0x55 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails +- Availability: v3 + +## setbyte + +- Bytecode: 0x56 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v3 + +## extract + +- Syntax: `extract S L` ∋ S: start position, L: length +- Bytecode: 0x57 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v5 + +## extract3 + +- Bytecode: 0x58 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- A range of bytes from A starting at B up to but not including B+C. If B+C is larger than the array length, the program fails
`extract3` can be called using `extract` with no immediates. +- Availability: v5 + +## extract_uint16 + +- Bytecode: 0x59 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- 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 +- Availability: v5 + +## extract_uint32 + +- Bytecode: 0x5a +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- 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 +- Availability: v5 + +## extract_uint64 + +- Bytecode: 0x5b +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- A uint64 formed from a range of big-endian bytes from A starting at B up to but not including B+8. If B+8 is larger than the array length, the program fails +- Availability: v5 + +## replace2 + +- Syntax: `replace2 S` ∋ S: start position +- Bytecode: 0x5c {uint8} +- Stack: ..., A: []byte, B: []byte → ..., []byte +- Copy of A with the bytes starting at S replaced by the bytes of B. Fails if S+len(B) exceeds len(A)
`replace2` can be called using `replace` with 1 immediate. +- Availability: v7 + +## replace3 + +- Bytecode: 0x5d +- Stack: ..., A: []byte, B: uint64, C: []byte → ..., []byte +- Copy of A with the bytes starting at B replaced by the bytes of C. Fails if B+len(C) exceeds len(A)
`replace3` can be called using `replace` with no immediates. +- Availability: v7 + +## base64_decode + +- Syntax: `base64_decode E` ∋ E: [base64](#field-group-base64) +- Bytecode: 0x5e {uint8} +- Stack: ..., A: []byte → ..., []byte +- decode A which was base64-encoded using _encoding_ E. Fail if A is not base64 encoded with encoding E +- **Cost**: 1 + 1 per 16 bytes of A +- Availability: v7 + +### base64 + +Encodings + +| Index | Name | Notes | +| - | ------ | --------- | +| 0 | URLEncoding | | +| 1 | StdEncoding | | + + +*Warning*: Usage should be restricted to very rare use cases. In almost all cases, smart contracts should directly handle non-encoded byte-strings. This 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. + + 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`. + +## json_ref + +- Syntax: `json_ref R` ∋ R: [json_ref](#field-group-json_ref) +- Bytecode: 0x5f {uint8} +- Stack: ..., A: []byte, B: []byte → ..., any +- key B's value, of type R, from a [valid](jsonspec.md) utf-8 encoded json object A +- **Cost**: 25 + 2 per 7 bytes of A +- Availability: v7 + +### json_ref + +Types + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | JSONString | []byte | | +| 1 | JSONUint64 | uint64 | | +| 2 | JSONObject | []byte | | + + +*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. + +Almost 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. + +## balance + +- Bytecode: 0x60 +- Stack: ..., A → ..., uint64 +- 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` +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## app_opted_in + +- Bytecode: 0x61 +- Stack: ..., A, B: uint64 → ..., bool +- 1 if account A is opted in to application B, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_get + +- Bytecode: 0x62 +- Stack: ..., A, B: []byte → ..., any +- local state of the key B in the current application in account A +- Availability: v2 +- Mode: Application + +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. + +## app_local_get_ex + +- Bytecode: 0x63 +- Stack: ..., A, B: uint64, C: []byte → ..., X: any, Y: bool +- X is the local state of application B, key C in account A. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_global_get + +- Bytecode: 0x64 +- Stack: ..., A: []byte → ..., any +- global state of the key A in the current application +- Availability: v2 +- Mode: Application + +params: state key. Return: value. The value is zero (of type uint64) if the key does not exist. + +## app_global_get_ex + +- Bytecode: 0x65 +- Stack: ..., A: uint64, B: []byte → ..., X: any, Y: bool +- X is the global state of application A, key B. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_put + +- Bytecode: 0x66 +- Stack: ..., A, B: []byte, C → ... +- write C to key B in account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value. + +## app_global_put + +- Bytecode: 0x67 +- Stack: ..., A: []byte, B → ... +- write B to key A in the global state of the current application +- Availability: v2 +- Mode: Application + +## app_local_del + +- Bytecode: 0x68 +- Stack: ..., A, B: []byte → ... +- delete key B from account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. + +Deleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.) + +## app_global_del + +- Bytecode: 0x69 +- Stack: ..., A: []byte → ... +- delete key A from the global state of the current application +- Availability: v2 +- Mode: Application + +params: state key. + +Deleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.) + +## asset_holding_get + +- Syntax: `asset_holding_get F` ∋ F: [asset_holding](#field-group-asset_holding) +- Bytecode: 0x70 {uint8} +- Stack: ..., A, B: uint64 → ..., X: any, Y: bool +- X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0 +- Availability: v2 +- Mode: Application + +### asset_holding + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetBalance | uint64 | Amount of the asset unit held by this account | +| 1 | AssetFrozen | bool | Is the asset frozen or not | + + +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. + +## asset_params_get + +- Syntax: `asset_params_get F` ∋ F: [asset_params](#field-group-asset_params) +- Bytecode: 0x71 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from asset A. Y is 1 if A exists, else 0 +- Availability: v2 +- Mode: Application + +### asset_params + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | AssetTotal | uint64 | | Total number of units of this asset | +| 1 | AssetDecimals | uint64 | | See AssetParams.Decimals | +| 2 | AssetDefaultFrozen | bool | | Frozen by default or not | +| 3 | AssetUnitName | []byte | | Asset unit name | +| 4 | AssetName | []byte | | Asset name | +| 5 | AssetURL | []byte | | URL with additional info about the asset | +| 6 | AssetMetadataHash | [32]byte | | Arbitrary commitment | +| 7 | AssetManager | address | | Manager address | +| 8 | AssetReserve | address | | Reserve address | +| 9 | AssetFreeze | address | | Freeze address | +| 10 | AssetClawback | address | | Clawback address | +| 11 | AssetCreator | address | v5 | Creator address | + + +params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value. + +## app_params_get + +- Syntax: `app_params_get F` ∋ F: [app_params](#field-group-app_params) +- Bytecode: 0x72 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from app A. Y is 1 if A exists, else 0 +- Availability: v5 +- Mode: Application + +### app_params + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AppApprovalProgram | []byte | Bytecode of Approval Program | +| 1 | AppClearStateProgram | []byte | Bytecode of Clear State Program | +| 2 | AppGlobalNumUint | uint64 | Number of uint64 values allowed in Global State | +| 3 | AppGlobalNumByteSlice | uint64 | Number of byte array values allowed in Global State | +| 4 | AppLocalNumUint | uint64 | Number of uint64 values allowed in Local State | +| 5 | AppLocalNumByteSlice | uint64 | Number of byte array values allowed in Local State | +| 6 | AppExtraProgramPages | uint64 | Number of Extra Program Pages of code space | +| 7 | AppCreator | address | Creator address | +| 8 | AppAddress | address | Address for which this application has authority | + + +params: Txn.ForeignApps offset or an _available_ app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value. + +## acct_params_get + +- Syntax: `acct_params_get F` ∋ F: [acct_params](#field-group-acct_params) +- Bytecode: 0x73 {uint8} +- Stack: ..., A → ..., X: any, Y: bool +- X is field F from account A. Y is 1 if A owns positive algos, else 0 +- Availability: v6 +- Mode: Application + +### acct_params + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AcctBalance | uint64 | Account balance in microalgos | +| 1 | AcctMinBalance | uint64 | Minimum required balance for account, in microalgos | +| 2 | AcctAuthAddr | address | Address the account is rekeyed to. | + + +## min_balance + +- Bytecode: 0x78 +- Stack: ..., A → ..., uint64 +- 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. +- Availability: v3 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## pushbytes + +- Syntax: `pushbytes BYTES` ∋ BYTES: a byte constant +- Bytecode: 0x80 {varuint length, bytes} +- Stack: ... → ..., []byte +- immediate BYTES +- Availability: v3 + +pushbytes args are not added to the bytecblock during assembly processes + +## pushint + +- Syntax: `pushint UINT` ∋ UINT: an int constant +- Bytecode: 0x81 {varuint} +- Stack: ... → ..., uint64 +- immediate UINT +- Availability: v3 + +pushint args are not added to the intcblock during assembly processes + +## ed25519verify_bare + +- Bytecode: 0x84 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of the data against the pubkey => {0 or 1} +- **Cost**: 1900 +- Availability: v7 + +## callsub + +- Syntax: `callsub TARGET` ∋ TARGET: branch offset +- Bytecode: 0x88 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET, saving the next instruction on the call stack +- Availability: v4 + +The call stack is separate from the data stack. Only `callsub`, `retsub`, and `proto` manipulate it. + +## retsub + +- Bytecode: 0x89 +- Stack: ... → ... +- pop the top instruction from the call stack and branch to it +- Availability: v4 + +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. + +## shl + +- Bytecode: 0x90 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times 2^B, modulo 2^64 +- Availability: v4 + +## shr + +- Bytecode: 0x91 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by 2^B +- Availability: v4 + +## sqrt + +- Bytecode: 0x92 +- Stack: ..., A: uint64 → ..., uint64 +- The largest integer I such that I^2 <= A +- **Cost**: 4 +- Availability: v4 + +## bitlen + +- Bytecode: 0x93 +- Stack: ..., A → ..., uint64 +- 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 +- Availability: v4 + +bitlen interprets arrays as big-endian integers, unlike setbit/getbit + +## exp + +- Bytecode: 0x94 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A raised to the Bth power. Fail if A == B == 0 and on overflow +- Availability: v4 + +## expw + +- Bytecode: 0x95 +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- 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 +- **Cost**: 10 +- Availability: v4 + +## bsqrt + +- Bytecode: 0x96 +- Stack: ..., A: []byte → ..., []byte +- The largest integer I such that I^2 <= A. A and I are interpreted as big-endian unsigned integers +- **Cost**: 40 +- Availability: v6 + +## divw + +- Bytecode: 0x97 +- Stack: ..., A: uint64, B: uint64, C: uint64 → ..., uint64 +- A,B / C. Fail if C == 0 or if result overflows. +- Availability: v6 + +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. + +## sha3_256 + +- Bytecode: 0x98 +- Stack: ..., A: []byte → ..., []byte +- SHA3_256 hash of value A, yields [32]byte +- **Cost**: 130 +- Availability: v7 + +## b+ + +- Bytecode: 0xa0 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A plus B. A and B are interpreted as big-endian unsigned integers +- **Cost**: 10 +- Availability: v4 + +## b- + +- Bytecode: 0xa1 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow. +- **Cost**: 10 +- Availability: v4 + +## b/ + +- Bytecode: 0xa2 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b* + +- Bytecode: 0xa3 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A times B. A and B are interpreted as big-endian unsigned integers. +- **Cost**: 20 +- Availability: v4 + +## b< + +- Bytecode: 0xa4 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b> + +- Bytecode: 0xa5 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b<= + +- Bytecode: 0xa6 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b>= + +- Bytecode: 0xa7 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b== + +- Bytecode: 0xa8 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b!= + +- Bytecode: 0xa9 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b% + +- Bytecode: 0xaa +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b| + +- Bytecode: 0xab +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-or B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b& + +- Bytecode: 0xac +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-and B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b^ + +- Bytecode: 0xad +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-xor B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b~ + +- Bytecode: 0xae +- Stack: ..., A: []byte → ..., []byte +- A with all bits inverted +- **Cost**: 4 +- Availability: v4 + +## bzero + +- Bytecode: 0xaf +- Stack: ..., A: uint64 → ..., []byte +- zero filled byte-array of length A +- Availability: v4 + +## log + +- Bytecode: 0xb0 +- Stack: ..., A: []byte → ... +- write A to log state of the current application +- Availability: v5 +- Mode: Application + +`log` fails if called more than MaxLogCalls times in a program, or if the sum of logged bytes exceeds 1024 bytes. + +## itxn_begin + +- Bytecode: 0xb1 +- Stack: ... → ... +- begin preparation of a new inner transaction in a new transaction group +- Availability: v5 +- Mode: Application + +`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. + +## itxn_field + +- Syntax: `itxn_field F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0xb2 {uint8} +- Stack: ..., A → ... +- set field F of the current inner transaction to A +- Availability: v5 +- Mode: Application + +`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_.) + +## itxn_submit + +- Bytecode: 0xb3 +- Stack: ... → ... +- 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. +- Availability: v5 +- Mode: Application + +`itxn_submit` resets the current transaction so that it can not be resubmitted. A new `itxn_begin` is required to prepare another inner transaction. + +## itxn + +- Syntax: `itxn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0xb4 {uint8} +- Stack: ... → ..., any +- field F of the last inner transaction +- Availability: v5 +- Mode: Application + +## itxna + +- Syntax: `itxna F I` ∋ F: [txna](#field-group-txna), I: a transaction field array index +- Bytecode: 0xb5 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the last inner transaction +- Availability: v5 +- Mode: Application + +## itxn_next + +- Bytecode: 0xb6 +- Stack: ... → ... +- begin preparation of a new inner transaction in the same transaction group +- Availability: v6 +- Mode: Application + +`itxn_next` initializes the transaction exactly as `itxn_begin` does + +## gitxn + +- Syntax: `gitxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0xb7 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## gitxna + +- Syntax: `gitxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0xb8 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## txnas + +- Syntax: `txnas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc0 {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F of the current transaction +- Availability: v5 + +## gtxnas + +- Syntax: `gtxnas T F` ∋ T: transaction group index, F: [txna](#field-group-txna) +- Bytecode: 0xc1 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F from the Tth transaction in the current group +- Availability: v5 + +## gtxnsas + +- Syntax: `gtxnsas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc2 {uint8} +- Stack: ..., A: uint64, B: uint64 → ..., any +- Bth value of the array field F from the Ath transaction in the current group +- Availability: v5 + +## args + +- Bytecode: 0xc3 +- Stack: ..., A: uint64 → ..., []byte +- Ath LogicSig argument +- Availability: v5 +- Mode: Signature + +## gloadss + +- Bytecode: 0xc4 +- Stack: ..., A: uint64, B: uint64 → ..., any +- Bth scratch space value of the Ath transaction in the current group +- Availability: v6 +- Mode: Application + +## itxnas + +- Syntax: `itxnas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc5 {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F of the last inner transaction +- Availability: v6 +- Mode: Application + +## gitxnas + +- Syntax: `gitxnas T F` ∋ T: transaction group index, F: [txna](#field-group-txna) +- Bytecode: 0xc6 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F from the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## vrf_verify + +- Syntax: `vrf_verify S` ∋ S: [vrf_verify](#field-group-vrf_verify) +- Bytecode: 0xd0 {uint8} +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., X: []byte, Y: bool +- Verify the proof B of message A against pubkey C. Returns vrf output and verification flag. +- **Cost**: 5700 +- Availability: v7 + +### vrf_verify + +Standards + +| Index | Name | Notes | +| - | ------ | --------- | +| 0 | VrfAlgorand | | + + +`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/). + +## block + +- Syntax: `block F` ∋ F: [block](#field-group-block) +- Bytecode: 0xd1 {uint8} +- Stack: ..., A: uint64 → ..., any +- field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive) +- Availability: v7 + +### block + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | BlkSeed | []byte | | +| 1 | BlkTimestamp | uint64 | | + diff --git a/data/transactions/logic/TEAL_opcodes_v8.md b/data/transactions/logic/TEAL_opcodes_v8.md new file mode 100644 index 0000000000..b2d1b851d6 --- /dev/null +++ b/data/transactions/logic/TEAL_opcodes_v8.md @@ -0,0 +1,1640 @@ +# v8 Opcodes + +Ops have a 'cost' of 1 unless otherwise specified. + + +## err + +- Bytecode: 0x00 +- Stack: ... → _exits_ +- Fail immediately. + +## sha256 + +- Bytecode: 0x01 +- Stack: ..., A: []byte → ..., [32]byte +- SHA256 hash of value A, yields [32]byte +- **Cost**: 35 + +## keccak256 + +- Bytecode: 0x02 +- Stack: ..., A: []byte → ..., [32]byte +- Keccak256 hash of value A, yields [32]byte +- **Cost**: 130 + +## sha512_256 + +- Bytecode: 0x03 +- Stack: ..., A: []byte → ..., [32]byte +- SHA512_256 hash of value A, yields [32]byte +- **Cost**: 45 + +## ed25519verify + +- Bytecode: 0x04 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1} +- **Cost**: 1900 + +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. + +## ecdsa_verify + +- Syntax: `ecdsa_verify V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x05 {uint8} +- Stack: ..., A: []byte, B: []byte, C: []byte, D: []byte, E: []byte → ..., bool +- for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1} +- **Cost**: Secp256k1=1700; Secp256r1=2500 +- Availability: v5 + +### ECDSA + +Curves + +| Index | Name | In | Notes | +| - | ------ | - | --------- | +| 0 | Secp256k1 | | secp256k1 curve, used in Bitcoin | +| 1 | Secp256r1 | v7 | secp256r1 curve, NIST standard | + + +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. + +## ecdsa_pk_decompress + +- Syntax: `ecdsa_pk_decompress V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x06 {uint8} +- Stack: ..., A: []byte → ..., X: []byte, Y: []byte +- decompress pubkey A into components X, Y +- **Cost**: Secp256k1=650; Secp256r1=2400 +- Availability: v5 + +The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded. + +## ecdsa_pk_recover + +- Syntax: `ecdsa_pk_recover V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x07 {uint8} +- Stack: ..., A: []byte, B: uint64, C: []byte, D: []byte → ..., X: []byte, Y: []byte +- for (data A, recovery id B, signature C, D) recover a public key +- **Cost**: 2000 +- Availability: v5 + +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. + +## + + +- Bytecode: 0x08 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A plus B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`. + +## - + +- Bytecode: 0x09 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A minus B. Fail if B > A. + +## / + +- Bytecode: 0x0a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by B (truncated division). Fail if B == 0. + +`divmodw` is available to divide the two-element values produced by `mulw` and `addw`. + +## * + +- Bytecode: 0x0b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`. + +## < + +- Bytecode: 0x0c +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than B => {0 or 1} + +## > + +- Bytecode: 0x0d +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than B => {0 or 1} + +## <= + +- Bytecode: 0x0e +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than or equal to B => {0 or 1} + +## >= + +- Bytecode: 0x0f +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than or equal to B => {0 or 1} + +## && + +- Bytecode: 0x10 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero and B is not zero => {0 or 1} + +## || + +- Bytecode: 0x11 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero or B is not zero => {0 or 1} + +## == + +- Bytecode: 0x12 +- Stack: ..., A, B → ..., bool +- A is equal to B => {0 or 1} + +## != + +- Bytecode: 0x13 +- Stack: ..., A, B → ..., bool +- A is not equal to B => {0 or 1} + +## ! + +- Bytecode: 0x14 +- Stack: ..., A: uint64 → ..., uint64 +- A == 0 yields 1; else 0 + +## len + +- Bytecode: 0x15 +- Stack: ..., A: []byte → ..., uint64 +- yields length of byte value A + +## itob + +- Bytecode: 0x16 +- Stack: ..., A: uint64 → ..., []byte +- converts uint64 A to big-endian byte array, always of length 8 + +## btoi + +- Bytecode: 0x17 +- Stack: ..., A: []byte → ..., uint64 +- converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8. + +`btoi` fails if the input is longer than 8 bytes. + +## % + +- Bytecode: 0x18 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A modulo B. Fail if B == 0. + +## | + +- Bytecode: 0x19 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-or B + +## & + +- Bytecode: 0x1a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-and B + +## ^ + +- Bytecode: 0x1b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-xor B + +## ~ + +- Bytecode: 0x1c +- Stack: ..., A: uint64 → ..., uint64 +- bitwise invert value A + +## mulw + +- Bytecode: 0x1d +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low + +## addw + +- Bytecode: 0x1e +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits. +- Availability: v2 + +## divmodw + +- Bytecode: 0x1f +- Stack: ..., A: uint64, B: uint64, C: uint64, D: uint64 → ..., W: uint64, X: uint64, Y: uint64, Z: uint64 +- W,X = (A,B / C,D); Y,Z = (A,B modulo C,D) +- **Cost**: 20 +- Availability: v4 + +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. + +## intcblock + +- Syntax: `intcblock UINT ...` ∋ UINT ...: a block of int constant values +- Bytecode: 0x20 {varuint count, [varuint ...]} +- Stack: ... → ... +- prepare block of uint64 constants for use by intc + +`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. + +## intc + +- Syntax: `intc I` ∋ I: an index in the intcblock +- Bytecode: 0x21 {uint8} +- Stack: ... → ..., uint64 +- Ith constant from intcblock + +## intc_0 + +- Bytecode: 0x22 +- Stack: ... → ..., uint64 +- constant 0 from intcblock + +## intc_1 + +- Bytecode: 0x23 +- Stack: ... → ..., uint64 +- constant 1 from intcblock + +## intc_2 + +- Bytecode: 0x24 +- Stack: ... → ..., uint64 +- constant 2 from intcblock + +## intc_3 + +- Bytecode: 0x25 +- Stack: ... → ..., uint64 +- constant 3 from intcblock + +## bytecblock + +- Syntax: `bytecblock BYTES ...` ∋ BYTES ...: a block of byte constant values +- Bytecode: 0x26 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ... +- prepare block of byte-array constants for use by bytec + +`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. + +## bytec + +- Syntax: `bytec I` ∋ I: an index in the bytecblock +- Bytecode: 0x27 {uint8} +- Stack: ... → ..., []byte +- Ith constant from bytecblock + +## bytec_0 + +- Bytecode: 0x28 +- Stack: ... → ..., []byte +- constant 0 from bytecblock + +## bytec_1 + +- Bytecode: 0x29 +- Stack: ... → ..., []byte +- constant 1 from bytecblock + +## bytec_2 + +- Bytecode: 0x2a +- Stack: ... → ..., []byte +- constant 2 from bytecblock + +## bytec_3 + +- Bytecode: 0x2b +- Stack: ... → ..., []byte +- constant 3 from bytecblock + +## arg + +- Syntax: `arg N` ∋ N: an arg index +- Bytecode: 0x2c {uint8} +- Stack: ... → ..., []byte +- Nth LogicSig argument +- Mode: Signature + +## arg_0 + +- Bytecode: 0x2d +- Stack: ... → ..., []byte +- LogicSig argument 0 +- Mode: Signature + +## arg_1 + +- Bytecode: 0x2e +- Stack: ... → ..., []byte +- LogicSig argument 1 +- Mode: Signature + +## arg_2 + +- Bytecode: 0x2f +- Stack: ... → ..., []byte +- LogicSig argument 2 +- Mode: Signature + +## arg_3 + +- Bytecode: 0x30 +- Stack: ... → ..., []byte +- LogicSig argument 3 +- Mode: Signature + +## txn + +- Syntax: `txn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x31 {uint8} +- Stack: ... → ..., any +- field F of current transaction + +### txn + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | Sender | address | | 32 byte address | +| 1 | Fee | uint64 | | microalgos | +| 2 | FirstValid | uint64 | | round number | +| 3 | FirstValidTime | uint64 | v7 | UNIX timestamp of block before txn.FirstValid. Fails if negative | +| 4 | LastValid | uint64 | | round number | +| 5 | Note | []byte | | Any data up to 1024 bytes | +| 6 | Lease | [32]byte | | 32 byte lease value | +| 7 | Receiver | address | | 32 byte address | +| 8 | Amount | uint64 | | microalgos | +| 9 | CloseRemainderTo | address | | 32 byte address | +| 10 | VotePK | [32]byte | | 32 byte address | +| 11 | SelectionPK | [32]byte | | 32 byte address | +| 12 | VoteFirst | uint64 | | The first round that the participation key is valid. | +| 13 | VoteLast | uint64 | | The last round that the participation key is valid. | +| 14 | VoteKeyDilution | uint64 | | Dilution for the 2-level participation key | +| 15 | Type | []byte | | Transaction type as bytes | +| 16 | TypeEnum | uint64 | | Transaction type as integer | +| 17 | XferAsset | uint64 | | Asset ID | +| 18 | AssetAmount | uint64 | | value in Asset's units | +| 19 | AssetSender | address | | 32 byte address. Source of assets if Sender is the Asset's Clawback address. | +| 20 | AssetReceiver | address | | 32 byte address | +| 21 | AssetCloseTo | address | | 32 byte address | +| 22 | GroupIndex | uint64 | | Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1 | +| 23 | TxID | [32]byte | | The computed ID for this transaction. 32 bytes. | +| 24 | ApplicationID | uint64 | v2 | ApplicationID from ApplicationCall transaction | +| 25 | OnCompletion | uint64 | v2 | ApplicationCall transaction on completion action | +| 27 | NumAppArgs | uint64 | v2 | Number of ApplicationArgs | +| 29 | NumAccounts | uint64 | v2 | Number of Accounts | +| 30 | ApprovalProgram | []byte | v2 | Approval program | +| 31 | ClearStateProgram | []byte | v2 | Clear state program | +| 32 | RekeyTo | address | v2 | 32 byte Sender's new AuthAddr | +| 33 | ConfigAsset | uint64 | v2 | Asset ID in asset config transaction | +| 34 | ConfigAssetTotal | uint64 | v2 | Total number of units of this asset created | +| 35 | ConfigAssetDecimals | uint64 | v2 | Number of digits to display after the decimal place when displaying the asset | +| 36 | ConfigAssetDefaultFrozen | bool | v2 | Whether the asset's slots are frozen by default or not, 0 or 1 | +| 37 | ConfigAssetUnitName | []byte | v2 | Unit name of the asset | +| 38 | ConfigAssetName | []byte | v2 | The asset name | +| 39 | ConfigAssetURL | []byte | v2 | URL | +| 40 | ConfigAssetMetadataHash | [32]byte | v2 | 32 byte commitment to unspecified asset metadata | +| 41 | ConfigAssetManager | address | v2 | 32 byte address | +| 42 | ConfigAssetReserve | address | v2 | 32 byte address | +| 43 | ConfigAssetFreeze | address | v2 | 32 byte address | +| 44 | ConfigAssetClawback | address | v2 | 32 byte address | +| 45 | FreezeAsset | uint64 | v2 | Asset ID being frozen or un-frozen | +| 46 | FreezeAssetAccount | address | v2 | 32 byte address of the account whose asset slot is being frozen or un-frozen | +| 47 | FreezeAssetFrozen | bool | v2 | The new frozen value, 0 or 1 | +| 49 | NumAssets | uint64 | v3 | Number of Assets | +| 51 | NumApplications | uint64 | v3 | Number of Applications | +| 52 | GlobalNumUint | uint64 | v3 | Number of global state integers in ApplicationCall | +| 53 | GlobalNumByteSlice | uint64 | v3 | Number of global state byteslices in ApplicationCall | +| 54 | LocalNumUint | uint64 | v3 | Number of local state integers in ApplicationCall | +| 55 | LocalNumByteSlice | uint64 | v3 | Number of local state byteslices in ApplicationCall | +| 56 | ExtraProgramPages | uint64 | v4 | Number of additional pages for each of the application's approval and clear state programs. An ExtraProgramPages of 1 means 2048 more total bytes, or 1024 for each program. | +| 57 | Nonparticipation | bool | v5 | Marks an account nonparticipating for rewards | +| 59 | NumLogs | uint64 | v5 | Number of Logs (only with `itxn` in v5). Application mode only | +| 60 | CreatedAssetID | uint64 | v5 | Asset ID allocated by the creation of an ASA (only with `itxn` in v5). Application mode only | +| 61 | CreatedApplicationID | uint64 | v5 | ApplicationID allocated by the creation of an application (only with `itxn` in v5). Application mode only | +| 62 | LastLog | []byte | v6 | The last message emitted. Empty bytes if none were emitted. Application mode only | +| 63 | StateProofPK | []byte | v6 | 64 byte state proof public key | +| 65 | NumApprovalProgramPages | uint64 | v7 | Number of Approval Program pages | +| 67 | NumClearStateProgramPages | uint64 | v7 | Number of ClearState Program pages | + + +## global + +- Syntax: `global F` ∋ F: [global](#field-group-global) +- Bytecode: 0x32 {uint8} +- Stack: ... → ..., any +- global field F + +### global + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | MinTxnFee | uint64 | | microalgos | +| 1 | MinBalance | uint64 | | microalgos | +| 2 | MaxTxnLife | uint64 | | rounds | +| 3 | ZeroAddress | address | | 32 byte address of all zero bytes | +| 4 | GroupSize | uint64 | | Number of transactions in this atomic transaction group. At least 1 | +| 5 | LogicSigVersion | uint64 | v2 | Maximum supported version | +| 6 | Round | uint64 | v2 | Current round number. Application mode only. | +| 7 | LatestTimestamp | uint64 | v2 | Last confirmed block UNIX timestamp. Fails if negative. Application mode only. | +| 8 | CurrentApplicationID | uint64 | v2 | ID of current application executing. Application mode only. | +| 9 | CreatorAddress | address | v3 | Address of the creator of the current application. Application mode only. | +| 10 | CurrentApplicationAddress | address | v5 | Address that the current application controls. Application mode only. | +| 11 | GroupID | [32]byte | v5 | ID of the transaction group. 32 zero bytes if the transaction is not part of a group. | +| 12 | OpcodeBudget | uint64 | v6 | The remaining cost that can be spent by opcodes in this program. | +| 13 | CallerApplicationID | uint64 | v6 | The application ID of the application that called this application. 0 if this application is at the top-level. Application mode only. | +| 14 | CallerApplicationAddress | address | v6 | The application address of the application that called this application. ZeroAddress if this application is at the top-level. Application mode only. | + + +## gtxn + +- Syntax: `gtxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0x33 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the current group + +for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`. + +## load + +- Syntax: `load I` ∋ I: position in scratch space to load from +- Bytecode: 0x34 {uint8} +- Stack: ... → ..., any +- Ith scratch space value. All scratch spaces are 0 at program start. + +## store + +- Syntax: `store I` ∋ I: position in scratch space to store to +- Bytecode: 0x35 {uint8} +- Stack: ..., A → ... +- store A to the Ith scratch space + +## txna + +- Syntax: `txna F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x36 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the current transaction
`txna` can be called using `txn` with 2 immediates. +- Availability: v2 + +### txna + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 26 | ApplicationArgs | []byte | v2 | Arguments passed to the application in the ApplicationCall transaction | +| 28 | Accounts | address | v2 | Accounts listed in the ApplicationCall transaction | +| 48 | Assets | uint64 | v3 | Foreign Assets listed in the ApplicationCall transaction | +| 50 | Applications | uint64 | v3 | Foreign Apps listed in the ApplicationCall transaction | +| 58 | Logs | []byte | v5 | Log messages emitted by an application call (only with `itxn` in v5). Application mode only | +| 64 | ApprovalProgramPages | []byte | v7 | Approval Program as an array of pages | +| 66 | ClearStateProgramPages | []byte | v7 | ClearState Program as an array of pages | + + +## gtxna + +- Syntax: `gtxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x37 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the current group
`gtxna` can be called using `gtxn` with 3 immediates. +- Availability: v2 + +## gtxns + +- Syntax: `gtxns F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x38 {uint8} +- Stack: ..., A: uint64 → ..., any +- field F of the Ath transaction in the current group +- Availability: v3 + +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. + +## gtxnsa + +- Syntax: `gtxnsa F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x39 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith value of the array field F from the Ath transaction in the current group
`gtxnsa` can be called using `gtxns` with 2 immediates. +- Availability: v3 + +## gload + +- Syntax: `gload T I` ∋ T: transaction group index, I: position in scratch space to load from +- Bytecode: 0x3a {uint8}, {uint8} +- Stack: ... → ..., any +- Ith scratch space value of the Tth transaction in the current group +- Availability: v4 +- Mode: Application + +`gload` fails unless the requested transaction is an ApplicationCall and T < GroupIndex. + +## gloads + +- Syntax: `gloads I` ∋ I: position in scratch space to load from +- Bytecode: 0x3b {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith scratch space value of the Ath transaction in the current group +- Availability: v4 +- Mode: Application + +`gloads` fails unless the requested transaction is an ApplicationCall and A < GroupIndex. + +## gaid + +- Syntax: `gaid T` ∋ T: transaction group index +- Bytecode: 0x3c {uint8} +- Stack: ... → ..., uint64 +- ID of the asset or application created in the Tth transaction of the current group +- Availability: v4 +- Mode: Application + +`gaid` fails unless the requested transaction created an asset or application and T < GroupIndex. + +## gaids + +- Bytecode: 0x3d +- Stack: ..., A: uint64 → ..., uint64 +- ID of the asset or application created in the Ath transaction of the current group +- Availability: v4 +- Mode: Application + +`gaids` fails unless the requested transaction created an asset or application and A < GroupIndex. + +## loads + +- Bytecode: 0x3e +- Stack: ..., A: uint64 → ..., any +- Ath scratch space value. All scratch spaces are 0 at program start. +- Availability: v5 + +## stores + +- Bytecode: 0x3f +- Stack: ..., A: uint64, B → ... +- store B to the Ath scratch space +- Availability: v5 + +## bnz + +- Syntax: `bnz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x40 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is not zero + +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. + +At 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.) + +## bz + +- Syntax: `bz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x41 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is zero +- Availability: v2 + +See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`. + +## b + +- Syntax: `b TARGET` ∋ TARGET: branch offset +- Bytecode: 0x42 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET +- Availability: v2 + +See `bnz` for details on how branches work. `b` always jumps to the offset. + +## return + +- Bytecode: 0x43 +- Stack: ..., A: uint64 → _exits_ +- use A as success value; end +- Availability: v2 + +## assert + +- Bytecode: 0x44 +- Stack: ..., A: uint64 → ... +- immediately fail unless A is a non-zero number +- Availability: v3 + +## bury + +- Syntax: `bury N` ∋ N: depth +- Bytecode: 0x45 {uint8} +- Stack: ..., A → ... +- replace the Nth value from the top of the stack with A. bury 0 fails. +- Availability: v8 + +## popn + +- Syntax: `popn N` ∋ N: stack depth +- Bytecode: 0x46 {uint8} +- Stack: ..., [N items] → ... +- remove N values from the top of the stack +- Availability: v8 + +## dupn + +- Syntax: `dupn N` ∋ N: copy count +- Bytecode: 0x47 {uint8} +- Stack: ..., A → ..., A, [N copies of A] +- duplicate A, N times +- Availability: v8 + +## pop + +- Bytecode: 0x48 +- Stack: ..., A → ... +- discard A + +## dup + +- Bytecode: 0x49 +- Stack: ..., A → ..., A, A +- duplicate A + +## dup2 + +- Bytecode: 0x4a +- Stack: ..., A, B → ..., A, B, A, B +- duplicate A and B +- Availability: v2 + +## dig + +- Syntax: `dig N` ∋ N: depth +- Bytecode: 0x4b {uint8} +- Stack: ..., A, [N items] → ..., A, [N items], A +- Nth value from the top of the stack. dig 0 is equivalent to dup +- Availability: v3 + +## swap + +- Bytecode: 0x4c +- Stack: ..., A, B → ..., B, A +- swaps A and B on stack +- Availability: v3 + +## select + +- Bytecode: 0x4d +- Stack: ..., A, B, C: uint64 → ..., A or B +- selects one of two values based on top-of-stack: B if C != 0, else A +- Availability: v3 + +## cover + +- Syntax: `cover N` ∋ N: depth +- Bytecode: 0x4e {uint8} +- Stack: ..., [N items], A → ..., A, [N items] +- remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth <= N. +- Availability: v5 + +## uncover + +- Syntax: `uncover N` ∋ N: depth +- Bytecode: 0x4f {uint8} +- Stack: ..., A, [N items] → ..., [N items], A +- 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. +- Availability: v5 + +## concat + +- Bytecode: 0x50 +- Stack: ..., A: []byte, B: []byte → ..., []byte +- join A and B +- Availability: v2 + +`concat` fails if the result would be greater than 4096 bytes. + +## substring + +- Syntax: `substring S E` ∋ S: start position, E: end position +- Bytecode: 0x51 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v2 + +## substring3 + +- Bytecode: 0x52 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v2 + +## getbit + +- Bytecode: 0x53 +- Stack: ..., A, B: uint64 → ..., uint64 +- 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 +- Availability: v3 + +see explanation of bit ordering in setbit + +## setbit + +- Bytecode: 0x54 +- Stack: ..., A, B: uint64, C: uint64 → ..., any +- 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 +- Availability: v3 + +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. + +## getbyte + +- Bytecode: 0x55 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails +- Availability: v3 + +## setbyte + +- Bytecode: 0x56 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v3 + +## extract + +- Syntax: `extract S L` ∋ S: start position, L: length +- Bytecode: 0x57 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v5 + +## extract3 + +- Bytecode: 0x58 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- A range of bytes from A starting at B up to but not including B+C. If B+C is larger than the array length, the program fails
`extract3` can be called using `extract` with no immediates. +- Availability: v5 + +## extract_uint16 + +- Bytecode: 0x59 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- 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 +- Availability: v5 + +## extract_uint32 + +- Bytecode: 0x5a +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- 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 +- Availability: v5 + +## extract_uint64 + +- Bytecode: 0x5b +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- A uint64 formed from a range of big-endian bytes from A starting at B up to but not including B+8. If B+8 is larger than the array length, the program fails +- Availability: v5 + +## replace2 + +- Syntax: `replace2 S` ∋ S: start position +- Bytecode: 0x5c {uint8} +- Stack: ..., A: []byte, B: []byte → ..., []byte +- Copy of A with the bytes starting at S replaced by the bytes of B. Fails if S+len(B) exceeds len(A)
`replace2` can be called using `replace` with 1 immediate. +- Availability: v7 + +## replace3 + +- Bytecode: 0x5d +- Stack: ..., A: []byte, B: uint64, C: []byte → ..., []byte +- Copy of A with the bytes starting at B replaced by the bytes of C. Fails if B+len(C) exceeds len(A)
`replace3` can be called using `replace` with no immediates. +- Availability: v7 + +## base64_decode + +- Syntax: `base64_decode E` ∋ E: [base64](#field-group-base64) +- Bytecode: 0x5e {uint8} +- Stack: ..., A: []byte → ..., []byte +- decode A which was base64-encoded using _encoding_ E. Fail if A is not base64 encoded with encoding E +- **Cost**: 1 + 1 per 16 bytes of A +- Availability: v7 + +### base64 + +Encodings + +| Index | Name | Notes | +| - | ------ | --------- | +| 0 | URLEncoding | | +| 1 | StdEncoding | | + + +*Warning*: Usage should be restricted to very rare use cases. In almost all cases, smart contracts should directly handle non-encoded byte-strings. This 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. + + 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`. + +## json_ref + +- Syntax: `json_ref R` ∋ R: [json_ref](#field-group-json_ref) +- Bytecode: 0x5f {uint8} +- Stack: ..., A: []byte, B: []byte → ..., any +- key B's value, of type R, from a [valid](jsonspec.md) utf-8 encoded json object A +- **Cost**: 25 + 2 per 7 bytes of A +- Availability: v7 + +### json_ref + +Types + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | JSONString | []byte | | +| 1 | JSONUint64 | uint64 | | +| 2 | JSONObject | []byte | | + + +*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. + +Almost 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. + +## balance + +- Bytecode: 0x60 +- Stack: ..., A → ..., uint64 +- 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` +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## app_opted_in + +- Bytecode: 0x61 +- Stack: ..., A, B: uint64 → ..., bool +- 1 if account A is opted in to application B, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_get + +- Bytecode: 0x62 +- Stack: ..., A, B: []byte → ..., any +- local state of the key B in the current application in account A +- Availability: v2 +- Mode: Application + +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. + +## app_local_get_ex + +- Bytecode: 0x63 +- Stack: ..., A, B: uint64, C: []byte → ..., X: any, Y: bool +- X is the local state of application B, key C in account A. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_global_get + +- Bytecode: 0x64 +- Stack: ..., A: []byte → ..., any +- global state of the key A in the current application +- Availability: v2 +- Mode: Application + +params: state key. Return: value. The value is zero (of type uint64) if the key does not exist. + +## app_global_get_ex + +- Bytecode: 0x65 +- Stack: ..., A: uint64, B: []byte → ..., X: any, Y: bool +- X is the global state of application A, key B. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_put + +- Bytecode: 0x66 +- Stack: ..., A, B: []byte, C → ... +- write C to key B in account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value. + +## app_global_put + +- Bytecode: 0x67 +- Stack: ..., A: []byte, B → ... +- write B to key A in the global state of the current application +- Availability: v2 +- Mode: Application + +## app_local_del + +- Bytecode: 0x68 +- Stack: ..., A, B: []byte → ... +- delete key B from account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. + +Deleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.) + +## app_global_del + +- Bytecode: 0x69 +- Stack: ..., A: []byte → ... +- delete key A from the global state of the current application +- Availability: v2 +- Mode: Application + +params: state key. + +Deleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.) + +## asset_holding_get + +- Syntax: `asset_holding_get F` ∋ F: [asset_holding](#field-group-asset_holding) +- Bytecode: 0x70 {uint8} +- Stack: ..., A, B: uint64 → ..., X: any, Y: bool +- X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0 +- Availability: v2 +- Mode: Application + +### asset_holding + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetBalance | uint64 | Amount of the asset unit held by this account | +| 1 | AssetFrozen | bool | Is the asset frozen or not | + + +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. + +## asset_params_get + +- Syntax: `asset_params_get F` ∋ F: [asset_params](#field-group-asset_params) +- Bytecode: 0x71 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from asset A. Y is 1 if A exists, else 0 +- Availability: v2 +- Mode: Application + +### asset_params + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | AssetTotal | uint64 | | Total number of units of this asset | +| 1 | AssetDecimals | uint64 | | See AssetParams.Decimals | +| 2 | AssetDefaultFrozen | bool | | Frozen by default or not | +| 3 | AssetUnitName | []byte | | Asset unit name | +| 4 | AssetName | []byte | | Asset name | +| 5 | AssetURL | []byte | | URL with additional info about the asset | +| 6 | AssetMetadataHash | [32]byte | | Arbitrary commitment | +| 7 | AssetManager | address | | Manager address | +| 8 | AssetReserve | address | | Reserve address | +| 9 | AssetFreeze | address | | Freeze address | +| 10 | AssetClawback | address | | Clawback address | +| 11 | AssetCreator | address | v5 | Creator address | + + +params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value. + +## app_params_get + +- Syntax: `app_params_get F` ∋ F: [app_params](#field-group-app_params) +- Bytecode: 0x72 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from app A. Y is 1 if A exists, else 0 +- Availability: v5 +- Mode: Application + +### app_params + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AppApprovalProgram | []byte | Bytecode of Approval Program | +| 1 | AppClearStateProgram | []byte | Bytecode of Clear State Program | +| 2 | AppGlobalNumUint | uint64 | Number of uint64 values allowed in Global State | +| 3 | AppGlobalNumByteSlice | uint64 | Number of byte array values allowed in Global State | +| 4 | AppLocalNumUint | uint64 | Number of uint64 values allowed in Local State | +| 5 | AppLocalNumByteSlice | uint64 | Number of byte array values allowed in Local State | +| 6 | AppExtraProgramPages | uint64 | Number of Extra Program Pages of code space | +| 7 | AppCreator | address | Creator address | +| 8 | AppAddress | address | Address for which this application has authority | + + +params: Txn.ForeignApps offset or an _available_ app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value. + +## acct_params_get + +- Syntax: `acct_params_get F` ∋ F: [acct_params](#field-group-acct_params) +- Bytecode: 0x73 {uint8} +- Stack: ..., A → ..., X: any, Y: bool +- X is field F from account A. Y is 1 if A owns positive algos, else 0 +- Availability: v6 +- Mode: Application + +### acct_params + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | AcctBalance | uint64 | | Account balance in microalgos | +| 1 | AcctMinBalance | uint64 | | Minimum required balance for account, in microalgos | +| 2 | AcctAuthAddr | address | | Address the account is rekeyed to. | +| 3 | AcctTotalNumUint | uint64 | v8 | The total number of uint64 values allocated by this account in Global and Local States. | +| 4 | AcctTotalNumByteSlice | uint64 | v8 | The total number of byte array values allocated by this account in Global and Local States. | +| 5 | AcctTotalExtraAppPages | uint64 | v8 | The number of extra app code pages used by this account. | +| 6 | AcctTotalAppsCreated | uint64 | v8 | The number of existing apps created by this account. | +| 7 | AcctTotalAppsOptedIn | uint64 | v8 | The number of apps this account is opted into. | +| 8 | AcctTotalAssetsCreated | uint64 | v8 | The number of existing ASAs created by this account. | +| 9 | AcctTotalAssets | uint64 | v8 | The numbers of ASAs held by this account (including ASAs this account created). | +| 10 | AcctTotalBoxes | uint64 | v8 | The number of existing boxes created by this account's app. | +| 11 | AcctTotalBoxBytes | uint64 | v8 | The total number of bytes used by this account's app's box keys and values. | + + +## min_balance + +- Bytecode: 0x78 +- Stack: ..., A → ..., uint64 +- 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. +- Availability: v3 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## pushbytes + +- Syntax: `pushbytes BYTES` ∋ BYTES: a byte constant +- Bytecode: 0x80 {varuint length, bytes} +- Stack: ... → ..., []byte +- immediate BYTES +- Availability: v3 + +pushbytes args are not added to the bytecblock during assembly processes + +## pushint + +- Syntax: `pushint UINT` ∋ UINT: an int constant +- Bytecode: 0x81 {varuint} +- Stack: ... → ..., uint64 +- immediate UINT +- Availability: v3 + +pushint args are not added to the intcblock during assembly processes + +## pushbytess + +- Syntax: `pushbytess BYTES ...` ∋ BYTES ...: a list of byte constants +- Bytecode: 0x82 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ..., [N items] +- push sequences of immediate byte arrays to stack (first byte array being deepest) +- Availability: v8 + +pushbytess args are not added to the bytecblock during assembly processes + +## pushints + +- Syntax: `pushints UINT ...` ∋ UINT ...: a list of int constants +- Bytecode: 0x83 {varuint count, [varuint ...]} +- Stack: ... → ..., [N items] +- push sequence of immediate uints to stack in the order they appear (first uint being deepest) +- Availability: v8 + +pushints args are not added to the intcblock during assembly processes + +## ed25519verify_bare + +- Bytecode: 0x84 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of the data against the pubkey => {0 or 1} +- **Cost**: 1900 +- Availability: v7 + +## callsub + +- Syntax: `callsub TARGET` ∋ TARGET: branch offset +- Bytecode: 0x88 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET, saving the next instruction on the call stack +- Availability: v4 + +The call stack is separate from the data stack. Only `callsub`, `retsub`, and `proto` manipulate it. + +## retsub + +- Bytecode: 0x89 +- Stack: ... → ... +- pop the top instruction from the call stack and branch to it +- Availability: v4 + +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. + +## proto + +- Syntax: `proto A R` ∋ A: number of arguments, R: number of return values +- Bytecode: 0x8a {uint8}, {uint8} +- Stack: ... → ... +- Prepare top call frame for a retsub that will assume A args and R return values. +- Availability: v8 + +Fails unless the last instruction executed was a `callsub`. + +## frame_dig + +- Syntax: `frame_dig I` ∋ I: frame slot +- Bytecode: 0x8b {int8} +- Stack: ... → ..., any +- Nth (signed) value from the frame pointer. +- Availability: v8 + +## frame_bury + +- Syntax: `frame_bury I` ∋ I: frame slot +- Bytecode: 0x8c {int8} +- Stack: ..., A → ... +- replace the Nth (signed) value from the frame pointer in the stack with A +- Availability: v8 + +## switch + +- Syntax: `switch TARGET ...` ∋ TARGET ...: list of labels +- Bytecode: 0x8d {varuint count, [int16 (big-endian) ...]} +- Stack: ..., A: uint64 → ... +- branch to the Ath label. Continue at following instruction if index A exceeds the number of labels. +- Availability: v8 + +## match + +- Syntax: `match TARGET ...` ∋ TARGET ...: list of labels +- Bytecode: 0x8e {varuint count, [int16 (big-endian) ...]} +- Stack: ..., [A1, A2, ..., AN], B → ... +- 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. +- Availability: v8 + +`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. + +## shl + +- Bytecode: 0x90 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times 2^B, modulo 2^64 +- Availability: v4 + +## shr + +- Bytecode: 0x91 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by 2^B +- Availability: v4 + +## sqrt + +- Bytecode: 0x92 +- Stack: ..., A: uint64 → ..., uint64 +- The largest integer I such that I^2 <= A +- **Cost**: 4 +- Availability: v4 + +## bitlen + +- Bytecode: 0x93 +- Stack: ..., A → ..., uint64 +- 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 +- Availability: v4 + +bitlen interprets arrays as big-endian integers, unlike setbit/getbit + +## exp + +- Bytecode: 0x94 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A raised to the Bth power. Fail if A == B == 0 and on overflow +- Availability: v4 + +## expw + +- Bytecode: 0x95 +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- 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 +- **Cost**: 10 +- Availability: v4 + +## bsqrt + +- Bytecode: 0x96 +- Stack: ..., A: []byte → ..., []byte +- The largest integer I such that I^2 <= A. A and I are interpreted as big-endian unsigned integers +- **Cost**: 40 +- Availability: v6 + +## divw + +- Bytecode: 0x97 +- Stack: ..., A: uint64, B: uint64, C: uint64 → ..., uint64 +- A,B / C. Fail if C == 0 or if result overflows. +- Availability: v6 + +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. + +## sha3_256 + +- Bytecode: 0x98 +- Stack: ..., A: []byte → ..., []byte +- SHA3_256 hash of value A, yields [32]byte +- **Cost**: 130 +- Availability: v7 + +## b+ + +- Bytecode: 0xa0 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A plus B. A and B are interpreted as big-endian unsigned integers +- **Cost**: 10 +- Availability: v4 + +## b- + +- Bytecode: 0xa1 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow. +- **Cost**: 10 +- Availability: v4 + +## b/ + +- Bytecode: 0xa2 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b* + +- Bytecode: 0xa3 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A times B. A and B are interpreted as big-endian unsigned integers. +- **Cost**: 20 +- Availability: v4 + +## b< + +- Bytecode: 0xa4 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b> + +- Bytecode: 0xa5 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b<= + +- Bytecode: 0xa6 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b>= + +- Bytecode: 0xa7 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b== + +- Bytecode: 0xa8 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b!= + +- Bytecode: 0xa9 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b% + +- Bytecode: 0xaa +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b| + +- Bytecode: 0xab +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-or B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b& + +- Bytecode: 0xac +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-and B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b^ + +- Bytecode: 0xad +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-xor B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b~ + +- Bytecode: 0xae +- Stack: ..., A: []byte → ..., []byte +- A with all bits inverted +- **Cost**: 4 +- Availability: v4 + +## bzero + +- Bytecode: 0xaf +- Stack: ..., A: uint64 → ..., []byte +- zero filled byte-array of length A +- Availability: v4 + +## log + +- Bytecode: 0xb0 +- Stack: ..., A: []byte → ... +- write A to log state of the current application +- Availability: v5 +- Mode: Application + +`log` fails if called more than MaxLogCalls times in a program, or if the sum of logged bytes exceeds 1024 bytes. + +## itxn_begin + +- Bytecode: 0xb1 +- Stack: ... → ... +- begin preparation of a new inner transaction in a new transaction group +- Availability: v5 +- Mode: Application + +`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. + +## itxn_field + +- Syntax: `itxn_field F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0xb2 {uint8} +- Stack: ..., A → ... +- set field F of the current inner transaction to A +- Availability: v5 +- Mode: Application + +`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_.) + +## itxn_submit + +- Bytecode: 0xb3 +- Stack: ... → ... +- 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. +- Availability: v5 +- Mode: Application + +`itxn_submit` resets the current transaction so that it can not be resubmitted. A new `itxn_begin` is required to prepare another inner transaction. + +## itxn + +- Syntax: `itxn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0xb4 {uint8} +- Stack: ... → ..., any +- field F of the last inner transaction +- Availability: v5 +- Mode: Application + +## itxna + +- Syntax: `itxna F I` ∋ F: [txna](#field-group-txna), I: a transaction field array index +- Bytecode: 0xb5 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the last inner transaction +- Availability: v5 +- Mode: Application + +## itxn_next + +- Bytecode: 0xb6 +- Stack: ... → ... +- begin preparation of a new inner transaction in the same transaction group +- Availability: v6 +- Mode: Application + +`itxn_next` initializes the transaction exactly as `itxn_begin` does + +## gitxn + +- Syntax: `gitxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0xb7 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## gitxna + +- Syntax: `gitxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0xb8 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## box_create + +- Bytecode: 0xb9 +- Stack: ..., A: boxName, B: uint64 → ..., bool +- 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 +- Availability: v8 +- Mode: Application + +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`. + +## box_extract + +- Bytecode: 0xba +- Stack: ..., A: boxName, B: uint64, C: uint64 → ..., []byte +- 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. +- Availability: v8 +- Mode: Application + +## box_replace + +- Bytecode: 0xbb +- Stack: ..., A: boxName, B: uint64, C: []byte → ... +- 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. +- Availability: v8 +- Mode: Application + +## box_del + +- Bytecode: 0xbc +- Stack: ..., A: boxName → ..., bool +- delete box named A if it exists. Return 1 if A existed, 0 otherwise +- Availability: v8 +- Mode: Application + +## box_len + +- Bytecode: 0xbd +- Stack: ..., A: boxName → ..., X: uint64, Y: bool +- X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0. +- Availability: v8 +- Mode: Application + +## box_get + +- Bytecode: 0xbe +- Stack: ..., A: boxName → ..., X: []byte, Y: bool +- X is the contents of box A if A exists, else ''. Y is 1 if A exists, else 0. +- Availability: v8 +- Mode: Application + +For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `box_replace` + +## box_put + +- Bytecode: 0xbf +- Stack: ..., A: boxName, B: []byte → ... +- 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 +- Availability: v8 +- Mode: Application + +For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `box_replace` + +## txnas + +- Syntax: `txnas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc0 {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F of the current transaction +- Availability: v5 + +## gtxnas + +- Syntax: `gtxnas T F` ∋ T: transaction group index, F: [txna](#field-group-txna) +- Bytecode: 0xc1 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F from the Tth transaction in the current group +- Availability: v5 + +## gtxnsas + +- Syntax: `gtxnsas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc2 {uint8} +- Stack: ..., A: uint64, B: uint64 → ..., any +- Bth value of the array field F from the Ath transaction in the current group +- Availability: v5 + +## args + +- Bytecode: 0xc3 +- Stack: ..., A: uint64 → ..., []byte +- Ath LogicSig argument +- Availability: v5 +- Mode: Signature + +## gloadss + +- Bytecode: 0xc4 +- Stack: ..., A: uint64, B: uint64 → ..., any +- Bth scratch space value of the Ath transaction in the current group +- Availability: v6 +- Mode: Application + +## itxnas + +- Syntax: `itxnas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc5 {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F of the last inner transaction +- Availability: v6 +- Mode: Application + +## gitxnas + +- Syntax: `gitxnas T F` ∋ T: transaction group index, F: [txna](#field-group-txna) +- Bytecode: 0xc6 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F from the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## vrf_verify + +- Syntax: `vrf_verify S` ∋ S: [vrf_verify](#field-group-vrf_verify) +- Bytecode: 0xd0 {uint8} +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., X: []byte, Y: bool +- Verify the proof B of message A against pubkey C. Returns vrf output and verification flag. +- **Cost**: 5700 +- Availability: v7 + +### vrf_verify + +Standards + +| Index | Name | Notes | +| - | ------ | --------- | +| 0 | VrfAlgorand | | + + +`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/). + +## block + +- Syntax: `block F` ∋ F: [block](#field-group-block) +- Bytecode: 0xd1 {uint8} +- Stack: ..., A: uint64 → ..., any +- field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive) +- Availability: v7 + +### block + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | BlkSeed | []byte | | +| 1 | BlkTimestamp | uint64 | | + diff --git a/data/transactions/logic/TEAL_opcodes_v9.md b/data/transactions/logic/TEAL_opcodes_v9.md new file mode 100644 index 0000000000..231343564d --- /dev/null +++ b/data/transactions/logic/TEAL_opcodes_v9.md @@ -0,0 +1,1640 @@ +# v9 Opcodes + +Ops have a 'cost' of 1 unless otherwise specified. + + +## err + +- Bytecode: 0x00 +- Stack: ... → _exits_ +- Fail immediately. + +## sha256 + +- Bytecode: 0x01 +- Stack: ..., A: []byte → ..., [32]byte +- SHA256 hash of value A, yields [32]byte +- **Cost**: 35 + +## keccak256 + +- Bytecode: 0x02 +- Stack: ..., A: []byte → ..., [32]byte +- Keccak256 hash of value A, yields [32]byte +- **Cost**: 130 + +## sha512_256 + +- Bytecode: 0x03 +- Stack: ..., A: []byte → ..., [32]byte +- SHA512_256 hash of value A, yields [32]byte +- **Cost**: 45 + +## ed25519verify + +- Bytecode: 0x04 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1} +- **Cost**: 1900 + +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. + +## ecdsa_verify + +- Syntax: `ecdsa_verify V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x05 {uint8} +- Stack: ..., A: []byte, B: []byte, C: []byte, D: []byte, E: []byte → ..., bool +- for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1} +- **Cost**: Secp256k1=1700; Secp256r1=2500 +- Availability: v5 + +### ECDSA + +Curves + +| Index | Name | In | Notes | +| - | ------ | - | --------- | +| 0 | Secp256k1 | | secp256k1 curve, used in Bitcoin | +| 1 | Secp256r1 | v7 | secp256r1 curve, NIST standard | + + +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. + +## ecdsa_pk_decompress + +- Syntax: `ecdsa_pk_decompress V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x06 {uint8} +- Stack: ..., A: []byte → ..., X: []byte, Y: []byte +- decompress pubkey A into components X, Y +- **Cost**: Secp256k1=650; Secp256r1=2400 +- Availability: v5 + +The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded. + +## ecdsa_pk_recover + +- Syntax: `ecdsa_pk_recover V` ∋ V: [ECDSA](#field-group-ecdsa) +- Bytecode: 0x07 {uint8} +- Stack: ..., A: []byte, B: uint64, C: []byte, D: []byte → ..., X: []byte, Y: []byte +- for (data A, recovery id B, signature C, D) recover a public key +- **Cost**: 2000 +- Availability: v5 + +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. + +## + + +- Bytecode: 0x08 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A plus B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`. + +## - + +- Bytecode: 0x09 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A minus B. Fail if B > A. + +## / + +- Bytecode: 0x0a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by B (truncated division). Fail if B == 0. + +`divmodw` is available to divide the two-element values produced by `mulw` and `addw`. + +## * + +- Bytecode: 0x0b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times B. Fail on overflow. + +Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`. + +## < + +- Bytecode: 0x0c +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than B => {0 or 1} + +## > + +- Bytecode: 0x0d +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than B => {0 or 1} + +## <= + +- Bytecode: 0x0e +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A less than or equal to B => {0 or 1} + +## >= + +- Bytecode: 0x0f +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A greater than or equal to B => {0 or 1} + +## && + +- Bytecode: 0x10 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero and B is not zero => {0 or 1} + +## || + +- Bytecode: 0x11 +- Stack: ..., A: uint64, B: uint64 → ..., bool +- A is not zero or B is not zero => {0 or 1} + +## == + +- Bytecode: 0x12 +- Stack: ..., A, B → ..., bool +- A is equal to B => {0 or 1} + +## != + +- Bytecode: 0x13 +- Stack: ..., A, B → ..., bool +- A is not equal to B => {0 or 1} + +## ! + +- Bytecode: 0x14 +- Stack: ..., A: uint64 → ..., uint64 +- A == 0 yields 1; else 0 + +## len + +- Bytecode: 0x15 +- Stack: ..., A: []byte → ..., uint64 +- yields length of byte value A + +## itob + +- Bytecode: 0x16 +- Stack: ..., A: uint64 → ..., []byte +- converts uint64 A to big-endian byte array, always of length 8 + +## btoi + +- Bytecode: 0x17 +- Stack: ..., A: []byte → ..., uint64 +- converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8. + +`btoi` fails if the input is longer than 8 bytes. + +## % + +- Bytecode: 0x18 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A modulo B. Fail if B == 0. + +## | + +- Bytecode: 0x19 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-or B + +## & + +- Bytecode: 0x1a +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-and B + +## ^ + +- Bytecode: 0x1b +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A bitwise-xor B + +## ~ + +- Bytecode: 0x1c +- Stack: ..., A: uint64 → ..., uint64 +- bitwise invert value A + +## mulw + +- Bytecode: 0x1d +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low + +## addw + +- Bytecode: 0x1e +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits. +- Availability: v2 + +## divmodw + +- Bytecode: 0x1f +- Stack: ..., A: uint64, B: uint64, C: uint64, D: uint64 → ..., W: uint64, X: uint64, Y: uint64, Z: uint64 +- W,X = (A,B / C,D); Y,Z = (A,B modulo C,D) +- **Cost**: 20 +- Availability: v4 + +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. + +## intcblock + +- Syntax: `intcblock UINT ...` ∋ UINT ...: a block of int constant values +- Bytecode: 0x20 {varuint count, [varuint ...]} +- Stack: ... → ... +- prepare block of uint64 constants for use by intc + +`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. + +## intc + +- Syntax: `intc I` ∋ I: an index in the intcblock +- Bytecode: 0x21 {uint8} +- Stack: ... → ..., uint64 +- Ith constant from intcblock + +## intc_0 + +- Bytecode: 0x22 +- Stack: ... → ..., uint64 +- constant 0 from intcblock + +## intc_1 + +- Bytecode: 0x23 +- Stack: ... → ..., uint64 +- constant 1 from intcblock + +## intc_2 + +- Bytecode: 0x24 +- Stack: ... → ..., uint64 +- constant 2 from intcblock + +## intc_3 + +- Bytecode: 0x25 +- Stack: ... → ..., uint64 +- constant 3 from intcblock + +## bytecblock + +- Syntax: `bytecblock BYTES ...` ∋ BYTES ...: a block of byte constant values +- Bytecode: 0x26 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ... +- prepare block of byte-array constants for use by bytec + +`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. + +## bytec + +- Syntax: `bytec I` ∋ I: an index in the bytecblock +- Bytecode: 0x27 {uint8} +- Stack: ... → ..., []byte +- Ith constant from bytecblock + +## bytec_0 + +- Bytecode: 0x28 +- Stack: ... → ..., []byte +- constant 0 from bytecblock + +## bytec_1 + +- Bytecode: 0x29 +- Stack: ... → ..., []byte +- constant 1 from bytecblock + +## bytec_2 + +- Bytecode: 0x2a +- Stack: ... → ..., []byte +- constant 2 from bytecblock + +## bytec_3 + +- Bytecode: 0x2b +- Stack: ... → ..., []byte +- constant 3 from bytecblock + +## arg + +- Syntax: `arg N` ∋ N: an arg index +- Bytecode: 0x2c {uint8} +- Stack: ... → ..., []byte +- Nth LogicSig argument +- Mode: Signature + +## arg_0 + +- Bytecode: 0x2d +- Stack: ... → ..., []byte +- LogicSig argument 0 +- Mode: Signature + +## arg_1 + +- Bytecode: 0x2e +- Stack: ... → ..., []byte +- LogicSig argument 1 +- Mode: Signature + +## arg_2 + +- Bytecode: 0x2f +- Stack: ... → ..., []byte +- LogicSig argument 2 +- Mode: Signature + +## arg_3 + +- Bytecode: 0x30 +- Stack: ... → ..., []byte +- LogicSig argument 3 +- Mode: Signature + +## txn + +- Syntax: `txn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x31 {uint8} +- Stack: ... → ..., any +- field F of current transaction + +### txn + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | Sender | address | | 32 byte address | +| 1 | Fee | uint64 | | microalgos | +| 2 | FirstValid | uint64 | | round number | +| 3 | FirstValidTime | uint64 | v7 | UNIX timestamp of block before txn.FirstValid. Fails if negative | +| 4 | LastValid | uint64 | | round number | +| 5 | Note | []byte | | Any data up to 1024 bytes | +| 6 | Lease | [32]byte | | 32 byte lease value | +| 7 | Receiver | address | | 32 byte address | +| 8 | Amount | uint64 | | microalgos | +| 9 | CloseRemainderTo | address | | 32 byte address | +| 10 | VotePK | [32]byte | | 32 byte address | +| 11 | SelectionPK | [32]byte | | 32 byte address | +| 12 | VoteFirst | uint64 | | The first round that the participation key is valid. | +| 13 | VoteLast | uint64 | | The last round that the participation key is valid. | +| 14 | VoteKeyDilution | uint64 | | Dilution for the 2-level participation key | +| 15 | Type | []byte | | Transaction type as bytes | +| 16 | TypeEnum | uint64 | | Transaction type as integer | +| 17 | XferAsset | uint64 | | Asset ID | +| 18 | AssetAmount | uint64 | | value in Asset's units | +| 19 | AssetSender | address | | 32 byte address. Source of assets if Sender is the Asset's Clawback address. | +| 20 | AssetReceiver | address | | 32 byte address | +| 21 | AssetCloseTo | address | | 32 byte address | +| 22 | GroupIndex | uint64 | | Position of this transaction within an atomic transaction group. A stand-alone transaction is implicitly element 0 in a group of 1 | +| 23 | TxID | [32]byte | | The computed ID for this transaction. 32 bytes. | +| 24 | ApplicationID | uint64 | v2 | ApplicationID from ApplicationCall transaction | +| 25 | OnCompletion | uint64 | v2 | ApplicationCall transaction on completion action | +| 27 | NumAppArgs | uint64 | v2 | Number of ApplicationArgs | +| 29 | NumAccounts | uint64 | v2 | Number of Accounts | +| 30 | ApprovalProgram | []byte | v2 | Approval program | +| 31 | ClearStateProgram | []byte | v2 | Clear state program | +| 32 | RekeyTo | address | v2 | 32 byte Sender's new AuthAddr | +| 33 | ConfigAsset | uint64 | v2 | Asset ID in asset config transaction | +| 34 | ConfigAssetTotal | uint64 | v2 | Total number of units of this asset created | +| 35 | ConfigAssetDecimals | uint64 | v2 | Number of digits to display after the decimal place when displaying the asset | +| 36 | ConfigAssetDefaultFrozen | bool | v2 | Whether the asset's slots are frozen by default or not, 0 or 1 | +| 37 | ConfigAssetUnitName | []byte | v2 | Unit name of the asset | +| 38 | ConfigAssetName | []byte | v2 | The asset name | +| 39 | ConfigAssetURL | []byte | v2 | URL | +| 40 | ConfigAssetMetadataHash | [32]byte | v2 | 32 byte commitment to unspecified asset metadata | +| 41 | ConfigAssetManager | address | v2 | 32 byte address | +| 42 | ConfigAssetReserve | address | v2 | 32 byte address | +| 43 | ConfigAssetFreeze | address | v2 | 32 byte address | +| 44 | ConfigAssetClawback | address | v2 | 32 byte address | +| 45 | FreezeAsset | uint64 | v2 | Asset ID being frozen or un-frozen | +| 46 | FreezeAssetAccount | address | v2 | 32 byte address of the account whose asset slot is being frozen or un-frozen | +| 47 | FreezeAssetFrozen | bool | v2 | The new frozen value, 0 or 1 | +| 49 | NumAssets | uint64 | v3 | Number of Assets | +| 51 | NumApplications | uint64 | v3 | Number of Applications | +| 52 | GlobalNumUint | uint64 | v3 | Number of global state integers in ApplicationCall | +| 53 | GlobalNumByteSlice | uint64 | v3 | Number of global state byteslices in ApplicationCall | +| 54 | LocalNumUint | uint64 | v3 | Number of local state integers in ApplicationCall | +| 55 | LocalNumByteSlice | uint64 | v3 | Number of local state byteslices in ApplicationCall | +| 56 | ExtraProgramPages | uint64 | v4 | Number of additional pages for each of the application's approval and clear state programs. An ExtraProgramPages of 1 means 2048 more total bytes, or 1024 for each program. | +| 57 | Nonparticipation | bool | v5 | Marks an account nonparticipating for rewards | +| 59 | NumLogs | uint64 | v5 | Number of Logs (only with `itxn` in v5). Application mode only | +| 60 | CreatedAssetID | uint64 | v5 | Asset ID allocated by the creation of an ASA (only with `itxn` in v5). Application mode only | +| 61 | CreatedApplicationID | uint64 | v5 | ApplicationID allocated by the creation of an application (only with `itxn` in v5). Application mode only | +| 62 | LastLog | []byte | v6 | The last message emitted. Empty bytes if none were emitted. Application mode only | +| 63 | StateProofPK | []byte | v6 | 64 byte state proof public key | +| 65 | NumApprovalProgramPages | uint64 | v7 | Number of Approval Program pages | +| 67 | NumClearStateProgramPages | uint64 | v7 | Number of ClearState Program pages | + + +## global + +- Syntax: `global F` ∋ F: [global](#field-group-global) +- Bytecode: 0x32 {uint8} +- Stack: ... → ..., any +- global field F + +### global + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | MinTxnFee | uint64 | | microalgos | +| 1 | MinBalance | uint64 | | microalgos | +| 2 | MaxTxnLife | uint64 | | rounds | +| 3 | ZeroAddress | address | | 32 byte address of all zero bytes | +| 4 | GroupSize | uint64 | | Number of transactions in this atomic transaction group. At least 1 | +| 5 | LogicSigVersion | uint64 | v2 | Maximum supported version | +| 6 | Round | uint64 | v2 | Current round number. Application mode only. | +| 7 | LatestTimestamp | uint64 | v2 | Last confirmed block UNIX timestamp. Fails if negative. Application mode only. | +| 8 | CurrentApplicationID | uint64 | v2 | ID of current application executing. Application mode only. | +| 9 | CreatorAddress | address | v3 | Address of the creator of the current application. Application mode only. | +| 10 | CurrentApplicationAddress | address | v5 | Address that the current application controls. Application mode only. | +| 11 | GroupID | [32]byte | v5 | ID of the transaction group. 32 zero bytes if the transaction is not part of a group. | +| 12 | OpcodeBudget | uint64 | v6 | The remaining cost that can be spent by opcodes in this program. | +| 13 | CallerApplicationID | uint64 | v6 | The application ID of the application that called this application. 0 if this application is at the top-level. Application mode only. | +| 14 | CallerApplicationAddress | address | v6 | The application address of the application that called this application. ZeroAddress if this application is at the top-level. Application mode only. | + + +## gtxn + +- Syntax: `gtxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0x33 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the current group + +for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`. + +## load + +- Syntax: `load I` ∋ I: position in scratch space to load from +- Bytecode: 0x34 {uint8} +- Stack: ... → ..., any +- Ith scratch space value. All scratch spaces are 0 at program start. + +## store + +- Syntax: `store I` ∋ I: position in scratch space to store to +- Bytecode: 0x35 {uint8} +- Stack: ..., A → ... +- store A to the Ith scratch space + +## txna + +- Syntax: `txna F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x36 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the current transaction
`txna` can be called using `txn` with 2 immediates. +- Availability: v2 + +### txna + +Fields (see [transaction reference](https://developer.algorand.org/docs/reference/transactions/)) + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 26 | ApplicationArgs | []byte | v2 | Arguments passed to the application in the ApplicationCall transaction | +| 28 | Accounts | address | v2 | Accounts listed in the ApplicationCall transaction | +| 48 | Assets | uint64 | v3 | Foreign Assets listed in the ApplicationCall transaction | +| 50 | Applications | uint64 | v3 | Foreign Apps listed in the ApplicationCall transaction | +| 58 | Logs | []byte | v5 | Log messages emitted by an application call (only with `itxn` in v5). Application mode only | +| 64 | ApprovalProgramPages | []byte | v7 | Approval Program as an array of pages | +| 66 | ClearStateProgramPages | []byte | v7 | ClearState Program as an array of pages | + + +## gtxna + +- Syntax: `gtxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x37 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the current group
`gtxna` can be called using `gtxn` with 3 immediates. +- Availability: v2 + +## gtxns + +- Syntax: `gtxns F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0x38 {uint8} +- Stack: ..., A: uint64 → ..., any +- field F of the Ath transaction in the current group +- Availability: v3 + +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. + +## gtxnsa + +- Syntax: `gtxnsa F I` ∋ F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0x39 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith value of the array field F from the Ath transaction in the current group
`gtxnsa` can be called using `gtxns` with 2 immediates. +- Availability: v3 + +## gload + +- Syntax: `gload T I` ∋ T: transaction group index, I: position in scratch space to load from +- Bytecode: 0x3a {uint8}, {uint8} +- Stack: ... → ..., any +- Ith scratch space value of the Tth transaction in the current group +- Availability: v4 +- Mode: Application + +`gload` fails unless the requested transaction is an ApplicationCall and T < GroupIndex. + +## gloads + +- Syntax: `gloads I` ∋ I: position in scratch space to load from +- Bytecode: 0x3b {uint8} +- Stack: ..., A: uint64 → ..., any +- Ith scratch space value of the Ath transaction in the current group +- Availability: v4 +- Mode: Application + +`gloads` fails unless the requested transaction is an ApplicationCall and A < GroupIndex. + +## gaid + +- Syntax: `gaid T` ∋ T: transaction group index +- Bytecode: 0x3c {uint8} +- Stack: ... → ..., uint64 +- ID of the asset or application created in the Tth transaction of the current group +- Availability: v4 +- Mode: Application + +`gaid` fails unless the requested transaction created an asset or application and T < GroupIndex. + +## gaids + +- Bytecode: 0x3d +- Stack: ..., A: uint64 → ..., uint64 +- ID of the asset or application created in the Ath transaction of the current group +- Availability: v4 +- Mode: Application + +`gaids` fails unless the requested transaction created an asset or application and A < GroupIndex. + +## loads + +- Bytecode: 0x3e +- Stack: ..., A: uint64 → ..., any +- Ath scratch space value. All scratch spaces are 0 at program start. +- Availability: v5 + +## stores + +- Bytecode: 0x3f +- Stack: ..., A: uint64, B → ... +- store B to the Ath scratch space +- Availability: v5 + +## bnz + +- Syntax: `bnz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x40 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is not zero + +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. + +At 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.) + +## bz + +- Syntax: `bz TARGET` ∋ TARGET: branch offset +- Bytecode: 0x41 {int16 (big-endian)} +- Stack: ..., A: uint64 → ... +- branch to TARGET if value A is zero +- Availability: v2 + +See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`. + +## b + +- Syntax: `b TARGET` ∋ TARGET: branch offset +- Bytecode: 0x42 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET +- Availability: v2 + +See `bnz` for details on how branches work. `b` always jumps to the offset. + +## return + +- Bytecode: 0x43 +- Stack: ..., A: uint64 → _exits_ +- use A as success value; end +- Availability: v2 + +## assert + +- Bytecode: 0x44 +- Stack: ..., A: uint64 → ... +- immediately fail unless A is a non-zero number +- Availability: v3 + +## bury + +- Syntax: `bury N` ∋ N: depth +- Bytecode: 0x45 {uint8} +- Stack: ..., A → ... +- replace the Nth value from the top of the stack with A. bury 0 fails. +- Availability: v8 + +## popn + +- Syntax: `popn N` ∋ N: stack depth +- Bytecode: 0x46 {uint8} +- Stack: ..., [N items] → ... +- remove N values from the top of the stack +- Availability: v8 + +## dupn + +- Syntax: `dupn N` ∋ N: copy count +- Bytecode: 0x47 {uint8} +- Stack: ..., A → ..., A, [N copies of A] +- duplicate A, N times +- Availability: v8 + +## pop + +- Bytecode: 0x48 +- Stack: ..., A → ... +- discard A + +## dup + +- Bytecode: 0x49 +- Stack: ..., A → ..., A, A +- duplicate A + +## dup2 + +- Bytecode: 0x4a +- Stack: ..., A, B → ..., A, B, A, B +- duplicate A and B +- Availability: v2 + +## dig + +- Syntax: `dig N` ∋ N: depth +- Bytecode: 0x4b {uint8} +- Stack: ..., A, [N items] → ..., A, [N items], A +- Nth value from the top of the stack. dig 0 is equivalent to dup +- Availability: v3 + +## swap + +- Bytecode: 0x4c +- Stack: ..., A, B → ..., B, A +- swaps A and B on stack +- Availability: v3 + +## select + +- Bytecode: 0x4d +- Stack: ..., A, B, C: uint64 → ..., A or B +- selects one of two values based on top-of-stack: B if C != 0, else A +- Availability: v3 + +## cover + +- Syntax: `cover N` ∋ N: depth +- Bytecode: 0x4e {uint8} +- Stack: ..., [N items], A → ..., A, [N items] +- remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth <= N. +- Availability: v5 + +## uncover + +- Syntax: `uncover N` ∋ N: depth +- Bytecode: 0x4f {uint8} +- Stack: ..., A, [N items] → ..., [N items], A +- 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. +- Availability: v5 + +## concat + +- Bytecode: 0x50 +- Stack: ..., A: []byte, B: []byte → ..., []byte +- join A and B +- Availability: v2 + +`concat` fails if the result would be greater than 4096 bytes. + +## substring + +- Syntax: `substring S E` ∋ S: start position, E: end position +- Bytecode: 0x51 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v2 + +## substring3 + +- Bytecode: 0x52 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v2 + +## getbit + +- Bytecode: 0x53 +- Stack: ..., A, B: uint64 → ..., uint64 +- 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 +- Availability: v3 + +see explanation of bit ordering in setbit + +## setbit + +- Bytecode: 0x54 +- Stack: ..., A, B: uint64, C: uint64 → ..., any +- 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 +- Availability: v3 + +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. + +## getbyte + +- Bytecode: 0x55 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails +- Availability: v3 + +## setbyte + +- Bytecode: 0x56 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- 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 +- Availability: v3 + +## extract + +- Syntax: `extract S L` ∋ S: start position, L: length +- Bytecode: 0x57 {uint8}, {uint8} +- Stack: ..., A: []byte → ..., []byte +- 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 +- Availability: v5 + +## extract3 + +- Bytecode: 0x58 +- Stack: ..., A: []byte, B: uint64, C: uint64 → ..., []byte +- A range of bytes from A starting at B up to but not including B+C. If B+C is larger than the array length, the program fails
`extract3` can be called using `extract` with no immediates. +- Availability: v5 + +## extract_uint16 + +- Bytecode: 0x59 +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- 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 +- Availability: v5 + +## extract_uint32 + +- Bytecode: 0x5a +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- 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 +- Availability: v5 + +## extract_uint64 + +- Bytecode: 0x5b +- Stack: ..., A: []byte, B: uint64 → ..., uint64 +- A uint64 formed from a range of big-endian bytes from A starting at B up to but not including B+8. If B+8 is larger than the array length, the program fails +- Availability: v5 + +## replace2 + +- Syntax: `replace2 S` ∋ S: start position +- Bytecode: 0x5c {uint8} +- Stack: ..., A: []byte, B: []byte → ..., []byte +- Copy of A with the bytes starting at S replaced by the bytes of B. Fails if S+len(B) exceeds len(A)
`replace2` can be called using `replace` with 1 immediate. +- Availability: v7 + +## replace3 + +- Bytecode: 0x5d +- Stack: ..., A: []byte, B: uint64, C: []byte → ..., []byte +- Copy of A with the bytes starting at B replaced by the bytes of C. Fails if B+len(C) exceeds len(A)
`replace3` can be called using `replace` with no immediates. +- Availability: v7 + +## base64_decode + +- Syntax: `base64_decode E` ∋ E: [base64](#field-group-base64) +- Bytecode: 0x5e {uint8} +- Stack: ..., A: []byte → ..., []byte +- decode A which was base64-encoded using _encoding_ E. Fail if A is not base64 encoded with encoding E +- **Cost**: 1 + 1 per 16 bytes of A +- Availability: v7 + +### base64 + +Encodings + +| Index | Name | Notes | +| - | ------ | --------- | +| 0 | URLEncoding | | +| 1 | StdEncoding | | + + +*Warning*: Usage should be restricted to very rare use cases. In almost all cases, smart contracts should directly handle non-encoded byte-strings. This 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. + + 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`. + +## json_ref + +- Syntax: `json_ref R` ∋ R: [json_ref](#field-group-json_ref) +- Bytecode: 0x5f {uint8} +- Stack: ..., A: []byte, B: []byte → ..., any +- key B's value, of type R, from a [valid](jsonspec.md) utf-8 encoded json object A +- **Cost**: 25 + 2 per 7 bytes of A +- Availability: v7 + +### json_ref + +Types + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | JSONString | []byte | | +| 1 | JSONUint64 | uint64 | | +| 2 | JSONObject | []byte | | + + +*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. + +Almost 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. + +## balance + +- Bytecode: 0x60 +- Stack: ..., A → ..., uint64 +- 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` +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## app_opted_in + +- Bytecode: 0x61 +- Stack: ..., A, B: uint64 → ..., bool +- 1 if account A is opted in to application B, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_get + +- Bytecode: 0x62 +- Stack: ..., A, B: []byte → ..., any +- local state of the key B in the current application in account A +- Availability: v2 +- Mode: Application + +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. + +## app_local_get_ex + +- Bytecode: 0x63 +- Stack: ..., A, B: uint64, C: []byte → ..., X: any, Y: bool +- X is the local state of application B, key C in account A. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_global_get + +- Bytecode: 0x64 +- Stack: ..., A: []byte → ..., any +- global state of the key A in the current application +- Availability: v2 +- Mode: Application + +params: state key. Return: value. The value is zero (of type uint64) if the key does not exist. + +## app_global_get_ex + +- Bytecode: 0x65 +- Stack: ..., A: uint64, B: []byte → ..., X: any, Y: bool +- X is the global state of application A, key B. Y is 1 if key existed, else 0 +- Availability: v2 +- Mode: Application + +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. + +## app_local_put + +- Bytecode: 0x66 +- Stack: ..., A, B: []byte, C → ... +- write C to key B in account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value. + +## app_global_put + +- Bytecode: 0x67 +- Stack: ..., A: []byte, B → ... +- write B to key A in the global state of the current application +- Availability: v2 +- Mode: Application + +## app_local_del + +- Bytecode: 0x68 +- Stack: ..., A, B: []byte → ... +- delete key B from account A's local state of the current application +- Availability: v2 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. + +Deleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.) + +## app_global_del + +- Bytecode: 0x69 +- Stack: ..., A: []byte → ... +- delete key A from the global state of the current application +- Availability: v2 +- Mode: Application + +params: state key. + +Deleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.) + +## asset_holding_get + +- Syntax: `asset_holding_get F` ∋ F: [asset_holding](#field-group-asset_holding) +- Bytecode: 0x70 {uint8} +- Stack: ..., A, B: uint64 → ..., X: any, Y: bool +- X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0 +- Availability: v2 +- Mode: Application + +### asset_holding + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AssetBalance | uint64 | Amount of the asset unit held by this account | +| 1 | AssetFrozen | bool | Is the asset frozen or not | + + +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. + +## asset_params_get + +- Syntax: `asset_params_get F` ∋ F: [asset_params](#field-group-asset_params) +- Bytecode: 0x71 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from asset A. Y is 1 if A exists, else 0 +- Availability: v2 +- Mode: Application + +### asset_params + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | AssetTotal | uint64 | | Total number of units of this asset | +| 1 | AssetDecimals | uint64 | | See AssetParams.Decimals | +| 2 | AssetDefaultFrozen | bool | | Frozen by default or not | +| 3 | AssetUnitName | []byte | | Asset unit name | +| 4 | AssetName | []byte | | Asset name | +| 5 | AssetURL | []byte | | URL with additional info about the asset | +| 6 | AssetMetadataHash | [32]byte | | Arbitrary commitment | +| 7 | AssetManager | address | | Manager address | +| 8 | AssetReserve | address | | Reserve address | +| 9 | AssetFreeze | address | | Freeze address | +| 10 | AssetClawback | address | | Clawback address | +| 11 | AssetCreator | address | v5 | Creator address | + + +params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value. + +## app_params_get + +- Syntax: `app_params_get F` ∋ F: [app_params](#field-group-app_params) +- Bytecode: 0x72 {uint8} +- Stack: ..., A: uint64 → ..., X: any, Y: bool +- X is field F from app A. Y is 1 if A exists, else 0 +- Availability: v5 +- Mode: Application + +### app_params + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | AppApprovalProgram | []byte | Bytecode of Approval Program | +| 1 | AppClearStateProgram | []byte | Bytecode of Clear State Program | +| 2 | AppGlobalNumUint | uint64 | Number of uint64 values allowed in Global State | +| 3 | AppGlobalNumByteSlice | uint64 | Number of byte array values allowed in Global State | +| 4 | AppLocalNumUint | uint64 | Number of uint64 values allowed in Local State | +| 5 | AppLocalNumByteSlice | uint64 | Number of byte array values allowed in Local State | +| 6 | AppExtraProgramPages | uint64 | Number of Extra Program Pages of code space | +| 7 | AppCreator | address | Creator address | +| 8 | AppAddress | address | Address for which this application has authority | + + +params: Txn.ForeignApps offset or an _available_ app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value. + +## acct_params_get + +- Syntax: `acct_params_get F` ∋ F: [acct_params](#field-group-acct_params) +- Bytecode: 0x73 {uint8} +- Stack: ..., A → ..., X: any, Y: bool +- X is field F from account A. Y is 1 if A owns positive algos, else 0 +- Availability: v6 +- Mode: Application + +### acct_params + +Fields + +| Index | Name | Type | In | Notes | +| - | ------ | -- | - | --------- | +| 0 | AcctBalance | uint64 | | Account balance in microalgos | +| 1 | AcctMinBalance | uint64 | | Minimum required balance for account, in microalgos | +| 2 | AcctAuthAddr | address | | Address the account is rekeyed to. | +| 3 | AcctTotalNumUint | uint64 | v8 | The total number of uint64 values allocated by this account in Global and Local States. | +| 4 | AcctTotalNumByteSlice | uint64 | v8 | The total number of byte array values allocated by this account in Global and Local States. | +| 5 | AcctTotalExtraAppPages | uint64 | v8 | The number of extra app code pages used by this account. | +| 6 | AcctTotalAppsCreated | uint64 | v8 | The number of existing apps created by this account. | +| 7 | AcctTotalAppsOptedIn | uint64 | v8 | The number of apps this account is opted into. | +| 8 | AcctTotalAssetsCreated | uint64 | v8 | The number of existing ASAs created by this account. | +| 9 | AcctTotalAssets | uint64 | v8 | The numbers of ASAs held by this account (including ASAs this account created). | +| 10 | AcctTotalBoxes | uint64 | v8 | The number of existing boxes created by this account's app. | +| 11 | AcctTotalBoxBytes | uint64 | v8 | The total number of bytes used by this account's app's box keys and values. | + + +## min_balance + +- Bytecode: 0x78 +- Stack: ..., A → ..., uint64 +- 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. +- Availability: v3 +- Mode: Application + +params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value. + +## pushbytes + +- Syntax: `pushbytes BYTES` ∋ BYTES: a byte constant +- Bytecode: 0x80 {varuint length, bytes} +- Stack: ... → ..., []byte +- immediate BYTES +- Availability: v3 + +pushbytes args are not added to the bytecblock during assembly processes + +## pushint + +- Syntax: `pushint UINT` ∋ UINT: an int constant +- Bytecode: 0x81 {varuint} +- Stack: ... → ..., uint64 +- immediate UINT +- Availability: v3 + +pushint args are not added to the intcblock during assembly processes + +## pushbytess + +- Syntax: `pushbytess BYTES ...` ∋ BYTES ...: a list of byte constants +- Bytecode: 0x82 {varuint count, [varuint length, bytes ...]} +- Stack: ... → ..., [N items] +- push sequences of immediate byte arrays to stack (first byte array being deepest) +- Availability: v8 + +pushbytess args are not added to the bytecblock during assembly processes + +## pushints + +- Syntax: `pushints UINT ...` ∋ UINT ...: a list of int constants +- Bytecode: 0x83 {varuint count, [varuint ...]} +- Stack: ... → ..., [N items] +- push sequence of immediate uints to stack in the order they appear (first uint being deepest) +- Availability: v8 + +pushints args are not added to the intcblock during assembly processes + +## ed25519verify_bare + +- Bytecode: 0x84 +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., bool +- for (data A, signature B, pubkey C) verify the signature of the data against the pubkey => {0 or 1} +- **Cost**: 1900 +- Availability: v7 + +## callsub + +- Syntax: `callsub TARGET` ∋ TARGET: branch offset +- Bytecode: 0x88 {int16 (big-endian)} +- Stack: ... → ... +- branch unconditionally to TARGET, saving the next instruction on the call stack +- Availability: v4 + +The call stack is separate from the data stack. Only `callsub`, `retsub`, and `proto` manipulate it. + +## retsub + +- Bytecode: 0x89 +- Stack: ... → ... +- pop the top instruction from the call stack and branch to it +- Availability: v4 + +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. + +## proto + +- Syntax: `proto A R` ∋ A: number of arguments, R: number of return values +- Bytecode: 0x8a {uint8}, {uint8} +- Stack: ... → ... +- Prepare top call frame for a retsub that will assume A args and R return values. +- Availability: v8 + +Fails unless the last instruction executed was a `callsub`. + +## frame_dig + +- Syntax: `frame_dig I` ∋ I: frame slot +- Bytecode: 0x8b {int8} +- Stack: ... → ..., any +- Nth (signed) value from the frame pointer. +- Availability: v8 + +## frame_bury + +- Syntax: `frame_bury I` ∋ I: frame slot +- Bytecode: 0x8c {int8} +- Stack: ..., A → ... +- replace the Nth (signed) value from the frame pointer in the stack with A +- Availability: v8 + +## switch + +- Syntax: `switch TARGET ...` ∋ TARGET ...: list of labels +- Bytecode: 0x8d {varuint count, [int16 (big-endian) ...]} +- Stack: ..., A: uint64 → ... +- branch to the Ath label. Continue at following instruction if index A exceeds the number of labels. +- Availability: v8 + +## match + +- Syntax: `match TARGET ...` ∋ TARGET ...: list of labels +- Bytecode: 0x8e {varuint count, [int16 (big-endian) ...]} +- Stack: ..., [A1, A2, ..., AN], B → ... +- 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. +- Availability: v8 + +`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. + +## shl + +- Bytecode: 0x90 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A times 2^B, modulo 2^64 +- Availability: v4 + +## shr + +- Bytecode: 0x91 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A divided by 2^B +- Availability: v4 + +## sqrt + +- Bytecode: 0x92 +- Stack: ..., A: uint64 → ..., uint64 +- The largest integer I such that I^2 <= A +- **Cost**: 4 +- Availability: v4 + +## bitlen + +- Bytecode: 0x93 +- Stack: ..., A → ..., uint64 +- 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 +- Availability: v4 + +bitlen interprets arrays as big-endian integers, unlike setbit/getbit + +## exp + +- Bytecode: 0x94 +- Stack: ..., A: uint64, B: uint64 → ..., uint64 +- A raised to the Bth power. Fail if A == B == 0 and on overflow +- Availability: v4 + +## expw + +- Bytecode: 0x95 +- Stack: ..., A: uint64, B: uint64 → ..., X: uint64, Y: uint64 +- 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 +- **Cost**: 10 +- Availability: v4 + +## bsqrt + +- Bytecode: 0x96 +- Stack: ..., A: []byte → ..., []byte +- The largest integer I such that I^2 <= A. A and I are interpreted as big-endian unsigned integers +- **Cost**: 40 +- Availability: v6 + +## divw + +- Bytecode: 0x97 +- Stack: ..., A: uint64, B: uint64, C: uint64 → ..., uint64 +- A,B / C. Fail if C == 0 or if result overflows. +- Availability: v6 + +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. + +## sha3_256 + +- Bytecode: 0x98 +- Stack: ..., A: []byte → ..., []byte +- SHA3_256 hash of value A, yields [32]byte +- **Cost**: 130 +- Availability: v7 + +## b+ + +- Bytecode: 0xa0 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A plus B. A and B are interpreted as big-endian unsigned integers +- **Cost**: 10 +- Availability: v4 + +## b- + +- Bytecode: 0xa1 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow. +- **Cost**: 10 +- Availability: v4 + +## b/ + +- Bytecode: 0xa2 +- Stack: ..., A: bigint, B: bigint → ..., bigint +- A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b* + +- Bytecode: 0xa3 +- Stack: ..., A: bigint, B: bigint → ..., []byte +- A times B. A and B are interpreted as big-endian unsigned integers. +- **Cost**: 20 +- Availability: v4 + +## b< + +- Bytecode: 0xa4 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b> + +- Bytecode: 0xa5 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b<= + +- Bytecode: 0xa6 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b>= + +- Bytecode: 0xa7 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b== + +- Bytecode: 0xa8 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b!= + +- Bytecode: 0xa9 +- Stack: ..., A: bigint, B: bigint → ..., bool +- 0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers +- Availability: v4 + +## b% + +- Bytecode: 0xaa +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero. +- **Cost**: 20 +- Availability: v4 + +## b| + +- Bytecode: 0xab +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-or B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b& + +- Bytecode: 0xac +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-and B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b^ + +- Bytecode: 0xad +- Stack: ..., A: []byte, B: []byte → ..., []byte +- A bitwise-xor B. A and B are zero-left extended to the greater of their lengths +- **Cost**: 6 +- Availability: v4 + +## b~ + +- Bytecode: 0xae +- Stack: ..., A: []byte → ..., []byte +- A with all bits inverted +- **Cost**: 4 +- Availability: v4 + +## bzero + +- Bytecode: 0xaf +- Stack: ..., A: uint64 → ..., []byte +- zero filled byte-array of length A +- Availability: v4 + +## log + +- Bytecode: 0xb0 +- Stack: ..., A: []byte → ... +- write A to log state of the current application +- Availability: v5 +- Mode: Application + +`log` fails if called more than MaxLogCalls times in a program, or if the sum of logged bytes exceeds 1024 bytes. + +## itxn_begin + +- Bytecode: 0xb1 +- Stack: ... → ... +- begin preparation of a new inner transaction in a new transaction group +- Availability: v5 +- Mode: Application + +`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. + +## itxn_field + +- Syntax: `itxn_field F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0xb2 {uint8} +- Stack: ..., A → ... +- set field F of the current inner transaction to A +- Availability: v5 +- Mode: Application + +`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_.) + +## itxn_submit + +- Bytecode: 0xb3 +- Stack: ... → ... +- 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. +- Availability: v5 +- Mode: Application + +`itxn_submit` resets the current transaction so that it can not be resubmitted. A new `itxn_begin` is required to prepare another inner transaction. + +## itxn + +- Syntax: `itxn F` ∋ F: [txn](#field-group-txn) +- Bytecode: 0xb4 {uint8} +- Stack: ... → ..., any +- field F of the last inner transaction +- Availability: v5 +- Mode: Application + +## itxna + +- Syntax: `itxna F I` ∋ F: [txna](#field-group-txna), I: a transaction field array index +- Bytecode: 0xb5 {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F of the last inner transaction +- Availability: v5 +- Mode: Application + +## itxn_next + +- Bytecode: 0xb6 +- Stack: ... → ... +- begin preparation of a new inner transaction in the same transaction group +- Availability: v6 +- Mode: Application + +`itxn_next` initializes the transaction exactly as `itxn_begin` does + +## gitxn + +- Syntax: `gitxn T F` ∋ T: transaction group index, F: [txn](#field-group-txn) +- Bytecode: 0xb7 {uint8}, {uint8} +- Stack: ... → ..., any +- field F of the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## gitxna + +- Syntax: `gitxna T F I` ∋ T: transaction group index, F: [txna](#field-group-txna), I: transaction field array index +- Bytecode: 0xb8 {uint8}, {uint8}, {uint8} +- Stack: ... → ..., any +- Ith value of the array field F from the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## box_create + +- Bytecode: 0xb9 +- Stack: ..., A: boxName, B: uint64 → ..., bool +- 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 +- Availability: v8 +- Mode: Application + +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`. + +## box_extract + +- Bytecode: 0xba +- Stack: ..., A: boxName, B: uint64, C: uint64 → ..., []byte +- 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. +- Availability: v8 +- Mode: Application + +## box_replace + +- Bytecode: 0xbb +- Stack: ..., A: boxName, B: uint64, C: []byte → ... +- 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. +- Availability: v8 +- Mode: Application + +## box_del + +- Bytecode: 0xbc +- Stack: ..., A: boxName → ..., bool +- delete box named A if it exists. Return 1 if A existed, 0 otherwise +- Availability: v8 +- Mode: Application + +## box_len + +- Bytecode: 0xbd +- Stack: ..., A: boxName → ..., X: uint64, Y: bool +- X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0. +- Availability: v8 +- Mode: Application + +## box_get + +- Bytecode: 0xbe +- Stack: ..., A: boxName → ..., X: []byte, Y: bool +- X is the contents of box A if A exists, else ''. Y is 1 if A exists, else 0. +- Availability: v8 +- Mode: Application + +For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `box_replace` + +## box_put + +- Bytecode: 0xbf +- Stack: ..., A: boxName, B: []byte → ... +- 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 +- Availability: v8 +- Mode: Application + +For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `box_replace` + +## txnas + +- Syntax: `txnas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc0 {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F of the current transaction +- Availability: v5 + +## gtxnas + +- Syntax: `gtxnas T F` ∋ T: transaction group index, F: [txna](#field-group-txna) +- Bytecode: 0xc1 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F from the Tth transaction in the current group +- Availability: v5 + +## gtxnsas + +- Syntax: `gtxnsas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc2 {uint8} +- Stack: ..., A: uint64, B: uint64 → ..., any +- Bth value of the array field F from the Ath transaction in the current group +- Availability: v5 + +## args + +- Bytecode: 0xc3 +- Stack: ..., A: uint64 → ..., []byte +- Ath LogicSig argument +- Availability: v5 +- Mode: Signature + +## gloadss + +- Bytecode: 0xc4 +- Stack: ..., A: uint64, B: uint64 → ..., any +- Bth scratch space value of the Ath transaction in the current group +- Availability: v6 +- Mode: Application + +## itxnas + +- Syntax: `itxnas F` ∋ F: [txna](#field-group-txna) +- Bytecode: 0xc5 {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F of the last inner transaction +- Availability: v6 +- Mode: Application + +## gitxnas + +- Syntax: `gitxnas T F` ∋ T: transaction group index, F: [txna](#field-group-txna) +- Bytecode: 0xc6 {uint8}, {uint8} +- Stack: ..., A: uint64 → ..., any +- Ath value of the array field F from the Tth transaction in the last inner group submitted +- Availability: v6 +- Mode: Application + +## vrf_verify + +- Syntax: `vrf_verify S` ∋ S: [vrf_verify](#field-group-vrf_verify) +- Bytecode: 0xd0 {uint8} +- Stack: ..., A: []byte, B: []byte, C: []byte → ..., X: []byte, Y: bool +- Verify the proof B of message A against pubkey C. Returns vrf output and verification flag. +- **Cost**: 5700 +- Availability: v7 + +### vrf_verify + +Standards + +| Index | Name | Notes | +| - | ------ | --------- | +| 0 | VrfAlgorand | | + + +`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/). + +## block + +- Syntax: `block F` ∋ F: [block](#field-group-block) +- Bytecode: 0xd1 {uint8} +- Stack: ..., A: uint64 → ..., any +- field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive) +- Availability: v7 + +### block + +Fields + +| Index | Name | Type | Notes | +| - | ------ | -- | --------- | +| 0 | BlkSeed | []byte | | +| 1 | BlkTimestamp | uint64 | | + diff --git a/data/transactions/logic/doc.go b/data/transactions/logic/doc.go index 1daca0d903..ad4f1674bd 100644 --- a/data/transactions/logic/doc.go +++ b/data/transactions/logic/doc.go @@ -364,29 +364,6 @@ type VerCost struct { Cost string } -// OpAllCosts returns an array of the cost of an op by version. Each entry -// indicates the cost over a range of versions, so if the cost has remained -// constant, there is only one result, otherwise each entry shows the cost for a -// consecutive range of versions, inclusive. -func OpAllCosts(opName string) []VerCost { - var costs []VerCost - for v := 1; v <= LogicVersion; v++ { - spec, ok := OpsByName[v][opName] - if !ok { - continue - } - argLen := len(spec.Arg.Types) - cost := spec.OpDetails.docCost(argLen) - if costs == nil || cost != costs[len(costs)-1].Cost { - costs = append(costs, VerCost{v, v, cost}) - } else { - costs[len(costs)-1].To = v - } - } - - return costs -} - // TypeNameDescriptions contains extra description about a low level // protocol transaction Type string, and provide a friendlier type // constant name in assembler. diff --git a/data/transactions/logic/doc_test.go b/data/transactions/logic/doc_test.go index 3a90ae9cd6..300c0ffdb9 100644 --- a/data/transactions/logic/doc_test.go +++ b/data/transactions/logic/doc_test.go @@ -113,21 +113,6 @@ func TestOpDocExtra(t *testing.T) { require.Empty(t, xd) } -func TestOpAllCosts(t *testing.T) { - partitiontest.PartitionTest(t) - t.Parallel() - - a := OpAllCosts("+") - require.Len(t, a, 1) - require.Equal(t, "1", a[0].Cost) - - a = OpAllCosts("sha256") - require.Len(t, a, 2) - for _, cost := range a { - require.True(t, cost.Cost != "0") - } -} - func TestOnCompletionDescription(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() diff --git a/data/transactions/logic/langspec_v1.json b/data/transactions/logic/langspec_v1.json new file mode 100644 index 0000000000..e88de1429d --- /dev/null +++ b/data/transactions/logic/langspec_v1.json @@ -0,0 +1,1136 @@ +{ + "Version": 1, + "LogicSigVersion": 9, + "NamedTypes": [ + { + "Name": "uint64", + "Abbreviation": "i", + "Bound": [ + 0, + 18446744073709551615 + ], + "AVMType": "uint64" + }, + { + "Name": "stateKey", + "Abbreviation": "K", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "none", + "Abbreviation": "x", + "Bound": [ + 0, + 0 + ], + "AVMType": "none" + }, + { + "Name": "method", + "Abbreviation": "M", + "Bound": [ + 4, + 4 + ], + "AVMType": "[]byte" + }, + { + "Name": "boxName", + "Abbreviation": "N", + "Bound": [ + 1, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "bool", + "Abbreviation": "T", + "Bound": [ + 0, + 1 + ], + "AVMType": "uint64" + }, + { + "Name": "bigint", + "Abbreviation": "I", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "any", + "Abbreviation": "a", + "Bound": [ + 0, + 0 + ], + "AVMType": "any" + }, + { + "Name": "address", + "Abbreviation": "A", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + }, + { + "Name": "[]byte", + "Abbreviation": "b", + "Bound": [ + 0, + 4096 + ], + "AVMType": "[]byte" + }, + { + "Name": "[32]byte", + "Abbreviation": "H", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + } + ], + "Ops": [ + { + "Opcode": 0, + "Name": "err", + "Size": 1, + "DocCost": "1", + "Doc": "Fail immediately.", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 1, + "Name": "sha256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "7", + "Doc": "SHA256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 2, + "Name": "keccak256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "26", + "Doc": "Keccak256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 3, + "Name": "sha512_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "9", + "Doc": "SHA512_256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 4, + "Name": "ed25519verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {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.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 8, + "Name": "+", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 9, + "Name": "-", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A minus B. Fail if B \u003e A.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 10, + "Name": "/", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 11, + "Name": "*", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 12, + "Name": "\u003c", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 13, + "Name": "\u003e", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 14, + "Name": "\u003c=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 15, + "Name": "\u003e=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 16, + "Name": "\u0026\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero and B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 17, + "Name": "||", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero or B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 18, + "Name": "==", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 19, + "Name": "!=", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 20, + "Name": "!", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A == 0 yields 1; else 0", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 21, + "Name": "len", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "yields length of byte value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 22, + "Name": "itob", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts uint64 A to big-endian byte array, always of length 8", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 23, + "Name": "btoi", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts big-endian byte array A to uint64. Fails if len(A) \u003e 8. Padded by leading 0s if len(A) \u003c 8.", + "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 24, + "Name": "%", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A modulo B. Fail if B == 0.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 25, + "Name": "|", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-or B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 26, + "Name": "\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-and B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 27, + "Name": "^", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-xor B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 28, + "Name": "~", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "bitwise invert value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 29, + "Name": "mulw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 32, + "Name": "intcblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of int constant values", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 33, + "Name": "intc", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from intcblock", + "ImmediateNote": [ + { + "Comment": "an index in the intcblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 34, + "Name": "intc_0", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 35, + "Name": "intc_1", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 36, + "Name": "intc_2", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 37, + "Name": "intc_3", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 38, + "Name": "bytecblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of byte constant values", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 39, + "Name": "bytec", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from bytecblock", + "ImmediateNote": [ + { + "Comment": "an index in the bytecblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 40, + "Name": "bytec_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 41, + "Name": "bytec_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 42, + "Name": "bytec_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 43, + "Name": "bytec_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 44, + "Name": "arg", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth LogicSig argument", + "ImmediateNote": [ + { + "Comment": "an arg index", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 45, + "Name": "arg_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 0", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 46, + "Name": "arg_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 1", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 47, + "Name": "arg_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 2", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 48, + "Name": "arg_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 3", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 49, + "Name": "txn", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "LastValid", + "Note", + "Lease", + "Receiver", + "Amount", + "CloseRemainderTo", + "VotePK", + "SelectionPK", + "VoteFirst", + "VoteLast", + "VoteKeyDilution", + "Type", + "TypeEnum", + "XferAsset", + "AssetAmount", + "AssetSender", + "AssetReceiver", + "AssetCloseTo", + "GroupIndex", + "TxID" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte" + ], + "DocCost": "1", + "Doc": "field F of current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 50, + "Name": "global", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "MinTxnFee", + "MinBalance", + "MaxTxnLife", + "ZeroAddress", + "GroupSize" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "uint64", + "address", + "uint64" + ], + "DocCost": "1", + "Doc": "global field F", + "ImmediateNote": [ + { + "Comment": "a global field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "global" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 51, + "Name": "gtxn", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "LastValid", + "Note", + "Lease", + "Receiver", + "Amount", + "CloseRemainderTo", + "VotePK", + "SelectionPK", + "VoteFirst", + "VoteLast", + "VoteKeyDilution", + "Type", + "TypeEnum", + "XferAsset", + "AssetAmount", + "AssetSender", + "AssetReceiver", + "AssetCloseTo", + "GroupIndex", + "TxID" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 52, + "Name": "load", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 53, + "Name": "store", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "store A to the Ith scratch space", + "ImmediateNote": [ + { + "Comment": "position in scratch space to store to", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 64, + "Name": "bnz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 72, + "Name": "pop", + "Args": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "discard A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 73, + "Name": "dup", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + } + ] +} diff --git a/data/transactions/logic/langspec.json b/data/transactions/logic/langspec_v10.json similarity index 95% rename from data/transactions/logic/langspec.json rename to data/transactions/logic/langspec_v10.json index d3a353b2bf..de938ffb72 100644 --- a/data/transactions/logic/langspec.json +++ b/data/transactions/logic/langspec_v10.json @@ -1,5 +1,5 @@ { - "EvalMaxVersion": 10, + "Version": 10, "LogicSigVersion": 9, "NamedTypes": [ { @@ -107,6 +107,7 @@ "Opcode": 0, "Name": "err", "Size": 1, + "DocCost": "1", "Doc": "Fail immediately.", "IntroducedVersion": 1, "Groups": [ @@ -123,6 +124,7 @@ "[32]byte" ], "Size": 1, + "DocCost": "35", "Doc": "SHA256 hash of value A, yields [32]byte", "IntroducedVersion": 1, "Groups": [ @@ -139,6 +141,7 @@ "[32]byte" ], "Size": 1, + "DocCost": "130", "Doc": "Keccak256 hash of value A, yields [32]byte", "IntroducedVersion": 1, "Groups": [ @@ -155,6 +158,7 @@ "[32]byte" ], "Size": 1, + "DocCost": "45", "Doc": "SHA512_256 hash of value A, yields [32]byte", "IntroducedVersion": 1, "Groups": [ @@ -173,6 +177,7 @@ "bool" ], "Size": 1, + "DocCost": "1900", "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {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.", "IntroducedVersion": 1, @@ -198,6 +203,7 @@ "Secp256k1", "Secp256r1" ], + "DocCost": "Secp256k1=1700; Secp256r1=2500", "Doc": "for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey =\u003e {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": [ @@ -228,6 +234,7 @@ "Secp256k1", "Secp256r1" ], + "DocCost": "Secp256k1=650; Secp256r1=2400", "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": [ @@ -261,6 +268,7 @@ "Secp256k1", "Secp256r1" ], + "DocCost": "2000", "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": [ @@ -287,6 +295,7 @@ "uint64" ], "Size": 1, + "DocCost": "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`.", "IntroducedVersion": 1, @@ -305,6 +314,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A minus B. Fail if B \u003e A.", "IntroducedVersion": 1, "Groups": [ @@ -322,6 +332,7 @@ "uint64" ], "Size": 1, + "DocCost": "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`.", "IntroducedVersion": 1, @@ -340,6 +351,7 @@ "uint64" ], "Size": 1, + "DocCost": "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`.", "IntroducedVersion": 1, @@ -358,6 +370,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "A less than B =\u003e {0 or 1}", "IntroducedVersion": 1, "Groups": [ @@ -375,6 +388,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "A greater than B =\u003e {0 or 1}", "IntroducedVersion": 1, "Groups": [ @@ -392,6 +406,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "A less than or equal to B =\u003e {0 or 1}", "IntroducedVersion": 1, "Groups": [ @@ -409,6 +424,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "A greater than or equal to B =\u003e {0 or 1}", "IntroducedVersion": 1, "Groups": [ @@ -426,6 +442,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "A is not zero and B is not zero =\u003e {0 or 1}", "IntroducedVersion": 1, "Groups": [ @@ -443,6 +460,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "A is not zero or B is not zero =\u003e {0 or 1}", "IntroducedVersion": 1, "Groups": [ @@ -460,6 +478,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "A is equal to B =\u003e {0 or 1}", "IntroducedVersion": 1, "Groups": [ @@ -477,6 +496,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "A is not equal to B =\u003e {0 or 1}", "IntroducedVersion": 1, "Groups": [ @@ -493,6 +513,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A == 0 yields 1; else 0", "IntroducedVersion": 1, "Groups": [ @@ -509,6 +530,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "yields length of byte value A", "IntroducedVersion": 1, "Groups": [ @@ -525,6 +547,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "converts uint64 A to big-endian byte array, always of length 8", "IntroducedVersion": 1, "Groups": [ @@ -541,6 +564,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "converts big-endian byte array A to uint64. Fails if len(A) \u003e 8. Padded by leading 0s if len(A) \u003c 8.", "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", "IntroducedVersion": 1, @@ -559,6 +583,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A modulo B. Fail if B == 0.", "IntroducedVersion": 1, "Groups": [ @@ -576,6 +601,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A bitwise-or B", "IntroducedVersion": 1, "Groups": [ @@ -593,6 +619,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A bitwise-and B", "IntroducedVersion": 1, "Groups": [ @@ -610,6 +637,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A bitwise-xor B", "IntroducedVersion": 1, "Groups": [ @@ -626,6 +654,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "bitwise invert value A", "IntroducedVersion": 1, "Groups": [ @@ -644,6 +673,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", "IntroducedVersion": 1, "Groups": [ @@ -662,6 +692,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", "IntroducedVersion": 2, "Groups": [ @@ -684,6 +715,7 @@ "uint64" ], "Size": 1, + "DocCost": "20", "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.", "IntroducedVersion": 4, @@ -695,6 +727,7 @@ "Opcode": 32, "Name": "intcblock", "Size": 0, + "DocCost": "1", "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": [ @@ -716,6 +749,7 @@ "uint64" ], "Size": 2, + "DocCost": "1", "Doc": "Ith constant from intcblock", "ImmediateNote": [ { @@ -736,6 +770,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "constant 0 from intcblock", "IntroducedVersion": 1, "Groups": [ @@ -749,6 +784,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "constant 1 from intcblock", "IntroducedVersion": 1, "Groups": [ @@ -762,6 +798,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "constant 2 from intcblock", "IntroducedVersion": 1, "Groups": [ @@ -775,6 +812,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "constant 3 from intcblock", "IntroducedVersion": 1, "Groups": [ @@ -785,6 +823,7 @@ "Opcode": 38, "Name": "bytecblock", "Size": 0, + "DocCost": "1", "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": [ @@ -806,6 +845,7 @@ "[]byte" ], "Size": 2, + "DocCost": "1", "Doc": "Ith constant from bytecblock", "ImmediateNote": [ { @@ -826,6 +866,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "constant 0 from bytecblock", "IntroducedVersion": 1, "Groups": [ @@ -839,6 +880,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "constant 1 from bytecblock", "IntroducedVersion": 1, "Groups": [ @@ -852,6 +894,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "constant 2 from bytecblock", "IntroducedVersion": 1, "Groups": [ @@ -865,6 +908,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "constant 3 from bytecblock", "IntroducedVersion": 1, "Groups": [ @@ -878,6 +922,7 @@ "[]byte" ], "Size": 2, + "DocCost": "1", "Doc": "Nth LogicSig argument", "ImmediateNote": [ { @@ -898,6 +943,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "LogicSig argument 0", "IntroducedVersion": 1, "Groups": [ @@ -911,6 +957,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "LogicSig argument 1", "IntroducedVersion": 1, "Groups": [ @@ -924,6 +971,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "LogicSig argument 2", "IntroducedVersion": 1, "Groups": [ @@ -937,6 +985,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "LogicSig argument 3", "IntroducedVersion": 1, "Groups": [ @@ -1090,6 +1139,7 @@ "[]byte", "uint64" ], + "DocCost": "1", "Doc": "field F of current transaction", "ImmediateNote": [ { @@ -1149,6 +1199,7 @@ "uint64", "uint64" ], + "DocCost": "1", "Doc": "global field F", "ImmediateNote": [ { @@ -1310,6 +1361,7 @@ "[]byte", "uint64" ], + "DocCost": "1", "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": [ @@ -1337,6 +1389,7 @@ "any" ], "Size": 2, + "DocCost": "1", "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", "ImmediateNote": [ { @@ -1357,6 +1410,7 @@ "any" ], "Size": 2, + "DocCost": "1", "Doc": "store A to the Ith scratch space", "ImmediateNote": [ { @@ -1395,6 +1449,7 @@ "[]byte", "[]byte" ], + "DocCost": "1", "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", "ImmediateNote": [ { @@ -1439,6 +1494,7 @@ "[]byte", "[]byte" ], + "DocCost": "1", "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": [ { @@ -1613,6 +1669,7 @@ "[]byte", "uint64" ], + "DocCost": "1", "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": [ @@ -1656,6 +1713,7 @@ "[]byte", "[]byte" ], + "DocCost": "1", "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": [ { @@ -1682,6 +1740,7 @@ "any" ], "Size": 3, + "DocCost": "1", "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 \u003c GroupIndex.", "ImmediateNote": [ @@ -1711,6 +1770,7 @@ "any" ], "Size": 2, + "DocCost": "1", "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 \u003c GroupIndex.", "ImmediateNote": [ @@ -1732,6 +1792,7 @@ "uint64" ], "Size": 2, + "DocCost": "1", "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 \u003c GroupIndex.", "ImmediateNote": [ @@ -1756,6 +1817,7 @@ "uint64" ], "Size": 1, + "DocCost": "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 \u003c GroupIndex.", "IntroducedVersion": 4, @@ -1773,6 +1835,7 @@ "any" ], "Size": 1, + "DocCost": "1", "Doc": "Ath scratch space value. All scratch spaces are 0 at program start.", "IntroducedVersion": 5, "Groups": [ @@ -1787,6 +1850,7 @@ "any" ], "Size": 1, + "DocCost": "1", "Doc": "store B to the Ath scratch space", "IntroducedVersion": 5, "Groups": [ @@ -1800,6 +1864,7 @@ "uint64" ], "Size": 3, + "DocCost": "1", "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": [ @@ -1821,6 +1886,7 @@ "uint64" ], "Size": 3, + "DocCost": "1", "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": [ @@ -1839,6 +1905,7 @@ "Opcode": 66, "Name": "b", "Size": 3, + "DocCost": "1", "Doc": "branch unconditionally to TARGET", "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", "ImmediateNote": [ @@ -1860,6 +1927,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "use A as success value; end", "IntroducedVersion": 2, "Groups": [ @@ -1873,6 +1941,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "immediately fail unless A is a non-zero number", "IntroducedVersion": 3, "Groups": [ @@ -1886,6 +1955,7 @@ "any" ], "Size": 2, + "DocCost": "1", "Doc": "replace the Nth value from the top of the stack with A. bury 0 fails.", "ImmediateNote": [ { @@ -1903,6 +1973,7 @@ "Opcode": 70, "Name": "popn", "Size": 2, + "DocCost": "1", "Doc": "remove N values from the top of the stack", "ImmediateNote": [ { @@ -1923,6 +1994,7 @@ "any" ], "Size": 2, + "DocCost": "1", "Doc": "duplicate A, N times", "ImmediateNote": [ { @@ -1943,6 +2015,7 @@ "any" ], "Size": 1, + "DocCost": "1", "Doc": "discard A", "IntroducedVersion": 1, "Groups": [ @@ -1960,6 +2033,7 @@ "any" ], "Size": 1, + "DocCost": "1", "Doc": "duplicate A", "IntroducedVersion": 1, "Groups": [ @@ -1980,6 +2054,7 @@ "any" ], "Size": 1, + "DocCost": "1", "Doc": "duplicate A and B", "IntroducedVersion": 2, "Groups": [ @@ -1997,6 +2072,7 @@ "any" ], "Size": 2, + "DocCost": "1", "Doc": "Nth value from the top of the stack. dig 0 is equivalent to dup", "ImmediateNote": [ { @@ -2022,6 +2098,7 @@ "any" ], "Size": 1, + "DocCost": "1", "Doc": "swaps A and B on stack", "IntroducedVersion": 3, "Groups": [ @@ -2040,6 +2117,7 @@ "any" ], "Size": 1, + "DocCost": "1", "Doc": "selects one of two values based on top-of-stack: B if C != 0, else A", "IntroducedVersion": 3, "Groups": [ @@ -2056,6 +2134,7 @@ "any" ], "Size": 2, + "DocCost": "1", "Doc": "remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth \u003c= N.", "ImmediateNote": [ { @@ -2079,6 +2158,7 @@ "any" ], "Size": 2, + "DocCost": "1", "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 \u003c= N.", "ImmediateNote": [ { @@ -2103,6 +2183,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "join A and B", "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", "IntroducedVersion": 2, @@ -2120,6 +2201,7 @@ "[]byte" ], "Size": 3, + "DocCost": "1", "Doc": "A range of bytes from A starting at S up to but not including E. If E \u003c S, or either is larger than the array length, the program fails", "ImmediateNote": [ { @@ -2150,6 +2232,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "A range of bytes from A starting at B up to but not including C. If C \u003c B, or either is larger than the array length, the program fails", "IntroducedVersion": 2, "Groups": [ @@ -2167,6 +2250,7 @@ "uint64" ], "Size": 1, + "DocCost": "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", "IntroducedVersion": 3, @@ -2186,6 +2270,7 @@ "any" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 3, @@ -2204,6 +2289,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails", "IntroducedVersion": 3, "Groups": [ @@ -2222,6 +2308,7 @@ "[]byte" ], "Size": 1, + "DocCost": "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", "IntroducedVersion": 3, "Groups": [ @@ -2238,6 +2325,7 @@ "[]byte" ], "Size": 3, + "DocCost": "1", "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": [ { @@ -2268,6 +2356,7 @@ "[]byte" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 5, "Groups": [ @@ -2285,6 +2374,7 @@ "uint64" ], "Size": 1, + "DocCost": "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", "IntroducedVersion": 5, "Groups": [ @@ -2302,6 +2392,7 @@ "uint64" ], "Size": 1, + "DocCost": "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", "IntroducedVersion": 5, "Groups": [ @@ -2319,6 +2410,7 @@ "uint64" ], "Size": 1, + "DocCost": "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", "IntroducedVersion": 5, "Groups": [ @@ -2336,6 +2428,7 @@ "[]byte" ], "Size": 2, + "DocCost": "1", "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": [ { @@ -2361,6 +2454,7 @@ "[]byte" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 7, "Groups": [ @@ -2385,6 +2479,7 @@ "any", "any" ], + "DocCost": "1 + 1 per 16 bytes of A", "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": [ @@ -2421,6 +2516,7 @@ "uint64", "[]byte" ], + "DocCost": "25 + 2 per 7 bytes of A", "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": [ @@ -2446,6 +2542,7 @@ "uint64" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 2, @@ -2464,6 +2561,7 @@ "bool" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 2, @@ -2482,6 +2580,7 @@ "any" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 2, @@ -2502,6 +2601,7 @@ "bool" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 2, @@ -2519,6 +2619,7 @@ "any" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 2, @@ -2538,6 +2639,7 @@ "bool" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 2, @@ -2554,6 +2656,7 @@ "any" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 2, @@ -2569,6 +2672,7 @@ "any" ], "Size": 1, + "DocCost": "1", "Doc": "write B to key A in the global state of the current application", "IntroducedVersion": 2, "Groups": [ @@ -2583,6 +2687,7 @@ "[]byte" ], "Size": 1, + "DocCost": "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.)", "IntroducedVersion": 2, @@ -2597,6 +2702,7 @@ "[]byte" ], "Size": 1, + "DocCost": "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.)", "IntroducedVersion": 2, @@ -2624,6 +2730,7 @@ "uint64", "bool" ], + "DocCost": "1", "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": [ @@ -2678,6 +2785,7 @@ "address", "address" ], + "DocCost": "1", "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": [ @@ -2726,6 +2834,7 @@ "address", "address" ], + "DocCost": "1", "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": [ @@ -2780,6 +2889,7 @@ "uint64", "uint64" ], + "DocCost": "1", "Doc": "X is field F from account A. Y is 1 if A owns positive algos, else 0", "ImmediateNote": [ { @@ -2804,6 +2914,7 @@ "uint64" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 3, @@ -2818,6 +2929,7 @@ "[]byte" ], "Size": 0, + "DocCost": "1", "Doc": "immediate BYTES", "DocExtra": "pushbytes args are not added to the bytecblock during assembly processes", "ImmediateNote": [ @@ -2839,6 +2951,7 @@ "uint64" ], "Size": 0, + "DocCost": "1", "Doc": "immediate UINT", "DocExtra": "pushint args are not added to the intcblock during assembly processes", "ImmediateNote": [ @@ -2857,6 +2970,7 @@ "Opcode": 130, "Name": "pushbytess", "Size": 0, + "DocCost": "1", "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": [ @@ -2875,6 +2989,7 @@ "Opcode": 131, "Name": "pushints", "Size": 0, + "DocCost": "1", "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": [ @@ -2901,6 +3016,7 @@ "bool" ], "Size": 1, + "DocCost": "1900", "Doc": "for (data A, signature B, pubkey C) verify the signature of the data against the pubkey =\u003e {0 or 1}", "IntroducedVersion": 7, "Groups": [ @@ -2911,6 +3027,7 @@ "Opcode": 136, "Name": "callsub", "Size": 3, + "DocCost": "1", "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": [ @@ -2929,6 +3046,7 @@ "Opcode": 137, "Name": "retsub", "Size": 1, + "DocCost": "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.", "IntroducedVersion": 4, @@ -2940,6 +3058,7 @@ "Opcode": 138, "Name": "proto", "Size": 3, + "DocCost": "1", "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": [ @@ -2966,6 +3085,7 @@ "any" ], "Size": 2, + "DocCost": "1", "Doc": "Nth (signed) value from the frame pointer.", "ImmediateNote": [ { @@ -2986,6 +3106,7 @@ "any" ], "Size": 2, + "DocCost": "1", "Doc": "replace the Nth (signed) value from the frame pointer in the stack with A", "ImmediateNote": [ { @@ -3006,6 +3127,7 @@ "uint64" ], "Size": 0, + "DocCost": "1", "Doc": "branch to the Ath label. Continue at following instruction if index A exceeds the number of labels.", "ImmediateNote": [ { @@ -3023,6 +3145,7 @@ "Opcode": 142, "Name": "match", "Size": 0, + "DocCost": "1", "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": [ @@ -3048,6 +3171,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A times 2^B, modulo 2^64", "IntroducedVersion": 4, "Groups": [ @@ -3065,6 +3189,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A divided by 2^B", "IntroducedVersion": 4, "Groups": [ @@ -3081,6 +3206,7 @@ "uint64" ], "Size": 1, + "DocCost": "4", "Doc": "The largest integer I such that I^2 \u003c= A", "IntroducedVersion": 4, "Groups": [ @@ -3097,6 +3223,7 @@ "uint64" ], "Size": 1, + "DocCost": "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", "IntroducedVersion": 4, @@ -3115,6 +3242,7 @@ "uint64" ], "Size": 1, + "DocCost": "1", "Doc": "A raised to the Bth power. Fail if A == B == 0 and on overflow", "IntroducedVersion": 4, "Groups": [ @@ -3133,6 +3261,7 @@ "uint64" ], "Size": 1, + "DocCost": "10", "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", "IntroducedVersion": 4, "Groups": [ @@ -3149,6 +3278,7 @@ "[]byte" ], "Size": 1, + "DocCost": "40", "Doc": "The largest integer I such that I^2 \u003c= A. A and I are interpreted as big-endian unsigned integers", "IntroducedVersion": 6, "Groups": [ @@ -3167,6 +3297,7 @@ "uint64" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 6, @@ -3184,6 +3315,7 @@ "[]byte" ], "Size": 1, + "DocCost": "130", "Doc": "SHA3_256 hash of value A, yields [32]byte", "IntroducedVersion": 7, "Groups": [ @@ -3201,6 +3333,7 @@ "[]byte" ], "Size": 1, + "DocCost": "10", "Doc": "A plus B. A and B are interpreted as big-endian unsigned integers", "IntroducedVersion": 4, "Groups": [ @@ -3218,6 +3351,7 @@ "bigint" ], "Size": 1, + "DocCost": "10", "Doc": "A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.", "IntroducedVersion": 4, "Groups": [ @@ -3235,6 +3369,7 @@ "bigint" ], "Size": 1, + "DocCost": "20", "Doc": "A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", "IntroducedVersion": 4, "Groups": [ @@ -3252,6 +3387,7 @@ "[]byte" ], "Size": 1, + "DocCost": "20", "Doc": "A times B. A and B are interpreted as big-endian unsigned integers.", "IntroducedVersion": 4, "Groups": [ @@ -3269,6 +3405,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers", "IntroducedVersion": 4, "Groups": [ @@ -3286,6 +3423,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers", "IntroducedVersion": 4, "Groups": [ @@ -3303,6 +3441,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", "IntroducedVersion": 4, "Groups": [ @@ -3320,6 +3459,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", "IntroducedVersion": 4, "Groups": [ @@ -3337,6 +3477,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers", "IntroducedVersion": 4, "Groups": [ @@ -3354,6 +3495,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers", "IntroducedVersion": 4, "Groups": [ @@ -3371,6 +3513,7 @@ "[]byte" ], "Size": 1, + "DocCost": "20", "Doc": "A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", "IntroducedVersion": 4, "Groups": [ @@ -3388,6 +3531,7 @@ "[]byte" ], "Size": 1, + "DocCost": "6", "Doc": "A bitwise-or B. A and B are zero-left extended to the greater of their lengths", "IntroducedVersion": 4, "Groups": [ @@ -3405,6 +3549,7 @@ "[]byte" ], "Size": 1, + "DocCost": "6", "Doc": "A bitwise-and B. A and B are zero-left extended to the greater of their lengths", "IntroducedVersion": 4, "Groups": [ @@ -3422,6 +3567,7 @@ "[]byte" ], "Size": 1, + "DocCost": "6", "Doc": "A bitwise-xor B. A and B are zero-left extended to the greater of their lengths", "IntroducedVersion": 4, "Groups": [ @@ -3438,6 +3584,7 @@ "[]byte" ], "Size": 1, + "DocCost": "4", "Doc": "A with all bits inverted", "IntroducedVersion": 4, "Groups": [ @@ -3454,6 +3601,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "zero filled byte-array of length A", "IntroducedVersion": 4, "Groups": [ @@ -3467,6 +3615,7 @@ "[]byte" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 5, @@ -3478,6 +3627,7 @@ "Opcode": 177, "Name": "itxn_begin", "Size": 1, + "DocCost": "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.", "IntroducedVersion": 5, @@ -3598,6 +3748,7 @@ "[]byte", "[]byte" ], + "DocCost": "1", "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": [ @@ -3617,6 +3768,7 @@ "Opcode": 179, "Name": "itxn_submit", "Size": 1, + "DocCost": "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.", "IntroducedVersion": 5, @@ -3771,6 +3923,7 @@ "[]byte", "uint64" ], + "DocCost": "1", "Doc": "field F of the last inner transaction", "ImmediateNote": [ { @@ -3810,6 +3963,7 @@ "[]byte", "[]byte" ], + "DocCost": "1", "Doc": "Ith value of the array field F of the last inner transaction", "ImmediateNote": [ { @@ -3833,6 +3987,7 @@ "Opcode": 182, "Name": "itxn_next", "Size": 1, + "DocCost": "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", "IntroducedVersion": 6, @@ -3987,6 +4142,7 @@ "[]byte", "uint64" ], + "DocCost": "1", "Doc": "field F of the Tth transaction in the last inner group submitted", "ImmediateNote": [ { @@ -4031,6 +4187,7 @@ "[]byte", "[]byte" ], + "DocCost": "1", "Doc": "Ith value of the array field F from the Tth transaction in the last inner group submitted", "ImmediateNote": [ { @@ -4066,6 +4223,7 @@ "bool" ], "Size": 1, + "DocCost": "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`.", "IntroducedVersion": 8, @@ -4085,6 +4243,7 @@ "[]byte" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 8, "Groups": [ @@ -4100,6 +4259,7 @@ "[]byte" ], "Size": 1, + "DocCost": "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.", "IntroducedVersion": 8, "Groups": [ @@ -4116,6 +4276,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "delete box named A if it exists. Return 1 if A existed, 0 otherwise", "IntroducedVersion": 8, "Groups": [ @@ -4133,6 +4294,7 @@ "bool" ], "Size": 1, + "DocCost": "1", "Doc": "X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0.", "IntroducedVersion": 8, "Groups": [ @@ -4150,6 +4312,7 @@ "bool" ], "Size": 1, + "DocCost": "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`", "IntroducedVersion": 8, @@ -4165,6 +4328,7 @@ "[]byte" ], "Size": 1, + "DocCost": "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`", "IntroducedVersion": 8, @@ -4200,6 +4364,7 @@ "[]byte", "[]byte" ], + "DocCost": "1", "Doc": "Ath value of the array field F of the current transaction", "ImmediateNote": [ { @@ -4242,6 +4407,7 @@ "[]byte", "[]byte" ], + "DocCost": "1", "Doc": "Ath value of the array field F from the Tth transaction in the current group", "ImmediateNote": [ { @@ -4290,6 +4456,7 @@ "[]byte", "[]byte" ], + "DocCost": "1", "Doc": "Bth value of the array field F from the Ath transaction in the current group", "ImmediateNote": [ { @@ -4314,6 +4481,7 @@ "[]byte" ], "Size": 1, + "DocCost": "1", "Doc": "Ath LogicSig argument", "IntroducedVersion": 5, "Groups": [ @@ -4331,6 +4499,7 @@ "any" ], "Size": 1, + "DocCost": "1", "Doc": "Bth scratch space value of the Ath transaction in the current group", "IntroducedVersion": 6, "Groups": [ @@ -4347,6 +4516,7 @@ "any" ], "Size": 2, + "DocCost": "1", "Doc": "Ath value of the array field F of the last inner transaction", "ImmediateNote": [ { @@ -4371,6 +4541,7 @@ "any" ], "Size": 3, + "DocCost": "1", "Doc": "Ath value of the array field F from the Tth transaction in the last inner group submitted", "ImmediateNote": [ { @@ -4406,6 +4577,7 @@ "ArgEnum": [ "VrfAlgorand" ], + "DocCost": "5700", "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": [ @@ -4439,6 +4611,7 @@ "[]byte", "uint64" ], + "DocCost": "1", "Doc": "field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)", "ImmediateNote": [ { @@ -4464,6 +4637,7 @@ "[]byte" ], "Size": 2, + "DocCost": "BN254g1=125; BN254g2=170; BLS12_381g1=205; BLS12_381g2=290", "Doc": "for curve points A and B, return the curve point A + B", "DocExtra": "A and B are curve points in affine representation: field element X concatenated with field element Y. Field element `Z` is encoded as follows.\nFor the base field elements (Fp), `Z` is encoded as a big-endian number and must be lower than the field modulus.\nFor the quadratic field extension (Fp2), `Z` is encoded as the concatenation of the individual encoding of the coefficients. For an Fp2 element of the form `Z = Z0 + Z1 i`, where `i` is a formal quadratic non-residue, the encoding of Z is the concatenation of the encoding of `Z0` and `Z1` in this order. (`Z0` and `Z1` must be less than the field modulus).\n\nThe point at infinity is encoded as `(X,Y) = (0,0)`.\nGroups G1 and G2 are denoted additively.\n\nFails if A or B is not in G.\nA and/or B are allowed to be the point at infinity.\nDoes _not_ check if A and B are in the main prime-order subgroup.", "ImmediateNote": [ @@ -4490,6 +4664,7 @@ "[]byte" ], "Size": 2, + "DocCost": "BN254g1=1810; BN254g2=3430; BLS12_381g1=2950; BLS12_381g2=6530", "Doc": "for curve point A and scalar B, return the curve point BA, the point A multiplied by the scalar B.", "DocExtra": "A is a curve point encoded and checked as described in `ec_add`. Scalar B is interpreted as a big-endian unsigned integer. Fails if B exceeds 32 bytes.", "ImmediateNote": [ @@ -4516,6 +4691,7 @@ "bool" ], "Size": 2, + "DocCost": "BN254g1=8000 + 7400 per 64 bytes of B; BN254g2=8000 + 7400 per 128 bytes of B; BLS12_381g1=13000 + 10000 per 96 bytes of B; BLS12_381g2=13000 + 10000 per 192 bytes of B", "Doc": "1 if the product of the pairing of each point in A with its respective point in B is equal to the identity element of the target group Gt, else 0", "DocExtra": "A and B are concatenated points, encoded and checked as described in `ec_add`. A contains points of the group G, B contains points of the associated group (G2 if G is G1, and vice versa). Fails if A and B have a different number of points, or if any point is not in its described group or outside the main prime-order subgroup - a stronger condition than other opcodes. AVM values are limited to 4096 bytes, so `ec_pairing_check` is limited by the size of the points in the groups being operated upon.", "ImmediateNote": [ @@ -4542,6 +4718,7 @@ "[]byte" ], "Size": 2, + "DocCost": "BN254g1=3600 + 90 per 32 bytes of B; BN254g2=7200 + 270 per 32 bytes of B; BLS12_381g1=6500 + 95 per 32 bytes of B; BLS12_381g2=14850 + 485 per 32 bytes of B", "Doc": "for curve points A and scalars B, return curve point B0A0 + B1A1 + B2A2 + ... + BnAn", "DocExtra": "A is a list of concatenated points, encoded and checked as described in `ec_add`. B is a list of concatenated scalars which, unlike ec_scalar_mul, must all be exactly 32 bytes long.\nThe name `ec_multi_scalar_mul` was chosen to reflect common usage, but a more consistent name would be `ec_multi_scalar_mul`. AVM values are limited to 4096 bytes, so `ec_multi_scalar_mul` is limited by the size of the points in the group being operated upon.", "ImmediateNote": [ @@ -4567,6 +4744,7 @@ "bool" ], "Size": 2, + "DocCost": "BN254g1=20; BN254g2=3100; BLS12_381g1=1850; BLS12_381g2=2340", "Doc": "1 if A is in the main prime-order subgroup of G (including the point at infinity) else 0. Program fails if A is not in G at all.", "ImmediateNote": [ { @@ -4591,6 +4769,7 @@ "[]byte" ], "Size": 2, + "DocCost": "BN254g1=630; BN254g2=3300; BLS12_381g1=1950; BLS12_381g2=8150", "Doc": "maps field element A to group G", "DocExtra": "BN254 points are mapped by the SVDW map. BLS12-381 points are mapped by the SSWU map.\nG1 element inputs are base field elements and G2 element inputs are quadratic field elements, with nearly the same encoding rules (for field elements) as defined in `ec_add`. There is one difference of encoding rule: G1 element inputs do not need to be 0-padded if they fit in less than 32 bytes for BN254 and less than 48 bytes for BLS12-381. (As usual, the empty byte array represents 0.) G2 elements inputs need to be always have the required size.", "ImmediateNote": [ diff --git a/data/transactions/logic/langspec_v2.json b/data/transactions/logic/langspec_v2.json new file mode 100644 index 0000000000..b0319cf998 --- /dev/null +++ b/data/transactions/logic/langspec_v2.json @@ -0,0 +1,1744 @@ +{ + "Version": 2, + "LogicSigVersion": 9, + "NamedTypes": [ + { + "Name": "uint64", + "Abbreviation": "i", + "Bound": [ + 0, + 18446744073709551615 + ], + "AVMType": "uint64" + }, + { + "Name": "stateKey", + "Abbreviation": "K", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "none", + "Abbreviation": "x", + "Bound": [ + 0, + 0 + ], + "AVMType": "none" + }, + { + "Name": "method", + "Abbreviation": "M", + "Bound": [ + 4, + 4 + ], + "AVMType": "[]byte" + }, + { + "Name": "boxName", + "Abbreviation": "N", + "Bound": [ + 1, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "bool", + "Abbreviation": "T", + "Bound": [ + 0, + 1 + ], + "AVMType": "uint64" + }, + { + "Name": "bigint", + "Abbreviation": "I", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "any", + "Abbreviation": "a", + "Bound": [ + 0, + 0 + ], + "AVMType": "any" + }, + { + "Name": "address", + "Abbreviation": "A", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + }, + { + "Name": "[]byte", + "Abbreviation": "b", + "Bound": [ + 0, + 4096 + ], + "AVMType": "[]byte" + }, + { + "Name": "[32]byte", + "Abbreviation": "H", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + } + ], + "Ops": [ + { + "Opcode": 0, + "Name": "err", + "Size": 1, + "DocCost": "1", + "Doc": "Fail immediately.", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 1, + "Name": "sha256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "35", + "Doc": "SHA256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 2, + "Name": "keccak256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "Keccak256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 3, + "Name": "sha512_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "45", + "Doc": "SHA512_256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 4, + "Name": "ed25519verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {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.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 8, + "Name": "+", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 9, + "Name": "-", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A minus B. Fail if B \u003e A.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 10, + "Name": "/", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 11, + "Name": "*", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 12, + "Name": "\u003c", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 13, + "Name": "\u003e", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 14, + "Name": "\u003c=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 15, + "Name": "\u003e=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 16, + "Name": "\u0026\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero and B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 17, + "Name": "||", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero or B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 18, + "Name": "==", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 19, + "Name": "!=", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 20, + "Name": "!", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A == 0 yields 1; else 0", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 21, + "Name": "len", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "yields length of byte value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 22, + "Name": "itob", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts uint64 A to big-endian byte array, always of length 8", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 23, + "Name": "btoi", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts big-endian byte array A to uint64. Fails if len(A) \u003e 8. Padded by leading 0s if len(A) \u003c 8.", + "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 24, + "Name": "%", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A modulo B. Fail if B == 0.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 25, + "Name": "|", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-or B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 26, + "Name": "\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-and B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 27, + "Name": "^", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-xor B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 28, + "Name": "~", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "bitwise invert value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 29, + "Name": "mulw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 30, + "Name": "addw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 32, + "Name": "intcblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of int constant values", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 33, + "Name": "intc", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from intcblock", + "ImmediateNote": [ + { + "Comment": "an index in the intcblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 34, + "Name": "intc_0", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 35, + "Name": "intc_1", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 36, + "Name": "intc_2", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 37, + "Name": "intc_3", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 38, + "Name": "bytecblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of byte constant values", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 39, + "Name": "bytec", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from bytecblock", + "ImmediateNote": [ + { + "Comment": "an index in the bytecblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 40, + "Name": "bytec_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 41, + "Name": "bytec_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 42, + "Name": "bytec_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 43, + "Name": "bytec_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 44, + "Name": "arg", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth LogicSig argument", + "ImmediateNote": [ + { + "Comment": "an arg index", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 45, + "Name": "arg_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 0", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 46, + "Name": "arg_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 1", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 47, + "Name": "arg_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 2", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 48, + "Name": "arg_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 3", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 49, + "Name": "txn", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool" + ], + "DocCost": "1", + "Doc": "field F of current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 50, + "Name": "global", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "MinTxnFee", + "MinBalance", + "MaxTxnLife", + "ZeroAddress", + "GroupSize", + "LogicSigVersion", + "Round", + "LatestTimestamp", + "CurrentApplicationID" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "uint64", + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "Doc": "global field F", + "ImmediateNote": [ + { + "Comment": "a global field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "global" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 51, + "Name": "gtxn", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 52, + "Name": "load", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 53, + "Name": "store", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "store A to the Ith scratch space", + "ImmediateNote": [ + { + "Comment": "position in scratch space to store to", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 54, + "Name": "txna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts" + ], + "ArgEnumTypes": [ + "[]byte", + "address" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 55, + "Name": "gtxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts" + ], + "ArgEnumTypes": [ + "[]byte", + "address" + ], + "DocCost": "1", + "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": [ + { + "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" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 64, + "Name": "bnz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 65, + "Name": "bz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 66, + "Name": "b", + "Size": 3, + "DocCost": "1", + "Doc": "branch unconditionally to TARGET", + "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", + "ImmediateNote": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 67, + "Name": "return", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "use A as success value; end", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 72, + "Name": "pop", + "Args": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "discard A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 73, + "Name": "dup", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 74, + "Name": "dup2", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any", + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A and B", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 80, + "Name": "concat", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "join A and B", + "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 81, + "Name": "substring", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "Doc": "A range of bytes from A starting at S up to but not including E. If E \u003c S, or either is larger than the array length, the program fails", + "ImmediateNote": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "end position", + "Encoding": "uint8", + "Name": "E" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 82, + "Name": "substring3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A range of bytes from A starting at B up to but not including C. If C \u003c B, or either is larger than the array length, the program fails", + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 96, + "Name": "balance", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 97, + "Name": "app_opted_in", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 98, + "Name": "app_local_get", + "Args": [ + "uint64", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 99, + "Name": "app_local_get_ex", + "Args": [ + "uint64", + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 100, + "Name": "app_global_get", + "Args": [ + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 101, + "Name": "app_global_get_ex", + "Args": [ + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 102, + "Name": "app_local_put", + "Args": [ + "uint64", + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 103, + "Name": "app_global_put", + "Args": [ + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "write B to key A in the global state of the current application", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 104, + "Name": "app_local_del", + "Args": [ + "uint64", + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 105, + "Name": "app_global_del", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 112, + "Name": "asset_holding_get", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetBalance", + "AssetFrozen" + ], + "ArgEnumTypes": [ + "uint64", + "bool" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset holding field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_holding" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 113, + "Name": "asset_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetTotal", + "AssetDecimals", + "AssetDefaultFrozen", + "AssetUnitName", + "AssetName", + "AssetURL", + "AssetMetadataHash", + "AssetManager", + "AssetReserve", + "AssetFreeze", + "AssetClawback" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_params" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + } + ] +} diff --git a/data/transactions/logic/langspec_v3.json b/data/transactions/logic/langspec_v3.json new file mode 100644 index 0000000000..e3fe6e4938 --- /dev/null +++ b/data/transactions/logic/langspec_v3.json @@ -0,0 +1,2183 @@ +{ + "Version": 3, + "LogicSigVersion": 9, + "NamedTypes": [ + { + "Name": "uint64", + "Abbreviation": "i", + "Bound": [ + 0, + 18446744073709551615 + ], + "AVMType": "uint64" + }, + { + "Name": "stateKey", + "Abbreviation": "K", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "none", + "Abbreviation": "x", + "Bound": [ + 0, + 0 + ], + "AVMType": "none" + }, + { + "Name": "method", + "Abbreviation": "M", + "Bound": [ + 4, + 4 + ], + "AVMType": "[]byte" + }, + { + "Name": "boxName", + "Abbreviation": "N", + "Bound": [ + 1, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "bool", + "Abbreviation": "T", + "Bound": [ + 0, + 1 + ], + "AVMType": "uint64" + }, + { + "Name": "bigint", + "Abbreviation": "I", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "any", + "Abbreviation": "a", + "Bound": [ + 0, + 0 + ], + "AVMType": "any" + }, + { + "Name": "address", + "Abbreviation": "A", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + }, + { + "Name": "[]byte", + "Abbreviation": "b", + "Bound": [ + 0, + 4096 + ], + "AVMType": "[]byte" + }, + { + "Name": "[32]byte", + "Abbreviation": "H", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + } + ], + "Ops": [ + { + "Opcode": 0, + "Name": "err", + "Size": 1, + "DocCost": "1", + "Doc": "Fail immediately.", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 1, + "Name": "sha256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "35", + "Doc": "SHA256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 2, + "Name": "keccak256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "Keccak256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 3, + "Name": "sha512_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "45", + "Doc": "SHA512_256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 4, + "Name": "ed25519verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {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.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 8, + "Name": "+", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 9, + "Name": "-", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A minus B. Fail if B \u003e A.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 10, + "Name": "/", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 11, + "Name": "*", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 12, + "Name": "\u003c", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 13, + "Name": "\u003e", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 14, + "Name": "\u003c=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 15, + "Name": "\u003e=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 16, + "Name": "\u0026\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero and B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 17, + "Name": "||", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero or B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 18, + "Name": "==", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 19, + "Name": "!=", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 20, + "Name": "!", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A == 0 yields 1; else 0", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 21, + "Name": "len", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "yields length of byte value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 22, + "Name": "itob", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts uint64 A to big-endian byte array, always of length 8", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 23, + "Name": "btoi", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts big-endian byte array A to uint64. Fails if len(A) \u003e 8. Padded by leading 0s if len(A) \u003c 8.", + "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 24, + "Name": "%", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A modulo B. Fail if B == 0.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 25, + "Name": "|", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-or B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 26, + "Name": "\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-and B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 27, + "Name": "^", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-xor B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 28, + "Name": "~", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "bitwise invert value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 29, + "Name": "mulw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 30, + "Name": "addw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 32, + "Name": "intcblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of int constant values", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 33, + "Name": "intc", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from intcblock", + "ImmediateNote": [ + { + "Comment": "an index in the intcblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 34, + "Name": "intc_0", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 35, + "Name": "intc_1", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 36, + "Name": "intc_2", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 37, + "Name": "intc_3", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 38, + "Name": "bytecblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of byte constant values", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 39, + "Name": "bytec", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from bytecblock", + "ImmediateNote": [ + { + "Comment": "an index in the bytecblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 40, + "Name": "bytec_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 41, + "Name": "bytec_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 42, + "Name": "bytec_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 43, + "Name": "bytec_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 44, + "Name": "arg", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth LogicSig argument", + "ImmediateNote": [ + { + "Comment": "an arg index", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 45, + "Name": "arg_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 0", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 46, + "Name": "arg_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 1", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 47, + "Name": "arg_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 2", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 48, + "Name": "arg_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 3", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 49, + "Name": "txn", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 50, + "Name": "global", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "MinTxnFee", + "MinBalance", + "MaxTxnLife", + "ZeroAddress", + "GroupSize", + "LogicSigVersion", + "Round", + "LatestTimestamp", + "CurrentApplicationID", + "CreatorAddress" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "uint64", + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address" + ], + "DocCost": "1", + "Doc": "global field F", + "ImmediateNote": [ + { + "Comment": "a global field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "global" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 51, + "Name": "gtxn", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 52, + "Name": "load", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 53, + "Name": "store", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "store A to the Ith scratch space", + "ImmediateNote": [ + { + "Comment": "position in scratch space to store to", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 54, + "Name": "txna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 55, + "Name": "gtxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "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" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 56, + "Name": "gtxns", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 57, + "Name": "gtxnsa", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 64, + "Name": "bnz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 65, + "Name": "bz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 66, + "Name": "b", + "Size": 3, + "DocCost": "1", + "Doc": "branch unconditionally to TARGET", + "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", + "ImmediateNote": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 67, + "Name": "return", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "use A as success value; end", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 68, + "Name": "assert", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "immediately fail unless A is a non-zero number", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 72, + "Name": "pop", + "Args": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "discard A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 73, + "Name": "dup", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 74, + "Name": "dup2", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any", + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A and B", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 75, + "Name": "dig", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth value from the top of the stack. dig 0 is equivalent to dup", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 76, + "Name": "swap", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "swaps A and B on stack", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 77, + "Name": "select", + "Args": [ + "any", + "any", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "selects one of two values based on top-of-stack: B if C != 0, else A", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 80, + "Name": "concat", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "join A and B", + "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 81, + "Name": "substring", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "Doc": "A range of bytes from A starting at S up to but not including E. If E \u003c S, or either is larger than the array length, the program fails", + "ImmediateNote": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "end position", + "Encoding": "uint8", + "Name": "E" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 82, + "Name": "substring3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A range of bytes from A starting at B up to but not including C. If C \u003c B, or either is larger than the array length, the program fails", + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 83, + "Name": "getbit", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 84, + "Name": "setbit", + "Args": [ + "any", + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 85, + "Name": "getbyte", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 86, + "Name": "setbyte", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 96, + "Name": "balance", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 97, + "Name": "app_opted_in", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 98, + "Name": "app_local_get", + "Args": [ + "uint64", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 99, + "Name": "app_local_get_ex", + "Args": [ + "uint64", + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 100, + "Name": "app_global_get", + "Args": [ + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 101, + "Name": "app_global_get_ex", + "Args": [ + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 102, + "Name": "app_local_put", + "Args": [ + "uint64", + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 103, + "Name": "app_global_put", + "Args": [ + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "write B to key A in the global state of the current application", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 104, + "Name": "app_local_del", + "Args": [ + "uint64", + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 105, + "Name": "app_global_del", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 112, + "Name": "asset_holding_get", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetBalance", + "AssetFrozen" + ], + "ArgEnumTypes": [ + "uint64", + "bool" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset holding field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_holding" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 113, + "Name": "asset_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetTotal", + "AssetDecimals", + "AssetDefaultFrozen", + "AssetUnitName", + "AssetName", + "AssetURL", + "AssetMetadataHash", + "AssetManager", + "AssetReserve", + "AssetFreeze", + "AssetClawback" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_params" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 120, + "Name": "min_balance", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 128, + "Name": "pushbytes", + "Returns": [ + "[]byte" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate BYTES", + "DocExtra": "pushbytes args are not added to the bytecblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "a byte constant", + "Encoding": "varuint length, bytes", + "Name": "BYTES" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 129, + "Name": "pushint", + "Returns": [ + "uint64" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate UINT", + "DocExtra": "pushint args are not added to the intcblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "an int constant", + "Encoding": "varuint", + "Name": "UINT" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + } + ] +} diff --git a/data/transactions/logic/langspec_v4.json b/data/transactions/logic/langspec_v4.json new file mode 100644 index 0000000000..9ffb5f7419 --- /dev/null +++ b/data/transactions/logic/langspec_v4.json @@ -0,0 +1,2730 @@ +{ + "Version": 4, + "LogicSigVersion": 9, + "NamedTypes": [ + { + "Name": "uint64", + "Abbreviation": "i", + "Bound": [ + 0, + 18446744073709551615 + ], + "AVMType": "uint64" + }, + { + "Name": "stateKey", + "Abbreviation": "K", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "none", + "Abbreviation": "x", + "Bound": [ + 0, + 0 + ], + "AVMType": "none" + }, + { + "Name": "method", + "Abbreviation": "M", + "Bound": [ + 4, + 4 + ], + "AVMType": "[]byte" + }, + { + "Name": "boxName", + "Abbreviation": "N", + "Bound": [ + 1, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "bool", + "Abbreviation": "T", + "Bound": [ + 0, + 1 + ], + "AVMType": "uint64" + }, + { + "Name": "bigint", + "Abbreviation": "I", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "any", + "Abbreviation": "a", + "Bound": [ + 0, + 0 + ], + "AVMType": "any" + }, + { + "Name": "address", + "Abbreviation": "A", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + }, + { + "Name": "[]byte", + "Abbreviation": "b", + "Bound": [ + 0, + 4096 + ], + "AVMType": "[]byte" + }, + { + "Name": "[32]byte", + "Abbreviation": "H", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + } + ], + "Ops": [ + { + "Opcode": 0, + "Name": "err", + "Size": 1, + "DocCost": "1", + "Doc": "Fail immediately.", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 1, + "Name": "sha256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "35", + "Doc": "SHA256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 2, + "Name": "keccak256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "Keccak256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 3, + "Name": "sha512_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "45", + "Doc": "SHA512_256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 4, + "Name": "ed25519verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {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.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 8, + "Name": "+", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 9, + "Name": "-", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A minus B. Fail if B \u003e A.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 10, + "Name": "/", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 11, + "Name": "*", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 12, + "Name": "\u003c", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 13, + "Name": "\u003e", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 14, + "Name": "\u003c=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 15, + "Name": "\u003e=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 16, + "Name": "\u0026\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero and B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 17, + "Name": "||", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero or B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 18, + "Name": "==", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 19, + "Name": "!=", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 20, + "Name": "!", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A == 0 yields 1; else 0", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 21, + "Name": "len", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "yields length of byte value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 22, + "Name": "itob", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts uint64 A to big-endian byte array, always of length 8", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 23, + "Name": "btoi", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts big-endian byte array A to uint64. Fails if len(A) \u003e 8. Padded by leading 0s if len(A) \u003c 8.", + "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 24, + "Name": "%", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A modulo B. Fail if B == 0.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 25, + "Name": "|", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-or B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 26, + "Name": "\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-and B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 27, + "Name": "^", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-xor B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 28, + "Name": "~", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "bitwise invert value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 29, + "Name": "mulw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 30, + "Name": "addw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 31, + "Name": "divmodw", + "Args": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "20", + "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.", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 32, + "Name": "intcblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of int constant values", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 33, + "Name": "intc", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from intcblock", + "ImmediateNote": [ + { + "Comment": "an index in the intcblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 34, + "Name": "intc_0", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 35, + "Name": "intc_1", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 36, + "Name": "intc_2", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 37, + "Name": "intc_3", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 38, + "Name": "bytecblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of byte constant values", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 39, + "Name": "bytec", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from bytecblock", + "ImmediateNote": [ + { + "Comment": "an index in the bytecblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 40, + "Name": "bytec_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 41, + "Name": "bytec_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 42, + "Name": "bytec_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 43, + "Name": "bytec_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 44, + "Name": "arg", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth LogicSig argument", + "ImmediateNote": [ + { + "Comment": "an arg index", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 45, + "Name": "arg_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 0", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 46, + "Name": "arg_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 1", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 47, + "Name": "arg_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 2", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 48, + "Name": "arg_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 3", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 49, + "Name": "txn", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 50, + "Name": "global", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "MinTxnFee", + "MinBalance", + "MaxTxnLife", + "ZeroAddress", + "GroupSize", + "LogicSigVersion", + "Round", + "LatestTimestamp", + "CurrentApplicationID", + "CreatorAddress" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "uint64", + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address" + ], + "DocCost": "1", + "Doc": "global field F", + "ImmediateNote": [ + { + "Comment": "a global field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "global" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 51, + "Name": "gtxn", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 52, + "Name": "load", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 53, + "Name": "store", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "store A to the Ith scratch space", + "ImmediateNote": [ + { + "Comment": "position in scratch space to store to", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 54, + "Name": "txna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 55, + "Name": "gtxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "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" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 56, + "Name": "gtxns", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 57, + "Name": "gtxnsa", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 58, + "Name": "gload", + "Returns": [ + "any" + ], + "Size": 3, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 59, + "Name": "gloads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 60, + "Name": "gaid", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 61, + "Name": "gaids", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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 \u003c GroupIndex.", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 64, + "Name": "bnz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 65, + "Name": "bz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 66, + "Name": "b", + "Size": 3, + "DocCost": "1", + "Doc": "branch unconditionally to TARGET", + "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", + "ImmediateNote": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 67, + "Name": "return", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "use A as success value; end", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 68, + "Name": "assert", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "immediately fail unless A is a non-zero number", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 72, + "Name": "pop", + "Args": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "discard A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 73, + "Name": "dup", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 74, + "Name": "dup2", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any", + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A and B", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 75, + "Name": "dig", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth value from the top of the stack. dig 0 is equivalent to dup", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 76, + "Name": "swap", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "swaps A and B on stack", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 77, + "Name": "select", + "Args": [ + "any", + "any", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "selects one of two values based on top-of-stack: B if C != 0, else A", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 80, + "Name": "concat", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "join A and B", + "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 81, + "Name": "substring", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "Doc": "A range of bytes from A starting at S up to but not including E. If E \u003c S, or either is larger than the array length, the program fails", + "ImmediateNote": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "end position", + "Encoding": "uint8", + "Name": "E" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 82, + "Name": "substring3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A range of bytes from A starting at B up to but not including C. If C \u003c B, or either is larger than the array length, the program fails", + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 83, + "Name": "getbit", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 84, + "Name": "setbit", + "Args": [ + "any", + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 85, + "Name": "getbyte", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 86, + "Name": "setbyte", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 96, + "Name": "balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 97, + "Name": "app_opted_in", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 98, + "Name": "app_local_get", + "Args": [ + "any", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 99, + "Name": "app_local_get_ex", + "Args": [ + "any", + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 100, + "Name": "app_global_get", + "Args": [ + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 101, + "Name": "app_global_get_ex", + "Args": [ + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 102, + "Name": "app_local_put", + "Args": [ + "any", + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 103, + "Name": "app_global_put", + "Args": [ + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "write B to key A in the global state of the current application", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 104, + "Name": "app_local_del", + "Args": [ + "any", + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 105, + "Name": "app_global_del", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 112, + "Name": "asset_holding_get", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetBalance", + "AssetFrozen" + ], + "ArgEnumTypes": [ + "uint64", + "bool" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset holding field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_holding" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 113, + "Name": "asset_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetTotal", + "AssetDecimals", + "AssetDefaultFrozen", + "AssetUnitName", + "AssetName", + "AssetURL", + "AssetMetadataHash", + "AssetManager", + "AssetReserve", + "AssetFreeze", + "AssetClawback" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_params" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 120, + "Name": "min_balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 128, + "Name": "pushbytes", + "Returns": [ + "[]byte" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate BYTES", + "DocExtra": "pushbytes args are not added to the bytecblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "a byte constant", + "Encoding": "varuint length, bytes", + "Name": "BYTES" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 129, + "Name": "pushint", + "Returns": [ + "uint64" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate UINT", + "DocExtra": "pushint args are not added to the intcblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "an int constant", + "Encoding": "varuint", + "Name": "UINT" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 136, + "Name": "callsub", + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 137, + "Name": "retsub", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 144, + "Name": "shl", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times 2^B, modulo 2^64", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 145, + "Name": "shr", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A divided by 2^B", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 146, + "Name": "sqrt", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "4", + "Doc": "The largest integer I such that I^2 \u003c= A", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 147, + "Name": "bitlen", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 148, + "Name": "exp", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A raised to the Bth power. Fail if A == B == 0 and on overflow", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 149, + "Name": "expw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "10", + "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 160, + "Name": "b+", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A plus B. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 161, + "Name": "b-", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 162, + "Name": "b/", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 163, + "Name": "b*", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A times B. A and B are interpreted as big-endian unsigned integers.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 164, + "Name": "b\u003c", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 165, + "Name": "b\u003e", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 166, + "Name": "b\u003c=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 167, + "Name": "b\u003e=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 168, + "Name": "b==", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 169, + "Name": "b!=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 170, + "Name": "b%", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 171, + "Name": "b|", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-or B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 172, + "Name": "b\u0026", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-and B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 173, + "Name": "b^", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-xor B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 174, + "Name": "b~", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "4", + "Doc": "A with all bits inverted", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 175, + "Name": "bzero", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "zero filled byte-array of length A", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + } + ] +} diff --git a/data/transactions/logic/langspec_v5.json b/data/transactions/logic/langspec_v5.json new file mode 100644 index 0000000000..9c336c7d86 --- /dev/null +++ b/data/transactions/logic/langspec_v5.json @@ -0,0 +1,3590 @@ +{ + "Version": 5, + "LogicSigVersion": 9, + "NamedTypes": [ + { + "Name": "uint64", + "Abbreviation": "i", + "Bound": [ + 0, + 18446744073709551615 + ], + "AVMType": "uint64" + }, + { + "Name": "stateKey", + "Abbreviation": "K", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "none", + "Abbreviation": "x", + "Bound": [ + 0, + 0 + ], + "AVMType": "none" + }, + { + "Name": "method", + "Abbreviation": "M", + "Bound": [ + 4, + 4 + ], + "AVMType": "[]byte" + }, + { + "Name": "boxName", + "Abbreviation": "N", + "Bound": [ + 1, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "bool", + "Abbreviation": "T", + "Bound": [ + 0, + 1 + ], + "AVMType": "uint64" + }, + { + "Name": "bigint", + "Abbreviation": "I", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "any", + "Abbreviation": "a", + "Bound": [ + 0, + 0 + ], + "AVMType": "any" + }, + { + "Name": "address", + "Abbreviation": "A", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + }, + { + "Name": "[]byte", + "Abbreviation": "b", + "Bound": [ + 0, + 4096 + ], + "AVMType": "[]byte" + }, + { + "Name": "[32]byte", + "Abbreviation": "H", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + } + ], + "Ops": [ + { + "Opcode": 0, + "Name": "err", + "Size": 1, + "DocCost": "1", + "Doc": "Fail immediately.", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 1, + "Name": "sha256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "35", + "Doc": "SHA256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 2, + "Name": "keccak256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "Keccak256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 3, + "Name": "sha512_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "45", + "Doc": "SHA512_256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 4, + "Name": "ed25519verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {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.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 5, + "Name": "ecdsa_verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1" + ], + "DocCost": "Secp256k1=1700", + "Doc": "for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey =\u003e {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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 6, + "Name": "ecdsa_pk_decompress", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1" + ], + "DocCost": "Secp256k1=650", + "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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 7, + "Name": "ecdsa_pk_recover", + "Args": [ + "[]byte", + "uint64", + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1" + ], + "DocCost": "2000", + "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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 8, + "Name": "+", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 9, + "Name": "-", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A minus B. Fail if B \u003e A.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 10, + "Name": "/", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 11, + "Name": "*", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 12, + "Name": "\u003c", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 13, + "Name": "\u003e", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 14, + "Name": "\u003c=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 15, + "Name": "\u003e=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 16, + "Name": "\u0026\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero and B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 17, + "Name": "||", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero or B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 18, + "Name": "==", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 19, + "Name": "!=", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 20, + "Name": "!", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A == 0 yields 1; else 0", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 21, + "Name": "len", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "yields length of byte value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 22, + "Name": "itob", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts uint64 A to big-endian byte array, always of length 8", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 23, + "Name": "btoi", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts big-endian byte array A to uint64. Fails if len(A) \u003e 8. Padded by leading 0s if len(A) \u003c 8.", + "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 24, + "Name": "%", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A modulo B. Fail if B == 0.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 25, + "Name": "|", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-or B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 26, + "Name": "\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-and B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 27, + "Name": "^", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-xor B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 28, + "Name": "~", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "bitwise invert value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 29, + "Name": "mulw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 30, + "Name": "addw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 31, + "Name": "divmodw", + "Args": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "20", + "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.", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 32, + "Name": "intcblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of int constant values", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 33, + "Name": "intc", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from intcblock", + "ImmediateNote": [ + { + "Comment": "an index in the intcblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 34, + "Name": "intc_0", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 35, + "Name": "intc_1", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 36, + "Name": "intc_2", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 37, + "Name": "intc_3", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 38, + "Name": "bytecblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of byte constant values", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 39, + "Name": "bytec", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from bytecblock", + "ImmediateNote": [ + { + "Comment": "an index in the bytecblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 40, + "Name": "bytec_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 41, + "Name": "bytec_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 42, + "Name": "bytec_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 43, + "Name": "bytec_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 44, + "Name": "arg", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth LogicSig argument", + "ImmediateNote": [ + { + "Comment": "an arg index", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 45, + "Name": "arg_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 0", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 46, + "Name": "arg_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 1", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 47, + "Name": "arg_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 2", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 48, + "Name": "arg_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 3", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 49, + "Name": "txn", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 50, + "Name": "global", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "MinTxnFee", + "MinBalance", + "MaxTxnLife", + "ZeroAddress", + "GroupSize", + "LogicSigVersion", + "Round", + "LatestTimestamp", + "CurrentApplicationID", + "CreatorAddress", + "CurrentApplicationAddress", + "GroupID" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "uint64", + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address", + "address", + "[32]byte" + ], + "DocCost": "1", + "Doc": "global field F", + "ImmediateNote": [ + { + "Comment": "a global field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "global" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 51, + "Name": "gtxn", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 52, + "Name": "load", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 53, + "Name": "store", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "store A to the Ith scratch space", + "ImmediateNote": [ + { + "Comment": "position in scratch space to store to", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 54, + "Name": "txna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 55, + "Name": "gtxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "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" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 56, + "Name": "gtxns", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 57, + "Name": "gtxnsa", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 58, + "Name": "gload", + "Returns": [ + "any" + ], + "Size": 3, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 59, + "Name": "gloads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 60, + "Name": "gaid", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 61, + "Name": "gaids", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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 \u003c GroupIndex.", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 62, + "Name": "loads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Ath scratch space value. All scratch spaces are 0 at program start.", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 63, + "Name": "stores", + "Args": [ + "uint64", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "store B to the Ath scratch space", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 64, + "Name": "bnz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 65, + "Name": "bz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 66, + "Name": "b", + "Size": 3, + "DocCost": "1", + "Doc": "branch unconditionally to TARGET", + "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", + "ImmediateNote": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 67, + "Name": "return", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "use A as success value; end", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 68, + "Name": "assert", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "immediately fail unless A is a non-zero number", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 72, + "Name": "pop", + "Args": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "discard A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 73, + "Name": "dup", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 74, + "Name": "dup2", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any", + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A and B", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 75, + "Name": "dig", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth value from the top of the stack. dig 0 is equivalent to dup", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 76, + "Name": "swap", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "swaps A and B on stack", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 77, + "Name": "select", + "Args": [ + "any", + "any", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "selects one of two values based on top-of-stack: B if C != 0, else A", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 78, + "Name": "cover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth \u003c= N.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 79, + "Name": "uncover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c= N.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 80, + "Name": "concat", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "join A and B", + "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 81, + "Name": "substring", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "Doc": "A range of bytes from A starting at S up to but not including E. If E \u003c S, or either is larger than the array length, the program fails", + "ImmediateNote": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "end position", + "Encoding": "uint8", + "Name": "E" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 82, + "Name": "substring3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A range of bytes from A starting at B up to but not including C. If C \u003c B, or either is larger than the array length, the program fails", + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 83, + "Name": "getbit", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 84, + "Name": "setbit", + "Args": [ + "any", + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 85, + "Name": "getbyte", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 86, + "Name": "setbyte", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 87, + "Name": "extract", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "length", + "Encoding": "uint8", + "Name": "L" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 88, + "Name": "extract3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 89, + "Name": "extract_uint16", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 90, + "Name": "extract_uint32", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 91, + "Name": "extract_uint64", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 96, + "Name": "balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 97, + "Name": "app_opted_in", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 98, + "Name": "app_local_get", + "Args": [ + "any", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 99, + "Name": "app_local_get_ex", + "Args": [ + "any", + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 100, + "Name": "app_global_get", + "Args": [ + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 101, + "Name": "app_global_get_ex", + "Args": [ + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 102, + "Name": "app_local_put", + "Args": [ + "any", + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 103, + "Name": "app_global_put", + "Args": [ + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "write B to key A in the global state of the current application", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 104, + "Name": "app_local_del", + "Args": [ + "any", + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 105, + "Name": "app_global_del", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 112, + "Name": "asset_holding_get", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetBalance", + "AssetFrozen" + ], + "ArgEnumTypes": [ + "uint64", + "bool" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset holding field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_holding" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 113, + "Name": "asset_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetTotal", + "AssetDecimals", + "AssetDefaultFrozen", + "AssetUnitName", + "AssetName", + "AssetURL", + "AssetMetadataHash", + "AssetManager", + "AssetReserve", + "AssetFreeze", + "AssetClawback", + "AssetCreator" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_params" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 114, + "Name": "app_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AppApprovalProgram", + "AppClearStateProgram", + "AppGlobalNumUint", + "AppGlobalNumByteSlice", + "AppLocalNumUint", + "AppLocalNumByteSlice", + "AppExtraProgramPages", + "AppCreator", + "AppAddress" + ], + "ArgEnumTypes": [ + "[]byte", + "[]byte", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "app params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "app_params" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 120, + "Name": "min_balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 128, + "Name": "pushbytes", + "Returns": [ + "[]byte" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate BYTES", + "DocExtra": "pushbytes args are not added to the bytecblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "a byte constant", + "Encoding": "varuint length, bytes", + "Name": "BYTES" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 129, + "Name": "pushint", + "Returns": [ + "uint64" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate UINT", + "DocExtra": "pushint args are not added to the intcblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "an int constant", + "Encoding": "varuint", + "Name": "UINT" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 136, + "Name": "callsub", + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 137, + "Name": "retsub", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 144, + "Name": "shl", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times 2^B, modulo 2^64", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 145, + "Name": "shr", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A divided by 2^B", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 146, + "Name": "sqrt", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "4", + "Doc": "The largest integer I such that I^2 \u003c= A", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 147, + "Name": "bitlen", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 148, + "Name": "exp", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A raised to the Bth power. Fail if A == B == 0 and on overflow", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 149, + "Name": "expw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "10", + "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 160, + "Name": "b+", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A plus B. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 161, + "Name": "b-", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 162, + "Name": "b/", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 163, + "Name": "b*", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A times B. A and B are interpreted as big-endian unsigned integers.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 164, + "Name": "b\u003c", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 165, + "Name": "b\u003e", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 166, + "Name": "b\u003c=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 167, + "Name": "b\u003e=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 168, + "Name": "b==", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 169, + "Name": "b!=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 170, + "Name": "b%", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 171, + "Name": "b|", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-or B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 172, + "Name": "b\u0026", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-and B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 173, + "Name": "b^", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-xor B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 174, + "Name": "b~", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "4", + "Doc": "A with all bits inverted", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 175, + "Name": "bzero", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "zero filled byte-array of length A", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 176, + "Name": "log", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 177, + "Name": "itxn_begin", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 178, + "Name": "itxn_field", + "Args": [ + "any" + ], + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "[]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "uint64", + "[]byte", + "address", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 179, + "Name": "itxn_submit", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 180, + "Name": "itxn", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 181, + "Name": "itxna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "a transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 192, + "Name": "txnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ath value of the array field F of the current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 193, + "Name": "gtxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ath value of the array field F from the Tth transaction in the current group", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 194, + "Name": "gtxnsas", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Bth value of the array field F from the Ath transaction in the current group", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 195, + "Name": "args", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Ath LogicSig argument", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + } + ] +} diff --git a/data/transactions/logic/langspec_v6.json b/data/transactions/logic/langspec_v6.json new file mode 100644 index 0000000000..613d389191 --- /dev/null +++ b/data/transactions/logic/langspec_v6.json @@ -0,0 +1,3975 @@ +{ + "Version": 6, + "LogicSigVersion": 9, + "NamedTypes": [ + { + "Name": "uint64", + "Abbreviation": "i", + "Bound": [ + 0, + 18446744073709551615 + ], + "AVMType": "uint64" + }, + { + "Name": "stateKey", + "Abbreviation": "K", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "none", + "Abbreviation": "x", + "Bound": [ + 0, + 0 + ], + "AVMType": "none" + }, + { + "Name": "method", + "Abbreviation": "M", + "Bound": [ + 4, + 4 + ], + "AVMType": "[]byte" + }, + { + "Name": "boxName", + "Abbreviation": "N", + "Bound": [ + 1, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "bool", + "Abbreviation": "T", + "Bound": [ + 0, + 1 + ], + "AVMType": "uint64" + }, + { + "Name": "bigint", + "Abbreviation": "I", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "any", + "Abbreviation": "a", + "Bound": [ + 0, + 0 + ], + "AVMType": "any" + }, + { + "Name": "address", + "Abbreviation": "A", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + }, + { + "Name": "[]byte", + "Abbreviation": "b", + "Bound": [ + 0, + 4096 + ], + "AVMType": "[]byte" + }, + { + "Name": "[32]byte", + "Abbreviation": "H", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + } + ], + "Ops": [ + { + "Opcode": 0, + "Name": "err", + "Size": 1, + "DocCost": "1", + "Doc": "Fail immediately.", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 1, + "Name": "sha256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "35", + "Doc": "SHA256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 2, + "Name": "keccak256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "Keccak256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 3, + "Name": "sha512_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "45", + "Doc": "SHA512_256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 4, + "Name": "ed25519verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {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.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 5, + "Name": "ecdsa_verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1" + ], + "DocCost": "Secp256k1=1700", + "Doc": "for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey =\u003e {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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 6, + "Name": "ecdsa_pk_decompress", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1" + ], + "DocCost": "Secp256k1=650", + "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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 7, + "Name": "ecdsa_pk_recover", + "Args": [ + "[]byte", + "uint64", + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1" + ], + "DocCost": "2000", + "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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 8, + "Name": "+", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 9, + "Name": "-", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A minus B. Fail if B \u003e A.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 10, + "Name": "/", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 11, + "Name": "*", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 12, + "Name": "\u003c", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 13, + "Name": "\u003e", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 14, + "Name": "\u003c=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 15, + "Name": "\u003e=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 16, + "Name": "\u0026\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero and B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 17, + "Name": "||", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero or B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 18, + "Name": "==", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 19, + "Name": "!=", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 20, + "Name": "!", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A == 0 yields 1; else 0", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 21, + "Name": "len", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "yields length of byte value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 22, + "Name": "itob", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts uint64 A to big-endian byte array, always of length 8", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 23, + "Name": "btoi", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts big-endian byte array A to uint64. Fails if len(A) \u003e 8. Padded by leading 0s if len(A) \u003c 8.", + "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 24, + "Name": "%", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A modulo B. Fail if B == 0.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 25, + "Name": "|", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-or B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 26, + "Name": "\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-and B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 27, + "Name": "^", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-xor B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 28, + "Name": "~", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "bitwise invert value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 29, + "Name": "mulw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 30, + "Name": "addw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 31, + "Name": "divmodw", + "Args": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "20", + "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.", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 32, + "Name": "intcblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of int constant values", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 33, + "Name": "intc", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from intcblock", + "ImmediateNote": [ + { + "Comment": "an index in the intcblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 34, + "Name": "intc_0", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 35, + "Name": "intc_1", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 36, + "Name": "intc_2", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 37, + "Name": "intc_3", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 38, + "Name": "bytecblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of byte constant values", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 39, + "Name": "bytec", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from bytecblock", + "ImmediateNote": [ + { + "Comment": "an index in the bytecblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 40, + "Name": "bytec_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 41, + "Name": "bytec_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 42, + "Name": "bytec_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 43, + "Name": "bytec_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 44, + "Name": "arg", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth LogicSig argument", + "ImmediateNote": [ + { + "Comment": "an arg index", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 45, + "Name": "arg_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 0", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 46, + "Name": "arg_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 1", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 47, + "Name": "arg_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 2", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 48, + "Name": "arg_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 3", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 49, + "Name": "txn", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "field F of current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 50, + "Name": "global", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "MinTxnFee", + "MinBalance", + "MaxTxnLife", + "ZeroAddress", + "GroupSize", + "LogicSigVersion", + "Round", + "LatestTimestamp", + "CurrentApplicationID", + "CreatorAddress", + "CurrentApplicationAddress", + "GroupID", + "OpcodeBudget", + "CallerApplicationID", + "CallerApplicationAddress" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "uint64", + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address", + "address", + "[32]byte", + "uint64", + "uint64", + "address" + ], + "DocCost": "1", + "Doc": "global field F", + "ImmediateNote": [ + { + "Comment": "a global field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "global" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 51, + "Name": "gtxn", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 52, + "Name": "load", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 53, + "Name": "store", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "store A to the Ith scratch space", + "ImmediateNote": [ + { + "Comment": "position in scratch space to store to", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 54, + "Name": "txna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 55, + "Name": "gtxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "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" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 56, + "Name": "gtxns", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 57, + "Name": "gtxnsa", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 58, + "Name": "gload", + "Returns": [ + "any" + ], + "Size": 3, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 59, + "Name": "gloads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 60, + "Name": "gaid", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 61, + "Name": "gaids", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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 \u003c GroupIndex.", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 62, + "Name": "loads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Ath scratch space value. All scratch spaces are 0 at program start.", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 63, + "Name": "stores", + "Args": [ + "uint64", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "store B to the Ath scratch space", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 64, + "Name": "bnz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 65, + "Name": "bz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 66, + "Name": "b", + "Size": 3, + "DocCost": "1", + "Doc": "branch unconditionally to TARGET", + "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", + "ImmediateNote": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 67, + "Name": "return", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "use A as success value; end", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 68, + "Name": "assert", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "immediately fail unless A is a non-zero number", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 72, + "Name": "pop", + "Args": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "discard A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 73, + "Name": "dup", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 74, + "Name": "dup2", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any", + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A and B", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 75, + "Name": "dig", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth value from the top of the stack. dig 0 is equivalent to dup", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 76, + "Name": "swap", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "swaps A and B on stack", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 77, + "Name": "select", + "Args": [ + "any", + "any", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "selects one of two values based on top-of-stack: B if C != 0, else A", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 78, + "Name": "cover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth \u003c= N.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 79, + "Name": "uncover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c= N.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 80, + "Name": "concat", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "join A and B", + "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 81, + "Name": "substring", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "Doc": "A range of bytes from A starting at S up to but not including E. If E \u003c S, or either is larger than the array length, the program fails", + "ImmediateNote": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "end position", + "Encoding": "uint8", + "Name": "E" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 82, + "Name": "substring3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A range of bytes from A starting at B up to but not including C. If C \u003c B, or either is larger than the array length, the program fails", + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 83, + "Name": "getbit", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 84, + "Name": "setbit", + "Args": [ + "any", + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 85, + "Name": "getbyte", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 86, + "Name": "setbyte", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 87, + "Name": "extract", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "length", + "Encoding": "uint8", + "Name": "L" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 88, + "Name": "extract3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 89, + "Name": "extract_uint16", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 90, + "Name": "extract_uint32", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 91, + "Name": "extract_uint64", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 96, + "Name": "balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 97, + "Name": "app_opted_in", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 98, + "Name": "app_local_get", + "Args": [ + "any", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 99, + "Name": "app_local_get_ex", + "Args": [ + "any", + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 100, + "Name": "app_global_get", + "Args": [ + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 101, + "Name": "app_global_get_ex", + "Args": [ + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 102, + "Name": "app_local_put", + "Args": [ + "any", + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 103, + "Name": "app_global_put", + "Args": [ + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "write B to key A in the global state of the current application", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 104, + "Name": "app_local_del", + "Args": [ + "any", + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 105, + "Name": "app_global_del", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 112, + "Name": "asset_holding_get", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetBalance", + "AssetFrozen" + ], + "ArgEnumTypes": [ + "uint64", + "bool" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset holding field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_holding" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 113, + "Name": "asset_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetTotal", + "AssetDecimals", + "AssetDefaultFrozen", + "AssetUnitName", + "AssetName", + "AssetURL", + "AssetMetadataHash", + "AssetManager", + "AssetReserve", + "AssetFreeze", + "AssetClawback", + "AssetCreator" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_params" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 114, + "Name": "app_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AppApprovalProgram", + "AppClearStateProgram", + "AppGlobalNumUint", + "AppGlobalNumByteSlice", + "AppLocalNumUint", + "AppLocalNumByteSlice", + "AppExtraProgramPages", + "AppCreator", + "AppAddress" + ], + "ArgEnumTypes": [ + "[]byte", + "[]byte", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "app params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "app_params" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 115, + "Name": "acct_params_get", + "Args": [ + "any" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AcctBalance", + "AcctMinBalance", + "AcctAuthAddr" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "address" + ], + "DocCost": "1", + "Doc": "X is field F from account A. Y is 1 if A owns positive algos, else 0", + "ImmediateNote": [ + { + "Comment": "account params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "acct_params" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 120, + "Name": "min_balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 128, + "Name": "pushbytes", + "Returns": [ + "[]byte" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate BYTES", + "DocExtra": "pushbytes args are not added to the bytecblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "a byte constant", + "Encoding": "varuint length, bytes", + "Name": "BYTES" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 129, + "Name": "pushint", + "Returns": [ + "uint64" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate UINT", + "DocExtra": "pushint args are not added to the intcblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "an int constant", + "Encoding": "varuint", + "Name": "UINT" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 136, + "Name": "callsub", + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 137, + "Name": "retsub", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 144, + "Name": "shl", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times 2^B, modulo 2^64", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 145, + "Name": "shr", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A divided by 2^B", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 146, + "Name": "sqrt", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "4", + "Doc": "The largest integer I such that I^2 \u003c= A", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 147, + "Name": "bitlen", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 148, + "Name": "exp", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A raised to the Bth power. Fail if A == B == 0 and on overflow", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 149, + "Name": "expw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "10", + "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 150, + "Name": "bsqrt", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "40", + "Doc": "The largest integer I such that I^2 \u003c= A. A and I are interpreted as big-endian unsigned integers", + "IntroducedVersion": 6, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 151, + "Name": "divw", + "Args": [ + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 6, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 160, + "Name": "b+", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A plus B. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 161, + "Name": "b-", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 162, + "Name": "b/", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 163, + "Name": "b*", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A times B. A and B are interpreted as big-endian unsigned integers.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 164, + "Name": "b\u003c", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 165, + "Name": "b\u003e", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 166, + "Name": "b\u003c=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 167, + "Name": "b\u003e=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 168, + "Name": "b==", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 169, + "Name": "b!=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 170, + "Name": "b%", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 171, + "Name": "b|", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-or B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 172, + "Name": "b\u0026", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-and B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 173, + "Name": "b^", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-xor B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 174, + "Name": "b~", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "4", + "Doc": "A with all bits inverted", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 175, + "Name": "bzero", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "zero filled byte-array of length A", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 176, + "Name": "log", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 177, + "Name": "itxn_begin", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 178, + "Name": "itxn_field", + "Args": [ + "any" + ], + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "[]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "uint64", + "[]byte", + "address", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 179, + "Name": "itxn_submit", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 180, + "Name": "itxn", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 181, + "Name": "itxna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "a transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 182, + "Name": "itxn_next", + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 183, + "Name": "gitxn", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "Sender", + "Fee", + "FirstValid", + "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" + ], + "ArgEnumTypes": [ + "address", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "field F of the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 184, + "Name": "gitxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F from the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "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" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 192, + "Name": "txnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ath value of the array field F of the current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 193, + "Name": "gtxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ath value of the array field F from the Tth transaction in the current group", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 194, + "Name": "gtxnsas", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte" + ], + "DocCost": "1", + "Doc": "Bth value of the array field F from the Ath transaction in the current group", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 195, + "Name": "args", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Ath LogicSig argument", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 196, + "Name": "gloadss", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth scratch space value of the Ath transaction in the current group", + "IntroducedVersion": 6, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 197, + "Name": "itxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ath value of the array field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 198, + "Name": "gitxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "DocCost": "1", + "Doc": "Ath value of the array field F from the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + } + ] +} diff --git a/data/transactions/logic/langspec_v7.json b/data/transactions/logic/langspec_v7.json new file mode 100644 index 0000000000..cb3664eb3a --- /dev/null +++ b/data/transactions/logic/langspec_v7.json @@ -0,0 +1,4280 @@ +{ + "Version": 7, + "LogicSigVersion": 9, + "NamedTypes": [ + { + "Name": "uint64", + "Abbreviation": "i", + "Bound": [ + 0, + 18446744073709551615 + ], + "AVMType": "uint64" + }, + { + "Name": "stateKey", + "Abbreviation": "K", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "none", + "Abbreviation": "x", + "Bound": [ + 0, + 0 + ], + "AVMType": "none" + }, + { + "Name": "method", + "Abbreviation": "M", + "Bound": [ + 4, + 4 + ], + "AVMType": "[]byte" + }, + { + "Name": "boxName", + "Abbreviation": "N", + "Bound": [ + 1, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "bool", + "Abbreviation": "T", + "Bound": [ + 0, + 1 + ], + "AVMType": "uint64" + }, + { + "Name": "bigint", + "Abbreviation": "I", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "any", + "Abbreviation": "a", + "Bound": [ + 0, + 0 + ], + "AVMType": "any" + }, + { + "Name": "address", + "Abbreviation": "A", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + }, + { + "Name": "[]byte", + "Abbreviation": "b", + "Bound": [ + 0, + 4096 + ], + "AVMType": "[]byte" + }, + { + "Name": "[32]byte", + "Abbreviation": "H", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + } + ], + "Ops": [ + { + "Opcode": 0, + "Name": "err", + "Size": 1, + "DocCost": "1", + "Doc": "Fail immediately.", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 1, + "Name": "sha256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "35", + "Doc": "SHA256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 2, + "Name": "keccak256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "Keccak256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 3, + "Name": "sha512_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "45", + "Doc": "SHA512_256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 4, + "Name": "ed25519verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {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.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 5, + "Name": "ecdsa_verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1", + "Secp256r1" + ], + "DocCost": "Secp256k1=1700; Secp256r1=2500", + "Doc": "for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey =\u003e {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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 6, + "Name": "ecdsa_pk_decompress", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1", + "Secp256r1" + ], + "DocCost": "Secp256k1=650; Secp256r1=2400", + "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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 7, + "Name": "ecdsa_pk_recover", + "Args": [ + "[]byte", + "uint64", + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1", + "Secp256r1" + ], + "DocCost": "2000", + "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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 8, + "Name": "+", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 9, + "Name": "-", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A minus B. Fail if B \u003e A.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 10, + "Name": "/", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 11, + "Name": "*", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 12, + "Name": "\u003c", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 13, + "Name": "\u003e", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 14, + "Name": "\u003c=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 15, + "Name": "\u003e=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 16, + "Name": "\u0026\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero and B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 17, + "Name": "||", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero or B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 18, + "Name": "==", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 19, + "Name": "!=", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 20, + "Name": "!", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A == 0 yields 1; else 0", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 21, + "Name": "len", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "yields length of byte value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 22, + "Name": "itob", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts uint64 A to big-endian byte array, always of length 8", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 23, + "Name": "btoi", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts big-endian byte array A to uint64. Fails if len(A) \u003e 8. Padded by leading 0s if len(A) \u003c 8.", + "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 24, + "Name": "%", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A modulo B. Fail if B == 0.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 25, + "Name": "|", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-or B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 26, + "Name": "\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-and B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 27, + "Name": "^", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-xor B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 28, + "Name": "~", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "bitwise invert value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 29, + "Name": "mulw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 30, + "Name": "addw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 31, + "Name": "divmodw", + "Args": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "20", + "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.", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 32, + "Name": "intcblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of int constant values", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 33, + "Name": "intc", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from intcblock", + "ImmediateNote": [ + { + "Comment": "an index in the intcblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 34, + "Name": "intc_0", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 35, + "Name": "intc_1", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 36, + "Name": "intc_2", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 37, + "Name": "intc_3", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 38, + "Name": "bytecblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of byte constant values", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 39, + "Name": "bytec", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from bytecblock", + "ImmediateNote": [ + { + "Comment": "an index in the bytecblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 40, + "Name": "bytec_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 41, + "Name": "bytec_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 42, + "Name": "bytec_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 43, + "Name": "bytec_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 44, + "Name": "arg", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth LogicSig argument", + "ImmediateNote": [ + { + "Comment": "an arg index", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 45, + "Name": "arg_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 0", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 46, + "Name": "arg_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 1", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 47, + "Name": "arg_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 2", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 48, + "Name": "arg_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 3", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 49, + "Name": "txn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 50, + "Name": "global", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "MinTxnFee", + "MinBalance", + "MaxTxnLife", + "ZeroAddress", + "GroupSize", + "LogicSigVersion", + "Round", + "LatestTimestamp", + "CurrentApplicationID", + "CreatorAddress", + "CurrentApplicationAddress", + "GroupID", + "OpcodeBudget", + "CallerApplicationID", + "CallerApplicationAddress" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "uint64", + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address", + "address", + "[32]byte", + "uint64", + "uint64", + "address" + ], + "DocCost": "1", + "Doc": "global field F", + "ImmediateNote": [ + { + "Comment": "a global field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "global" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 51, + "Name": "gtxn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 52, + "Name": "load", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 53, + "Name": "store", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "store A to the Ith scratch space", + "ImmediateNote": [ + { + "Comment": "position in scratch space to store to", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 54, + "Name": "txna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 55, + "Name": "gtxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "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" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 56, + "Name": "gtxns", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 57, + "Name": "gtxnsa", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 58, + "Name": "gload", + "Returns": [ + "any" + ], + "Size": 3, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 59, + "Name": "gloads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 60, + "Name": "gaid", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 61, + "Name": "gaids", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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 \u003c GroupIndex.", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 62, + "Name": "loads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Ath scratch space value. All scratch spaces are 0 at program start.", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 63, + "Name": "stores", + "Args": [ + "uint64", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "store B to the Ath scratch space", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 64, + "Name": "bnz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 65, + "Name": "bz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 66, + "Name": "b", + "Size": 3, + "DocCost": "1", + "Doc": "branch unconditionally to TARGET", + "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", + "ImmediateNote": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 67, + "Name": "return", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "use A as success value; end", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 68, + "Name": "assert", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "immediately fail unless A is a non-zero number", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 72, + "Name": "pop", + "Args": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "discard A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 73, + "Name": "dup", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 74, + "Name": "dup2", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any", + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A and B", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 75, + "Name": "dig", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth value from the top of the stack. dig 0 is equivalent to dup", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 76, + "Name": "swap", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "swaps A and B on stack", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 77, + "Name": "select", + "Args": [ + "any", + "any", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "selects one of two values based on top-of-stack: B if C != 0, else A", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 78, + "Name": "cover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth \u003c= N.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 79, + "Name": "uncover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c= N.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 80, + "Name": "concat", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "join A and B", + "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 81, + "Name": "substring", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "Doc": "A range of bytes from A starting at S up to but not including E. If E \u003c S, or either is larger than the array length, the program fails", + "ImmediateNote": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "end position", + "Encoding": "uint8", + "Name": "E" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 82, + "Name": "substring3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A range of bytes from A starting at B up to but not including C. If C \u003c B, or either is larger than the array length, the program fails", + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 83, + "Name": "getbit", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 84, + "Name": "setbit", + "Args": [ + "any", + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 85, + "Name": "getbyte", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 86, + "Name": "setbyte", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 87, + "Name": "extract", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "length", + "Encoding": "uint8", + "Name": "L" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 88, + "Name": "extract3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 89, + "Name": "extract_uint16", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 90, + "Name": "extract_uint32", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 91, + "Name": "extract_uint64", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 92, + "Name": "replace2", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "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": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 93, + "Name": "replace3", + "Args": [ + "[]byte", + "uint64", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 94, + "Name": "base64_decode", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "URLEncoding", + "StdEncoding" + ], + "ArgEnumTypes": [ + "any", + "any" + ], + "DocCost": "1 + 1 per 16 bytes of A", + "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": [ + { + "Comment": "encoding index", + "Encoding": "uint8", + "Name": "E", + "Reference": "base64" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 95, + "Name": "json_ref", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "JSONString", + "JSONUint64", + "JSONObject" + ], + "ArgEnumTypes": [ + "[]byte", + "uint64", + "[]byte" + ], + "DocCost": "25 + 2 per 7 bytes of A", + "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": [ + { + "Comment": "return type index", + "Encoding": "uint8", + "Name": "R", + "Reference": "json_ref" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 96, + "Name": "balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 97, + "Name": "app_opted_in", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 98, + "Name": "app_local_get", + "Args": [ + "any", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 99, + "Name": "app_local_get_ex", + "Args": [ + "any", + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 100, + "Name": "app_global_get", + "Args": [ + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 101, + "Name": "app_global_get_ex", + "Args": [ + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 102, + "Name": "app_local_put", + "Args": [ + "any", + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 103, + "Name": "app_global_put", + "Args": [ + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "write B to key A in the global state of the current application", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 104, + "Name": "app_local_del", + "Args": [ + "any", + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 105, + "Name": "app_global_del", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 112, + "Name": "asset_holding_get", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetBalance", + "AssetFrozen" + ], + "ArgEnumTypes": [ + "uint64", + "bool" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset holding field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_holding" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 113, + "Name": "asset_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetTotal", + "AssetDecimals", + "AssetDefaultFrozen", + "AssetUnitName", + "AssetName", + "AssetURL", + "AssetMetadataHash", + "AssetManager", + "AssetReserve", + "AssetFreeze", + "AssetClawback", + "AssetCreator" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_params" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 114, + "Name": "app_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AppApprovalProgram", + "AppClearStateProgram", + "AppGlobalNumUint", + "AppGlobalNumByteSlice", + "AppLocalNumUint", + "AppLocalNumByteSlice", + "AppExtraProgramPages", + "AppCreator", + "AppAddress" + ], + "ArgEnumTypes": [ + "[]byte", + "[]byte", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "app params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "app_params" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 115, + "Name": "acct_params_get", + "Args": [ + "any" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AcctBalance", + "AcctMinBalance", + "AcctAuthAddr" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "address" + ], + "DocCost": "1", + "Doc": "X is field F from account A. Y is 1 if A owns positive algos, else 0", + "ImmediateNote": [ + { + "Comment": "account params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "acct_params" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 120, + "Name": "min_balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 128, + "Name": "pushbytes", + "Returns": [ + "[]byte" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate BYTES", + "DocExtra": "pushbytes args are not added to the bytecblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "a byte constant", + "Encoding": "varuint length, bytes", + "Name": "BYTES" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 129, + "Name": "pushint", + "Returns": [ + "uint64" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate UINT", + "DocExtra": "pushint args are not added to the intcblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "an int constant", + "Encoding": "varuint", + "Name": "UINT" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 132, + "Name": "ed25519verify_bare", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of the data against the pubkey =\u003e {0 or 1}", + "IntroducedVersion": 7, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 136, + "Name": "callsub", + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 137, + "Name": "retsub", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 144, + "Name": "shl", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times 2^B, modulo 2^64", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 145, + "Name": "shr", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A divided by 2^B", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 146, + "Name": "sqrt", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "4", + "Doc": "The largest integer I such that I^2 \u003c= A", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 147, + "Name": "bitlen", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 148, + "Name": "exp", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A raised to the Bth power. Fail if A == B == 0 and on overflow", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 149, + "Name": "expw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "10", + "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 150, + "Name": "bsqrt", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "40", + "Doc": "The largest integer I such that I^2 \u003c= A. A and I are interpreted as big-endian unsigned integers", + "IntroducedVersion": 6, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 151, + "Name": "divw", + "Args": [ + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 6, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 152, + "Name": "sha3_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "SHA3_256 hash of value A, yields [32]byte", + "IntroducedVersion": 7, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 160, + "Name": "b+", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A plus B. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 161, + "Name": "b-", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 162, + "Name": "b/", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 163, + "Name": "b*", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A times B. A and B are interpreted as big-endian unsigned integers.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 164, + "Name": "b\u003c", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 165, + "Name": "b\u003e", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 166, + "Name": "b\u003c=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 167, + "Name": "b\u003e=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 168, + "Name": "b==", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 169, + "Name": "b!=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 170, + "Name": "b%", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 171, + "Name": "b|", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-or B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 172, + "Name": "b\u0026", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-and B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 173, + "Name": "b^", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-xor B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 174, + "Name": "b~", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "4", + "Doc": "A with all bits inverted", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 175, + "Name": "bzero", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "zero filled byte-array of length A", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 176, + "Name": "log", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 177, + "Name": "itxn_begin", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 178, + "Name": "itxn_field", + "Args": [ + "any" + ], + "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": [ + "address", + "uint64", + "[]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "uint64", + "[]byte", + "address", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 179, + "Name": "itxn_submit", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 180, + "Name": "itxn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 181, + "Name": "itxna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "a transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 182, + "Name": "itxn_next", + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 183, + "Name": "gitxn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 184, + "Name": "gitxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F from the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "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" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 192, + "Name": "txnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ath value of the array field F of the current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 193, + "Name": "gtxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ath value of the array field F from the Tth transaction in the current group", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 194, + "Name": "gtxnsas", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Bth value of the array field F from the Ath transaction in the current group", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 195, + "Name": "args", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Ath LogicSig argument", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 196, + "Name": "gloadss", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth scratch space value of the Ath transaction in the current group", + "IntroducedVersion": 6, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 197, + "Name": "itxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ath value of the array field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 198, + "Name": "gitxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "DocCost": "1", + "Doc": "Ath value of the array field F from the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 208, + "Name": "vrf_verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "VrfAlgorand" + ], + "DocCost": "5700", + "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": [ + { + "Comment": " parameters index", + "Encoding": "uint8", + "Name": "S", + "Reference": "vrf_verify" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 209, + "Name": "block", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "BlkSeed", + "BlkTimestamp" + ], + "ArgEnumTypes": [ + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)", + "ImmediateNote": [ + { + "Comment": " block field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "block" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "State Access" + ] + } + ] +} diff --git a/data/transactions/logic/langspec_v8.json b/data/transactions/logic/langspec_v8.json new file mode 100644 index 0000000000..1cce84389a --- /dev/null +++ b/data/transactions/logic/langspec_v8.json @@ -0,0 +1,4626 @@ +{ + "Version": 8, + "LogicSigVersion": 9, + "NamedTypes": [ + { + "Name": "uint64", + "Abbreviation": "i", + "Bound": [ + 0, + 18446744073709551615 + ], + "AVMType": "uint64" + }, + { + "Name": "stateKey", + "Abbreviation": "K", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "none", + "Abbreviation": "x", + "Bound": [ + 0, + 0 + ], + "AVMType": "none" + }, + { + "Name": "method", + "Abbreviation": "M", + "Bound": [ + 4, + 4 + ], + "AVMType": "[]byte" + }, + { + "Name": "boxName", + "Abbreviation": "N", + "Bound": [ + 1, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "bool", + "Abbreviation": "T", + "Bound": [ + 0, + 1 + ], + "AVMType": "uint64" + }, + { + "Name": "bigint", + "Abbreviation": "I", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "any", + "Abbreviation": "a", + "Bound": [ + 0, + 0 + ], + "AVMType": "any" + }, + { + "Name": "address", + "Abbreviation": "A", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + }, + { + "Name": "[]byte", + "Abbreviation": "b", + "Bound": [ + 0, + 4096 + ], + "AVMType": "[]byte" + }, + { + "Name": "[32]byte", + "Abbreviation": "H", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + } + ], + "Ops": [ + { + "Opcode": 0, + "Name": "err", + "Size": 1, + "DocCost": "1", + "Doc": "Fail immediately.", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 1, + "Name": "sha256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "35", + "Doc": "SHA256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 2, + "Name": "keccak256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "Keccak256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 3, + "Name": "sha512_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "45", + "Doc": "SHA512_256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 4, + "Name": "ed25519verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {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.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 5, + "Name": "ecdsa_verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1", + "Secp256r1" + ], + "DocCost": "Secp256k1=1700; Secp256r1=2500", + "Doc": "for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey =\u003e {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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 6, + "Name": "ecdsa_pk_decompress", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1", + "Secp256r1" + ], + "DocCost": "Secp256k1=650; Secp256r1=2400", + "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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 7, + "Name": "ecdsa_pk_recover", + "Args": [ + "[]byte", + "uint64", + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1", + "Secp256r1" + ], + "DocCost": "2000", + "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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 8, + "Name": "+", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 9, + "Name": "-", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A minus B. Fail if B \u003e A.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 10, + "Name": "/", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 11, + "Name": "*", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 12, + "Name": "\u003c", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 13, + "Name": "\u003e", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 14, + "Name": "\u003c=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 15, + "Name": "\u003e=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 16, + "Name": "\u0026\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero and B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 17, + "Name": "||", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero or B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 18, + "Name": "==", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 19, + "Name": "!=", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 20, + "Name": "!", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A == 0 yields 1; else 0", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 21, + "Name": "len", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "yields length of byte value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 22, + "Name": "itob", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts uint64 A to big-endian byte array, always of length 8", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 23, + "Name": "btoi", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts big-endian byte array A to uint64. Fails if len(A) \u003e 8. Padded by leading 0s if len(A) \u003c 8.", + "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 24, + "Name": "%", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A modulo B. Fail if B == 0.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 25, + "Name": "|", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-or B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 26, + "Name": "\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-and B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 27, + "Name": "^", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-xor B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 28, + "Name": "~", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "bitwise invert value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 29, + "Name": "mulw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 30, + "Name": "addw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 31, + "Name": "divmodw", + "Args": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "20", + "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.", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 32, + "Name": "intcblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of int constant values", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 33, + "Name": "intc", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from intcblock", + "ImmediateNote": [ + { + "Comment": "an index in the intcblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 34, + "Name": "intc_0", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 35, + "Name": "intc_1", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 36, + "Name": "intc_2", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 37, + "Name": "intc_3", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 38, + "Name": "bytecblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of byte constant values", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 39, + "Name": "bytec", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from bytecblock", + "ImmediateNote": [ + { + "Comment": "an index in the bytecblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 40, + "Name": "bytec_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 41, + "Name": "bytec_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 42, + "Name": "bytec_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 43, + "Name": "bytec_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 44, + "Name": "arg", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth LogicSig argument", + "ImmediateNote": [ + { + "Comment": "an arg index", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 45, + "Name": "arg_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 0", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 46, + "Name": "arg_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 1", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 47, + "Name": "arg_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 2", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 48, + "Name": "arg_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 3", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 49, + "Name": "txn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 50, + "Name": "global", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "MinTxnFee", + "MinBalance", + "MaxTxnLife", + "ZeroAddress", + "GroupSize", + "LogicSigVersion", + "Round", + "LatestTimestamp", + "CurrentApplicationID", + "CreatorAddress", + "CurrentApplicationAddress", + "GroupID", + "OpcodeBudget", + "CallerApplicationID", + "CallerApplicationAddress" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "uint64", + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address", + "address", + "[32]byte", + "uint64", + "uint64", + "address" + ], + "DocCost": "1", + "Doc": "global field F", + "ImmediateNote": [ + { + "Comment": "a global field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "global" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 51, + "Name": "gtxn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 52, + "Name": "load", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 53, + "Name": "store", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "store A to the Ith scratch space", + "ImmediateNote": [ + { + "Comment": "position in scratch space to store to", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 54, + "Name": "txna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 55, + "Name": "gtxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "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" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 56, + "Name": "gtxns", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 57, + "Name": "gtxnsa", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 58, + "Name": "gload", + "Returns": [ + "any" + ], + "Size": 3, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 59, + "Name": "gloads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 60, + "Name": "gaid", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 61, + "Name": "gaids", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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 \u003c GroupIndex.", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 62, + "Name": "loads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Ath scratch space value. All scratch spaces are 0 at program start.", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 63, + "Name": "stores", + "Args": [ + "uint64", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "store B to the Ath scratch space", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 64, + "Name": "bnz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 65, + "Name": "bz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 66, + "Name": "b", + "Size": 3, + "DocCost": "1", + "Doc": "branch unconditionally to TARGET", + "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", + "ImmediateNote": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 67, + "Name": "return", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "use A as success value; end", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 68, + "Name": "assert", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "immediately fail unless A is a non-zero number", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 69, + "Name": "bury", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "replace the Nth value from the top of the stack with A. bury 0 fails.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 70, + "Name": "popn", + "Size": 2, + "DocCost": "1", + "Doc": "remove N values from the top of the stack", + "ImmediateNote": [ + { + "Comment": "stack depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 71, + "Name": "dupn", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "duplicate A, N times", + "ImmediateNote": [ + { + "Comment": "copy count", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 72, + "Name": "pop", + "Args": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "discard A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 73, + "Name": "dup", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 74, + "Name": "dup2", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any", + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A and B", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 75, + "Name": "dig", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth value from the top of the stack. dig 0 is equivalent to dup", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 76, + "Name": "swap", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "swaps A and B on stack", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 77, + "Name": "select", + "Args": [ + "any", + "any", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "selects one of two values based on top-of-stack: B if C != 0, else A", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 78, + "Name": "cover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth \u003c= N.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 79, + "Name": "uncover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c= N.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 80, + "Name": "concat", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "join A and B", + "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 81, + "Name": "substring", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "Doc": "A range of bytes from A starting at S up to but not including E. If E \u003c S, or either is larger than the array length, the program fails", + "ImmediateNote": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "end position", + "Encoding": "uint8", + "Name": "E" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 82, + "Name": "substring3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A range of bytes from A starting at B up to but not including C. If C \u003c B, or either is larger than the array length, the program fails", + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 83, + "Name": "getbit", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 84, + "Name": "setbit", + "Args": [ + "any", + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 85, + "Name": "getbyte", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 86, + "Name": "setbyte", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 87, + "Name": "extract", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "length", + "Encoding": "uint8", + "Name": "L" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 88, + "Name": "extract3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 89, + "Name": "extract_uint16", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 90, + "Name": "extract_uint32", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 91, + "Name": "extract_uint64", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 92, + "Name": "replace2", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "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": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 93, + "Name": "replace3", + "Args": [ + "[]byte", + "uint64", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 94, + "Name": "base64_decode", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "URLEncoding", + "StdEncoding" + ], + "ArgEnumTypes": [ + "any", + "any" + ], + "DocCost": "1 + 1 per 16 bytes of A", + "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": [ + { + "Comment": "encoding index", + "Encoding": "uint8", + "Name": "E", + "Reference": "base64" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 95, + "Name": "json_ref", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "JSONString", + "JSONUint64", + "JSONObject" + ], + "ArgEnumTypes": [ + "[]byte", + "uint64", + "[]byte" + ], + "DocCost": "25 + 2 per 7 bytes of A", + "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": [ + { + "Comment": "return type index", + "Encoding": "uint8", + "Name": "R", + "Reference": "json_ref" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 96, + "Name": "balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 97, + "Name": "app_opted_in", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 98, + "Name": "app_local_get", + "Args": [ + "any", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 99, + "Name": "app_local_get_ex", + "Args": [ + "any", + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 100, + "Name": "app_global_get", + "Args": [ + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 101, + "Name": "app_global_get_ex", + "Args": [ + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 102, + "Name": "app_local_put", + "Args": [ + "any", + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 103, + "Name": "app_global_put", + "Args": [ + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "write B to key A in the global state of the current application", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 104, + "Name": "app_local_del", + "Args": [ + "any", + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 105, + "Name": "app_global_del", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 112, + "Name": "asset_holding_get", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetBalance", + "AssetFrozen" + ], + "ArgEnumTypes": [ + "uint64", + "bool" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset holding field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_holding" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 113, + "Name": "asset_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetTotal", + "AssetDecimals", + "AssetDefaultFrozen", + "AssetUnitName", + "AssetName", + "AssetURL", + "AssetMetadataHash", + "AssetManager", + "AssetReserve", + "AssetFreeze", + "AssetClawback", + "AssetCreator" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_params" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 114, + "Name": "app_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AppApprovalProgram", + "AppClearStateProgram", + "AppGlobalNumUint", + "AppGlobalNumByteSlice", + "AppLocalNumUint", + "AppLocalNumByteSlice", + "AppExtraProgramPages", + "AppCreator", + "AppAddress" + ], + "ArgEnumTypes": [ + "[]byte", + "[]byte", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "app params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "app_params" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 115, + "Name": "acct_params_get", + "Args": [ + "any" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AcctBalance", + "AcctMinBalance", + "AcctAuthAddr", + "AcctTotalNumUint", + "AcctTotalNumByteSlice", + "AcctTotalExtraAppPages", + "AcctTotalAppsCreated", + "AcctTotalAppsOptedIn", + "AcctTotalAssetsCreated", + "AcctTotalAssets", + "AcctTotalBoxes", + "AcctTotalBoxBytes" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "Doc": "X is field F from account A. Y is 1 if A owns positive algos, else 0", + "ImmediateNote": [ + { + "Comment": "account params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "acct_params" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 120, + "Name": "min_balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 128, + "Name": "pushbytes", + "Returns": [ + "[]byte" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate BYTES", + "DocExtra": "pushbytes args are not added to the bytecblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "a byte constant", + "Encoding": "varuint length, bytes", + "Name": "BYTES" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 129, + "Name": "pushint", + "Returns": [ + "uint64" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate UINT", + "DocExtra": "pushint args are not added to the intcblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "an int constant", + "Encoding": "varuint", + "Name": "UINT" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 130, + "Name": "pushbytess", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a list of byte constants", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 131, + "Name": "pushints", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a list of int constants", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 132, + "Name": "ed25519verify_bare", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of the data against the pubkey =\u003e {0 or 1}", + "IntroducedVersion": 7, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 136, + "Name": "callsub", + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 137, + "Name": "retsub", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 138, + "Name": "proto", + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "number of arguments", + "Encoding": "uint8", + "Name": "A" + }, + { + "Comment": "number of return values", + "Encoding": "uint8", + "Name": "R" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 139, + "Name": "frame_dig", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth (signed) value from the frame pointer.", + "ImmediateNote": [ + { + "Comment": "frame slot", + "Encoding": "int8", + "Name": "I" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 140, + "Name": "frame_bury", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "replace the Nth (signed) value from the frame pointer in the stack with A", + "ImmediateNote": [ + { + "Comment": "frame slot", + "Encoding": "int8", + "Name": "I" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 141, + "Name": "switch", + "Args": [ + "uint64" + ], + "Size": 0, + "DocCost": "1", + "Doc": "branch to the Ath label. Continue at following instruction if index A exceeds the number of labels.", + "ImmediateNote": [ + { + "Comment": "list of labels", + "Encoding": "varuint count, [int16 (big-endian) ...]", + "Name": "TARGET ..." + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 142, + "Name": "match", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "list of labels", + "Encoding": "varuint count, [int16 (big-endian) ...]", + "Name": "TARGET ..." + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 144, + "Name": "shl", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times 2^B, modulo 2^64", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 145, + "Name": "shr", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A divided by 2^B", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 146, + "Name": "sqrt", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "4", + "Doc": "The largest integer I such that I^2 \u003c= A", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 147, + "Name": "bitlen", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 148, + "Name": "exp", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A raised to the Bth power. Fail if A == B == 0 and on overflow", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 149, + "Name": "expw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "10", + "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 150, + "Name": "bsqrt", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "40", + "Doc": "The largest integer I such that I^2 \u003c= A. A and I are interpreted as big-endian unsigned integers", + "IntroducedVersion": 6, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 151, + "Name": "divw", + "Args": [ + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 6, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 152, + "Name": "sha3_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "SHA3_256 hash of value A, yields [32]byte", + "IntroducedVersion": 7, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 160, + "Name": "b+", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A plus B. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 161, + "Name": "b-", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 162, + "Name": "b/", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 163, + "Name": "b*", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A times B. A and B are interpreted as big-endian unsigned integers.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 164, + "Name": "b\u003c", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 165, + "Name": "b\u003e", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 166, + "Name": "b\u003c=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 167, + "Name": "b\u003e=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 168, + "Name": "b==", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 169, + "Name": "b!=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 170, + "Name": "b%", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 171, + "Name": "b|", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-or B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 172, + "Name": "b\u0026", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-and B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 173, + "Name": "b^", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-xor B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 174, + "Name": "b~", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "4", + "Doc": "A with all bits inverted", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 175, + "Name": "bzero", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "zero filled byte-array of length A", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 176, + "Name": "log", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 177, + "Name": "itxn_begin", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 178, + "Name": "itxn_field", + "Args": [ + "any" + ], + "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": [ + "address", + "uint64", + "[]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "uint64", + "[]byte", + "address", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 179, + "Name": "itxn_submit", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 180, + "Name": "itxn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 181, + "Name": "itxna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "a transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 182, + "Name": "itxn_next", + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 183, + "Name": "gitxn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 184, + "Name": "gitxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F from the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "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" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 185, + "Name": "box_create", + "Args": [ + "boxName", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 186, + "Name": "box_extract", + "Args": [ + "boxName", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 187, + "Name": "box_replace", + "Args": [ + "boxName", + "uint64", + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 188, + "Name": "box_del", + "Args": [ + "boxName" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "delete box named A if it exists. Return 1 if A existed, 0 otherwise", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 189, + "Name": "box_len", + "Args": [ + "boxName" + ], + "Returns": [ + "uint64", + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0.", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 190, + "Name": "box_get", + "Args": [ + "boxName" + ], + "Returns": [ + "[]byte", + "bool" + ], + "Size": 1, + "DocCost": "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`", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 191, + "Name": "box_put", + "Args": [ + "boxName", + "[]byte" + ], + "Size": 1, + "DocCost": "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`", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 192, + "Name": "txnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ath value of the array field F of the current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 193, + "Name": "gtxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ath value of the array field F from the Tth transaction in the current group", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 194, + "Name": "gtxnsas", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Bth value of the array field F from the Ath transaction in the current group", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 195, + "Name": "args", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Ath LogicSig argument", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 196, + "Name": "gloadss", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth scratch space value of the Ath transaction in the current group", + "IntroducedVersion": 6, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 197, + "Name": "itxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ath value of the array field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 198, + "Name": "gitxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "DocCost": "1", + "Doc": "Ath value of the array field F from the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 208, + "Name": "vrf_verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "VrfAlgorand" + ], + "DocCost": "5700", + "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": [ + { + "Comment": " parameters index", + "Encoding": "uint8", + "Name": "S", + "Reference": "vrf_verify" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 209, + "Name": "block", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "BlkSeed", + "BlkTimestamp" + ], + "ArgEnumTypes": [ + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)", + "ImmediateNote": [ + { + "Comment": " block field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "block" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "State Access" + ] + } + ] +} diff --git a/data/transactions/logic/langspec_v9.json b/data/transactions/logic/langspec_v9.json new file mode 100644 index 0000000000..9c4a41c780 --- /dev/null +++ b/data/transactions/logic/langspec_v9.json @@ -0,0 +1,4626 @@ +{ + "Version": 9, + "LogicSigVersion": 9, + "NamedTypes": [ + { + "Name": "uint64", + "Abbreviation": "i", + "Bound": [ + 0, + 18446744073709551615 + ], + "AVMType": "uint64" + }, + { + "Name": "stateKey", + "Abbreviation": "K", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "none", + "Abbreviation": "x", + "Bound": [ + 0, + 0 + ], + "AVMType": "none" + }, + { + "Name": "method", + "Abbreviation": "M", + "Bound": [ + 4, + 4 + ], + "AVMType": "[]byte" + }, + { + "Name": "boxName", + "Abbreviation": "N", + "Bound": [ + 1, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "bool", + "Abbreviation": "T", + "Bound": [ + 0, + 1 + ], + "AVMType": "uint64" + }, + { + "Name": "bigint", + "Abbreviation": "I", + "Bound": [ + 0, + 64 + ], + "AVMType": "[]byte" + }, + { + "Name": "any", + "Abbreviation": "a", + "Bound": [ + 0, + 0 + ], + "AVMType": "any" + }, + { + "Name": "address", + "Abbreviation": "A", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + }, + { + "Name": "[]byte", + "Abbreviation": "b", + "Bound": [ + 0, + 4096 + ], + "AVMType": "[]byte" + }, + { + "Name": "[32]byte", + "Abbreviation": "H", + "Bound": [ + 32, + 32 + ], + "AVMType": "[]byte" + } + ], + "Ops": [ + { + "Opcode": 0, + "Name": "err", + "Size": 1, + "DocCost": "1", + "Doc": "Fail immediately.", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 1, + "Name": "sha256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "35", + "Doc": "SHA256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 2, + "Name": "keccak256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "Keccak256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 3, + "Name": "sha512_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[32]byte" + ], + "Size": 1, + "DocCost": "45", + "Doc": "SHA512_256 hash of value A, yields [32]byte", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 4, + "Name": "ed25519verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {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.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 5, + "Name": "ecdsa_verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1", + "Secp256r1" + ], + "DocCost": "Secp256k1=1700; Secp256r1=2500", + "Doc": "for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey =\u003e {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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 6, + "Name": "ecdsa_pk_decompress", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1", + "Secp256r1" + ], + "DocCost": "Secp256k1=650; Secp256r1=2400", + "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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 7, + "Name": "ecdsa_pk_recover", + "Args": [ + "[]byte", + "uint64", + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte", + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "Secp256k1", + "Secp256r1" + ], + "DocCost": "2000", + "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": [ + { + "Comment": "curve index", + "Encoding": "uint8", + "Name": "V", + "Reference": "ECDSA" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 8, + "Name": "+", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 9, + "Name": "-", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A minus B. Fail if B \u003e A.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 10, + "Name": "/", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 11, + "Name": "*", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 12, + "Name": "\u003c", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 13, + "Name": "\u003e", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 14, + "Name": "\u003c=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A less than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 15, + "Name": "\u003e=", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A greater than or equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 16, + "Name": "\u0026\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero and B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 17, + "Name": "||", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not zero or B is not zero =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 18, + "Name": "==", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 19, + "Name": "!=", + "Args": [ + "any", + "any" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A is not equal to B =\u003e {0 or 1}", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 20, + "Name": "!", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A == 0 yields 1; else 0", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 21, + "Name": "len", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "yields length of byte value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 22, + "Name": "itob", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts uint64 A to big-endian byte array, always of length 8", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 23, + "Name": "btoi", + "Args": [ + "[]byte" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "converts big-endian byte array A to uint64. Fails if len(A) \u003e 8. Padded by leading 0s if len(A) \u003c 8.", + "DocExtra": "`btoi` fails if the input is longer than 8 bytes.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 24, + "Name": "%", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A modulo B. Fail if B == 0.", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 25, + "Name": "|", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-or B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 26, + "Name": "\u0026", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-and B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 27, + "Name": "^", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A bitwise-xor B", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 28, + "Name": "~", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "bitwise invert value A", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 29, + "Name": "mulw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low", + "IntroducedVersion": 1, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 30, + "Name": "addw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 31, + "Name": "divmodw", + "Args": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64", + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "20", + "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.", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 32, + "Name": "intcblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of int constant values", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 33, + "Name": "intc", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from intcblock", + "ImmediateNote": [ + { + "Comment": "an index in the intcblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 34, + "Name": "intc_0", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 35, + "Name": "intc_1", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 36, + "Name": "intc_2", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 37, + "Name": "intc_3", + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from intcblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 38, + "Name": "bytecblock", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a block of byte constant values", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 39, + "Name": "bytec", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith constant from bytecblock", + "ImmediateNote": [ + { + "Comment": "an index in the bytecblock", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 40, + "Name": "bytec_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 0 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 41, + "Name": "bytec_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 1 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 42, + "Name": "bytec_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 2 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 43, + "Name": "bytec_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "constant 3 from bytecblock", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 44, + "Name": "arg", + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth LogicSig argument", + "ImmediateNote": [ + { + "Comment": "an arg index", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 45, + "Name": "arg_0", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 0", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 46, + "Name": "arg_1", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 1", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 47, + "Name": "arg_2", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 2", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 48, + "Name": "arg_3", + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "LogicSig argument 3", + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 49, + "Name": "txn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 50, + "Name": "global", + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "MinTxnFee", + "MinBalance", + "MaxTxnLife", + "ZeroAddress", + "GroupSize", + "LogicSigVersion", + "Round", + "LatestTimestamp", + "CurrentApplicationID", + "CreatorAddress", + "CurrentApplicationAddress", + "GroupID", + "OpcodeBudget", + "CallerApplicationID", + "CallerApplicationAddress" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "uint64", + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address", + "address", + "[32]byte", + "uint64", + "uint64", + "address" + ], + "DocCost": "1", + "Doc": "global field F", + "ImmediateNote": [ + { + "Comment": "a global field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "global" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 51, + "Name": "gtxn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 52, + "Name": "load", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ith scratch space value. All scratch spaces are 0 at program start.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 53, + "Name": "store", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "store A to the Ith scratch space", + "ImmediateNote": [ + { + "Comment": "position in scratch space to store to", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 54, + "Name": "txna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the current transaction\n`txna` can be called using `txn` with 2 immediates.", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 55, + "Name": "gtxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "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" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 56, + "Name": "gtxns", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 57, + "Name": "gtxnsa", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 58, + "Name": "gload", + "Returns": [ + "any" + ], + "Size": 3, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 59, + "Name": "gloads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "position in scratch space to load from", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 60, + "Name": "gaid", + "Returns": [ + "uint64" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c GroupIndex.", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 61, + "Name": "gaids", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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 \u003c GroupIndex.", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 62, + "Name": "loads", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Ath scratch space value. All scratch spaces are 0 at program start.", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 63, + "Name": "stores", + "Args": [ + "uint64", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "store B to the Ath scratch space", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 64, + "Name": "bnz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 65, + "Name": "bz", + "Args": [ + "uint64" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 66, + "Name": "b", + "Size": 3, + "DocCost": "1", + "Doc": "branch unconditionally to TARGET", + "DocExtra": "See `bnz` for details on how branches work. `b` always jumps to the offset.", + "ImmediateNote": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 67, + "Name": "return", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "use A as success value; end", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 68, + "Name": "assert", + "Args": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "immediately fail unless A is a non-zero number", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 69, + "Name": "bury", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "replace the Nth value from the top of the stack with A. bury 0 fails.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 70, + "Name": "popn", + "Size": 2, + "DocCost": "1", + "Doc": "remove N values from the top of the stack", + "ImmediateNote": [ + { + "Comment": "stack depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 71, + "Name": "dupn", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "duplicate A, N times", + "ImmediateNote": [ + { + "Comment": "copy count", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 72, + "Name": "pop", + "Args": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "discard A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 73, + "Name": "dup", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A", + "IntroducedVersion": 1, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 74, + "Name": "dup2", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any", + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "duplicate A and B", + "IntroducedVersion": 2, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 75, + "Name": "dig", + "Args": [ + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth value from the top of the stack. dig 0 is equivalent to dup", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 76, + "Name": "swap", + "Args": [ + "any", + "any" + ], + "Returns": [ + "any", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "swaps A and B on stack", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 77, + "Name": "select", + "Args": [ + "any", + "any", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "selects one of two values based on top-of-stack: B if C != 0, else A", + "IntroducedVersion": 3, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 78, + "Name": "cover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth \u003c= N.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 79, + "Name": "uncover", + "Args": [ + "any" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "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 \u003c= N.", + "ImmediateNote": [ + { + "Comment": "depth", + "Encoding": "uint8", + "Name": "N" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 80, + "Name": "concat", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "join A and B", + "DocExtra": "`concat` fails if the result would be greater than 4096 bytes.", + "IntroducedVersion": 2, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 81, + "Name": "substring", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "Doc": "A range of bytes from A starting at S up to but not including E. If E \u003c S, or either is larger than the array length, the program fails", + "ImmediateNote": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "end position", + "Encoding": "uint8", + "Name": "E" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 82, + "Name": "substring3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A range of bytes from A starting at B up to but not including C. If C \u003c B, or either is larger than the array length, the program fails", + "IntroducedVersion": 2, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 83, + "Name": "getbit", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 84, + "Name": "setbit", + "Args": [ + "any", + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 85, + "Name": "getbyte", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 86, + "Name": "setbyte", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 3, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 87, + "Name": "extract", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + }, + { + "Comment": "length", + "Encoding": "uint8", + "Name": "L" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 88, + "Name": "extract3", + "Args": [ + "[]byte", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 89, + "Name": "extract_uint16", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 90, + "Name": "extract_uint32", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 91, + "Name": "extract_uint64", + "Args": [ + "[]byte", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 5, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 92, + "Name": "replace2", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 2, + "DocCost": "1", + "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": [ + { + "Comment": "start position", + "Encoding": "uint8", + "Name": "S" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 93, + "Name": "replace3", + "Args": [ + "[]byte", + "uint64", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 94, + "Name": "base64_decode", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 2, + "ArgEnum": [ + "URLEncoding", + "StdEncoding" + ], + "ArgEnumTypes": [ + "any", + "any" + ], + "DocCost": "1 + 1 per 16 bytes of A", + "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": [ + { + "Comment": "encoding index", + "Encoding": "uint8", + "Name": "E", + "Reference": "base64" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 95, + "Name": "json_ref", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "JSONString", + "JSONUint64", + "JSONObject" + ], + "ArgEnumTypes": [ + "[]byte", + "uint64", + "[]byte" + ], + "DocCost": "25 + 2 per 7 bytes of A", + "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": [ + { + "Comment": "return type index", + "Encoding": "uint8", + "Name": "R", + "Reference": "json_ref" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Byte Array Manipulation" + ] + }, + { + "Opcode": 96, + "Name": "balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 97, + "Name": "app_opted_in", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 98, + "Name": "app_local_get", + "Args": [ + "any", + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 99, + "Name": "app_local_get_ex", + "Args": [ + "any", + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 100, + "Name": "app_global_get", + "Args": [ + "[]byte" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 101, + "Name": "app_global_get_ex", + "Args": [ + "uint64", + "[]byte" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 102, + "Name": "app_local_put", + "Args": [ + "any", + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 103, + "Name": "app_global_put", + "Args": [ + "[]byte", + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "write B to key A in the global state of the current application", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 104, + "Name": "app_local_del", + "Args": [ + "any", + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 105, + "Name": "app_global_del", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.)", + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 112, + "Name": "asset_holding_get", + "Args": [ + "any", + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetBalance", + "AssetFrozen" + ], + "ArgEnumTypes": [ + "uint64", + "bool" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset holding field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_holding" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 113, + "Name": "asset_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AssetTotal", + "AssetDecimals", + "AssetDefaultFrozen", + "AssetUnitName", + "AssetName", + "AssetURL", + "AssetMetadataHash", + "AssetManager", + "AssetReserve", + "AssetFreeze", + "AssetClawback", + "AssetCreator" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "asset params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "asset_params" + } + ], + "IntroducedVersion": 2, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 114, + "Name": "app_params_get", + "Args": [ + "uint64" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AppApprovalProgram", + "AppClearStateProgram", + "AppGlobalNumUint", + "AppGlobalNumByteSlice", + "AppLocalNumUint", + "AppLocalNumByteSlice", + "AppExtraProgramPages", + "AppCreator", + "AppAddress" + ], + "ArgEnumTypes": [ + "[]byte", + "[]byte", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "address", + "address" + ], + "DocCost": "1", + "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": [ + { + "Comment": "app params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "app_params" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 115, + "Name": "acct_params_get", + "Args": [ + "any" + ], + "Returns": [ + "any", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "AcctBalance", + "AcctMinBalance", + "AcctAuthAddr", + "AcctTotalNumUint", + "AcctTotalNumByteSlice", + "AcctTotalExtraAppPages", + "AcctTotalAppsCreated", + "AcctTotalAppsOptedIn", + "AcctTotalAssetsCreated", + "AcctTotalAssets", + "AcctTotalBoxes", + "AcctTotalBoxBytes" + ], + "ArgEnumTypes": [ + "uint64", + "uint64", + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64" + ], + "DocCost": "1", + "Doc": "X is field F from account A. Y is 1 if A owns positive algos, else 0", + "ImmediateNote": [ + { + "Comment": "account params field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "acct_params" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 120, + "Name": "min_balance", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 3, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 128, + "Name": "pushbytes", + "Returns": [ + "[]byte" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate BYTES", + "DocExtra": "pushbytes args are not added to the bytecblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "a byte constant", + "Encoding": "varuint length, bytes", + "Name": "BYTES" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 129, + "Name": "pushint", + "Returns": [ + "uint64" + ], + "Size": 0, + "DocCost": "1", + "Doc": "immediate UINT", + "DocExtra": "pushint args are not added to the intcblock during assembly processes", + "ImmediateNote": [ + { + "Comment": "an int constant", + "Encoding": "varuint", + "Name": "UINT" + } + ], + "IntroducedVersion": 3, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 130, + "Name": "pushbytess", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a list of byte constants", + "Encoding": "varuint count, [varuint length, bytes ...]", + "Name": "BYTES ..." + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 131, + "Name": "pushints", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "a list of int constants", + "Encoding": "varuint count, [varuint ...]", + "Name": "UINT ..." + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 132, + "Name": "ed25519verify_bare", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1900", + "Doc": "for (data A, signature B, pubkey C) verify the signature of the data against the pubkey =\u003e {0 or 1}", + "IntroducedVersion": 7, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 136, + "Name": "callsub", + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "branch offset", + "Encoding": "int16 (big-endian)", + "Name": "TARGET" + } + ], + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 137, + "Name": "retsub", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 4, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 138, + "Name": "proto", + "Size": 3, + "DocCost": "1", + "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": [ + { + "Comment": "number of arguments", + "Encoding": "uint8", + "Name": "A" + }, + { + "Comment": "number of return values", + "Encoding": "uint8", + "Name": "R" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 139, + "Name": "frame_dig", + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Nth (signed) value from the frame pointer.", + "ImmediateNote": [ + { + "Comment": "frame slot", + "Encoding": "int8", + "Name": "I" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 140, + "Name": "frame_bury", + "Args": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "replace the Nth (signed) value from the frame pointer in the stack with A", + "ImmediateNote": [ + { + "Comment": "frame slot", + "Encoding": "int8", + "Name": "I" + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 141, + "Name": "switch", + "Args": [ + "uint64" + ], + "Size": 0, + "DocCost": "1", + "Doc": "branch to the Ath label. Continue at following instruction if index A exceeds the number of labels.", + "ImmediateNote": [ + { + "Comment": "list of labels", + "Encoding": "varuint count, [int16 (big-endian) ...]", + "Name": "TARGET ..." + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 142, + "Name": "match", + "Size": 0, + "DocCost": "1", + "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": [ + { + "Comment": "list of labels", + "Encoding": "varuint count, [int16 (big-endian) ...]", + "Name": "TARGET ..." + } + ], + "IntroducedVersion": 8, + "Groups": [ + "Flow Control" + ] + }, + { + "Opcode": 144, + "Name": "shl", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A times 2^B, modulo 2^64", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 145, + "Name": "shr", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A divided by 2^B", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 146, + "Name": "sqrt", + "Args": [ + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "4", + "Doc": "The largest integer I such that I^2 \u003c= A", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 147, + "Name": "bitlen", + "Args": [ + "any" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 148, + "Name": "exp", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "1", + "Doc": "A raised to the Bth power. Fail if A == B == 0 and on overflow", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 149, + "Name": "expw", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "uint64", + "uint64" + ], + "Size": 1, + "DocCost": "10", + "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", + "IntroducedVersion": 4, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 150, + "Name": "bsqrt", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "40", + "Doc": "The largest integer I such that I^2 \u003c= A. A and I are interpreted as big-endian unsigned integers", + "IntroducedVersion": 6, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 151, + "Name": "divw", + "Args": [ + "uint64", + "uint64", + "uint64" + ], + "Returns": [ + "uint64" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 6, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 152, + "Name": "sha3_256", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "130", + "Doc": "SHA3_256 hash of value A, yields [32]byte", + "IntroducedVersion": 7, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 160, + "Name": "b+", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A plus B. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 161, + "Name": "b-", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "10", + "Doc": "A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 162, + "Name": "b/", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bigint" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 163, + "Name": "b*", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A times B. A and B are interpreted as big-endian unsigned integers.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 164, + "Name": "b\u003c", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 165, + "Name": "b\u003e", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 166, + "Name": "b\u003c=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 167, + "Name": "b\u003e=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 168, + "Name": "b==", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 169, + "Name": "b!=", + "Args": [ + "bigint", + "bigint" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 170, + "Name": "b%", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "20", + "Doc": "A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Arithmetic" + ] + }, + { + "Opcode": 171, + "Name": "b|", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-or B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 172, + "Name": "b\u0026", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-and B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 173, + "Name": "b^", + "Args": [ + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "6", + "Doc": "A bitwise-xor B. A and B are zero-left extended to the greater of their lengths", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 174, + "Name": "b~", + "Args": [ + "[]byte" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "4", + "Doc": "A with all bits inverted", + "IntroducedVersion": 4, + "Groups": [ + "Byte Array Logic" + ] + }, + { + "Opcode": 175, + "Name": "bzero", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "zero filled byte-array of length A", + "IntroducedVersion": 4, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 176, + "Name": "log", + "Args": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "State Access" + ] + }, + { + "Opcode": 177, + "Name": "itxn_begin", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 178, + "Name": "itxn_field", + "Args": [ + "any" + ], + "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": [ + "address", + "uint64", + "[]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "uint64", + "[]byte", + "address", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "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": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 179, + "Name": "itxn_submit", + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 180, + "Name": "itxn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 181, + "Name": "itxna", + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + }, + { + "Comment": "a transaction field array index", + "Encoding": "uint8", + "Name": "I" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 182, + "Name": "itxn_next", + "Size": 1, + "DocCost": "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", + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 183, + "Name": "gitxn", + "Returns": [ + "any" + ], + "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": [ + "address", + "uint64", + "uint64", + "uint64", + "uint64", + "[]byte", + "[32]byte", + "address", + "uint64", + "address", + "[32]byte", + "[32]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "uint64", + "uint64", + "uint64", + "address", + "address", + "address", + "uint64", + "[32]byte", + "uint64", + "uint64", + "[]byte", + "uint64", + "address", + "uint64", + "[]byte", + "[]byte", + "address", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "[]byte", + "[]byte", + "[32]byte", + "address", + "address", + "address", + "address", + "uint64", + "address", + "bool", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "uint64", + "bool", + "[]byte", + "uint64", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte", + "uint64", + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txn" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 184, + "Name": "gitxna", + "Returns": [ + "any" + ], + "Size": 4, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ith value of the array field F from the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "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" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 185, + "Name": "box_create", + "Args": [ + "boxName", + "uint64" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "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`.", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 186, + "Name": "box_extract", + "Args": [ + "boxName", + "uint64", + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 187, + "Name": "box_replace", + "Args": [ + "boxName", + "uint64", + "[]byte" + ], + "Size": 1, + "DocCost": "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.", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 188, + "Name": "box_del", + "Args": [ + "boxName" + ], + "Returns": [ + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "delete box named A if it exists. Return 1 if A existed, 0 otherwise", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 189, + "Name": "box_len", + "Args": [ + "boxName" + ], + "Returns": [ + "uint64", + "bool" + ], + "Size": 1, + "DocCost": "1", + "Doc": "X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0.", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 190, + "Name": "box_get", + "Args": [ + "boxName" + ], + "Returns": [ + "[]byte", + "bool" + ], + "Size": 1, + "DocCost": "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`", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 191, + "Name": "box_put", + "Args": [ + "boxName", + "[]byte" + ], + "Size": 1, + "DocCost": "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`", + "IntroducedVersion": 8, + "Groups": [ + "Box Access" + ] + }, + { + "Opcode": 192, + "Name": "txnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ath value of the array field F of the current transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 193, + "Name": "gtxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Ath value of the array field F from the Tth transaction in the current group", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 194, + "Name": "gtxnsas", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "ApplicationArgs", + "Accounts", + "Assets", + "Applications", + "Logs", + "ApprovalProgramPages", + "ClearStateProgramPages" + ], + "ArgEnumTypes": [ + "[]byte", + "address", + "uint64", + "uint64", + "[]byte", + "[]byte", + "[]byte" + ], + "DocCost": "1", + "Doc": "Bth value of the array field F from the Ath transaction in the current group", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 195, + "Name": "args", + "Args": [ + "uint64" + ], + "Returns": [ + "[]byte" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Ath LogicSig argument", + "IntroducedVersion": 5, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 196, + "Name": "gloadss", + "Args": [ + "uint64", + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 1, + "DocCost": "1", + "Doc": "Bth scratch space value of the Ath transaction in the current group", + "IntroducedVersion": 6, + "Groups": [ + "Loading Values" + ] + }, + { + "Opcode": 197, + "Name": "itxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "DocCost": "1", + "Doc": "Ath value of the array field F of the last inner transaction", + "ImmediateNote": [ + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 198, + "Name": "gitxnas", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 3, + "DocCost": "1", + "Doc": "Ath value of the array field F from the Tth transaction in the last inner group submitted", + "ImmediateNote": [ + { + "Comment": "transaction group index", + "Encoding": "uint8", + "Name": "T" + }, + { + "Comment": "transaction field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "txna" + } + ], + "IntroducedVersion": 6, + "Groups": [ + "Inner Transactions" + ] + }, + { + "Opcode": 208, + "Name": "vrf_verify", + "Args": [ + "[]byte", + "[]byte", + "[]byte" + ], + "Returns": [ + "[]byte", + "bool" + ], + "Size": 2, + "ArgEnum": [ + "VrfAlgorand" + ], + "DocCost": "5700", + "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": [ + { + "Comment": " parameters index", + "Encoding": "uint8", + "Name": "S", + "Reference": "vrf_verify" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "Arithmetic" + ] + }, + { + "Opcode": 209, + "Name": "block", + "Args": [ + "uint64" + ], + "Returns": [ + "any" + ], + "Size": 2, + "ArgEnum": [ + "BlkSeed", + "BlkTimestamp" + ], + "ArgEnumTypes": [ + "[]byte", + "uint64" + ], + "DocCost": "1", + "Doc": "field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)", + "ImmediateNote": [ + { + "Comment": " block field index", + "Encoding": "uint8", + "Name": "F", + "Reference": "block" + } + ], + "IntroducedVersion": 7, + "Groups": [ + "State Access" + ] + } + ] +} diff --git a/data/transactions/logic/opcodes.go b/data/transactions/logic/opcodes.go index 42825faa9f..4b6a9000eb 100644 --- a/data/transactions/logic/opcodes.go +++ b/data/transactions/logic/opcodes.go @@ -142,7 +142,7 @@ type OpDetails struct { trusted bool // if `trusted`, don't check stack effects. they are more complicated than simply checking the opcode prototype. } -func (d *OpDetails) docCost(argLen int) string { +func (d *OpDetails) docCost(argLen int, version uint64) string { cost := d.FullCost.docCost(argLen) if cost != "" { return cost @@ -155,14 +155,15 @@ func (d *OpDetails) docCost(argLen int) string { } found = true group := imm.Group + var fieldCostStrings []string for _, name := range group.Names { fs, ok := group.SpecByName(name) - if !ok { + if !ok || fs.Version() > version { continue } - cost += fmt.Sprintf(" %s=%s;", name, imm.fieldCosts[fs.Field()].docCost(argLen)) + fieldCostStrings = append(fieldCostStrings, fmt.Sprintf("%s=%s", name, imm.fieldCosts[fs.Field()].docCost(argLen))) } - cost = strings.TrimSuffix(cost, ";") + cost = strings.Join(fieldCostStrings, "; ") } } return cost @@ -462,6 +463,11 @@ func (spec *OpSpec) AlwaysExits() bool { return len(spec.Return.Types) == 1 && spec.Return.Types[0].AVMType == avmNone } +// DocCost returns the cost of the opcode in human-readable form. +func (spec *OpSpec) DocCost(version uint64) string { + return spec.OpDetails.docCost(len(spec.Arg.Types), version) +} + func (spec *OpSpec) deadens() bool { switch spec.Name { case "b", "callsub", "retsub", "err", "return":