Skip to content

Opcodes List

This page contains a reference for all available opcodes v11.

OPCODE
NAME
STACK INPUT
STACK OUTPUT
0x00
err
-
-
SizeAvailabilityDoc Cost
1v11
Description

Fail immediately.

Groups

Flow Control

0x01
sha256
[]byte
[32]byte
SizeAvailabilityDoc Cost
1v135
Description

SHA256 hash of value A, yields [32]byte

Groups

Cryptography

0x02
keccak256
[]byte
[32]byte
SizeAvailabilityDoc Cost
1v1130
Description

Keccak256 hash of value A, yields [32]byte

Groups

Cryptography

0x03
sha512_256
[]byte
[32]byte
SizeAvailabilityDoc Cost
1v145
Description

SHA512_256 hash of value A, yields [32]byte

Groups

Cryptography

0x04
ed25519verify
[]byte
[64]byte
[32]byte
bool
SizeAvailabilityDoc Cost
1v11900
Description

for (data A, signature B, pubkey C) verify the signature of ("ProgData" || program_hash || data) against the pubkey => {0 or 1}

Groups

Cryptography

Notes

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.

0x05
ecdsa_verify
[32]byte
[32]byte
[32]byte
[32]byte
[32]byte
bool
SizeAvailabilityDoc Cost
2v5Secp256k1=1700; Secp256r1=2500
Description

for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey => {0 or 1}

Groups

Cryptography

Notes

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.

Immediate Notes
CommentEncodingNameReference
curve indexuint8VECDSA
0x06
ecdsa_pk_decompress
[33]byte
[32]byte
[32]byte
SizeAvailabilityDoc Cost
2v5Secp256k1=650; Secp256r1=2400
Description

decompress pubkey A into components X, Y

Groups

Cryptography

Notes

The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded.

Immediate Notes
CommentEncodingNameReference
curve indexuint8VECDSA
0x07
ecdsa_pk_recover
[32]byte
uint64
[32]byte
[32]byte
[32]byte
[32]byte
SizeAvailabilityDoc Cost
2v52000
Description

for (data A, recovery id B, signature C, D) recover a public key

Groups

Cryptography

Notes

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.

Immediate Notes
CommentEncodingNameReference
curve indexuint8VECDSA
0x08
+
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

A plus B. Fail on overflow.

Groups

Arithmetic

Notes

Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`.

0x09
-
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

A minus B. Fail if B > A.

Groups

Arithmetic

0x0a
/
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

A divided by B (truncated division). Fail if B == 0.

Groups

Arithmetic

Notes

`divmodw` is available to divide the two-element values produced by `mulw` and `addw`.

0x0b
*
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

A times B. Fail on overflow.

Groups

Arithmetic

Notes

Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`.

0x0c
<
uint64
uint64
bool
SizeAvailabilityDoc Cost
1v11
Description

A less than B => {0 or 1}

Groups

Arithmetic

0x0d
>
uint64
uint64
bool
SizeAvailabilityDoc Cost
1v11
Description

A greater than B => {0 or 1}

Groups

Arithmetic

0x0e
<=
uint64
uint64
bool
SizeAvailabilityDoc Cost
1v11
Description

A less than or equal to B => {0 or 1}

Groups

Arithmetic

0x0f
>=
uint64
uint64
bool
SizeAvailabilityDoc Cost
1v11
Description

A greater than or equal to B => {0 or 1}

Groups

Arithmetic

0x10
&&
uint64
uint64
bool
SizeAvailabilityDoc Cost
1v11
Description

A is not zero and B is not zero => {0 or 1}

Groups

Arithmetic

0x11
||
uint64
uint64
bool
SizeAvailabilityDoc Cost
1v11
Description

A is not zero or B is not zero => {0 or 1}

Groups

Arithmetic

0x12
==
any
any
bool
SizeAvailabilityDoc Cost
1v11
Description

A is equal to B => {0 or 1}

Groups

Arithmetic

0x13
!=
any
any
bool
SizeAvailabilityDoc Cost
1v11
Description

A is not equal to B => {0 or 1}

Groups

Arithmetic

0x14
!
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

A == 0 yields 1; else 0

Groups

Arithmetic

0x15
len
[]byte
uint64
SizeAvailabilityDoc Cost
1v11
Description

yields length of byte value A

Groups

Byte Array Manipulation

0x16
itob
uint64
[8]byte
SizeAvailabilityDoc Cost
1v11
Description

converts uint64 A to big-endian byte array, always of length 8

Groups

Arithmetic

0x17
btoi
[]byte
uint64
SizeAvailabilityDoc Cost
1v11
Description

converts big-endian byte array A to uint64. Fails if len(A) > 8. Padded by leading 0s if len(A) < 8.

Groups

Arithmetic

Notes

`btoi` fails if the input is longer than 8 bytes.

0x18
%
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

A modulo B. Fail if B == 0.

Groups

Arithmetic

0x19
|
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

A bitwise-or B

Groups

Arithmetic

0x1a
&
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

A bitwise-and B

Groups

Arithmetic

0x1b
^
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

A bitwise-xor B

Groups

Arithmetic

0x1c
~
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

bitwise invert value A

Groups

Arithmetic

0x1d
mulw
uint64
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v11
Description

A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low

Groups

Arithmetic

0x1e
addw
uint64
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v21
Description

A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.

Groups

Arithmetic

0x1f
divmodw
uint64
uint64
uint64
uint64
uint64
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v420
Description

W,X = (A,B / C,D); Y,Z = (A,B modulo C,D)

Groups

Arithmetic

Notes

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.

0x20
intcblock
-
-
SizeAvailabilityDoc Cost
0v11
Description

prepare block of uint64 constants for use by intc

Groups

Loading Values

Notes

`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.

Immediate Notes
CommentEncodingName
a block of int constant valuesvaruint count, [varuint ...]UINT ...
0x21
intc
-
uint64
SizeAvailabilityDoc Cost
2v11
Description

Ith constant from intcblock

Groups

Loading Values

Immediate Notes
CommentEncodingName
an index in the intcblockuint8I
0x22
intc_0
-
uint64
SizeAvailabilityDoc Cost
1v11
Description

constant 0 from intcblock

Groups

Loading Values

0x23
intc_1
-
uint64
SizeAvailabilityDoc Cost
1v11
Description

constant 1 from intcblock

Groups

Loading Values

0x24
intc_2
-
uint64
SizeAvailabilityDoc Cost
1v11
Description

constant 2 from intcblock

Groups

Loading Values

0x25
intc_3
-
uint64
SizeAvailabilityDoc Cost
1v11
Description

constant 3 from intcblock

Groups

Loading Values

0x26
bytecblock
-
-
SizeAvailabilityDoc Cost
0v11
Description

prepare block of byte-array constants for use by bytec

Groups

Loading Values

Notes

`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.

Immediate Notes
CommentEncodingName
a block of byte constant valuesvaruint count, [varuint length, bytes ...]BYTES ...
0x27
bytec
-
[]byte
SizeAvailabilityDoc Cost
2v11
Description

Ith constant from bytecblock

Groups

Loading Values

Immediate Notes
CommentEncodingName
an index in the bytecblockuint8I
0x28
bytec_0
-
[]byte
SizeAvailabilityDoc Cost
1v11
Description

constant 0 from bytecblock

Groups

Loading Values

0x29
bytec_1
-
[]byte
SizeAvailabilityDoc Cost
1v11
Description

constant 1 from bytecblock

Groups

Loading Values

0x2a
bytec_2
-
[]byte
SizeAvailabilityDoc Cost
1v11
Description

constant 2 from bytecblock

Groups

Loading Values

0x2b
bytec_3
-
[]byte
SizeAvailabilityDoc Cost
1v11
Description

constant 3 from bytecblock

Groups

Loading Values

0x2c
arg
-
[]byte
SizeAvailabilityDoc Cost
2v11
Description

Nth LogicSig argument

Groups

Loading Values

Immediate Notes
CommentEncodingName
an arg indexuint8N
0x2d
arg_0
-
[]byte
SizeAvailabilityDoc Cost
1v11
Description

LogicSig argument 0

Groups

Loading Values

0x2e
arg_1
-
[]byte
SizeAvailabilityDoc Cost
1v11
Description

LogicSig argument 1

Groups

Loading Values

0x2f
arg_2
-
[]byte
SizeAvailabilityDoc Cost
1v11
Description

LogicSig argument 2

Groups

Loading Values

0x30
arg_3
-
[]byte
SizeAvailabilityDoc Cost
1v11
Description

LogicSig argument 3

Groups

Loading Values

0x31
txn
-
any
SizeAvailabilityDoc Cost
2v11
Description

field F of current transaction

Groups

Loading Values

Immediate Notes
CommentEncodingNameReference
transaction field indexuint8Ftxn
Argument Details
IndexArgumentType
0Senderaddress
1Feeuint64
2FirstValiduint64
3FirstValidTimeuint64
4LastValiduint64
5Note[]byte
6Lease[32]byte
7Receiveraddress
8Amountuint64
9CloseRemainderToaddress
10VotePK[32]byte
11SelectionPK[32]byte
12VoteFirstuint64
13VoteLastuint64
14VoteKeyDilutionuint64
15Type[]byte
16TypeEnumuint64
17XferAssetuint64
18AssetAmountuint64
19AssetSenderaddress
20AssetReceiveraddress
21AssetCloseToaddress
22GroupIndexuint64
23TxID[32]byte
24ApplicationIDuint64
25OnCompletionuint64
26ApplicationArgs[]byte
27NumAppArgsuint64
28Accountsaddress
29NumAccountsuint64
30ApprovalProgram[]byte
31ClearStateProgram[]byte
32RekeyToaddress
33ConfigAssetuint64
34ConfigAssetTotaluint64
35ConfigAssetDecimalsuint64
36ConfigAssetDefaultFrozenbool
37ConfigAssetUnitName[]byte
38ConfigAssetName[]byte
39ConfigAssetURL[]byte
40ConfigAssetMetadataHash[32]byte
41ConfigAssetManageraddress
42ConfigAssetReserveaddress
43ConfigAssetFreezeaddress
44ConfigAssetClawbackaddress
45FreezeAssetuint64
46FreezeAssetAccountaddress
47FreezeAssetFrozenbool
48Assetsuint64
49NumAssetsuint64
50Applicationsuint64
51NumApplicationsuint64
52GlobalNumUintuint64
53GlobalNumByteSliceuint64
54LocalNumUintuint64
55LocalNumByteSliceuint64
56ExtraProgramPagesuint64
57Nonparticipationbool
58Logs[]byte
59NumLogsuint64
60CreatedAssetIDuint64
61CreatedApplicationIDuint64
62LastLog[]byte
63StateProofPK[]byte
64ApprovalProgramPages[]byte
65NumApprovalProgramPagesuint64
66ClearStateProgramPages[]byte
67NumClearStateProgramPagesuint64
0x32
global
-
any
SizeAvailabilityDoc Cost
2v11
Description

global field F

Groups

Loading Values

Immediate Notes
CommentEncodingNameReference
a global field indexuint8Fglobal
Argument Details
IndexArgumentType
0MinTxnFeeuint64
1MinBalanceuint64
2MaxTxnLifeuint64
3ZeroAddressaddress
4GroupSizeuint64
5LogicSigVersionuint64
6Rounduint64
7LatestTimestampuint64
8CurrentApplicationIDuint64
9CreatorAddressaddress
10CurrentApplicationAddressaddress
11GroupID[32]byte
12OpcodeBudgetuint64
13CallerApplicationIDuint64
14CallerApplicationAddressaddress
15AssetCreateMinBalanceuint64
16AssetOptInMinBalanceuint64
17GenesisHash[32]byte
18PayoutsEnabledbool
19PayoutsGoOnlineFeeuint64
20PayoutsPercentuint64
21PayoutsMinBalanceuint64
22PayoutsMaxBalanceuint64
0x33
gtxn
-
any
SizeAvailabilityDoc Cost
3v11
Description

field F of the Tth transaction in the current group

Groups

Loading Values

Notes

for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`.

Immediate Notes
CommentEncodingNameReference
transaction group indexuint8T
transaction field indexuint8Ftxn
Argument Details
IndexArgumentType
0Senderaddress
1Feeuint64
2FirstValiduint64
3FirstValidTimeuint64
4LastValiduint64
5Note[]byte
6Lease[32]byte
7Receiveraddress
8Amountuint64
9CloseRemainderToaddress
10VotePK[32]byte
11SelectionPK[32]byte
12VoteFirstuint64
13VoteLastuint64
14VoteKeyDilutionuint64
15Type[]byte
16TypeEnumuint64
17XferAssetuint64
18AssetAmountuint64
19AssetSenderaddress
20AssetReceiveraddress
21AssetCloseToaddress
22GroupIndexuint64
23TxID[32]byte
24ApplicationIDuint64
25OnCompletionuint64
26ApplicationArgs[]byte
27NumAppArgsuint64
28Accountsaddress
29NumAccountsuint64
30ApprovalProgram[]byte
31ClearStateProgram[]byte
32RekeyToaddress
33ConfigAssetuint64
34ConfigAssetTotaluint64
35ConfigAssetDecimalsuint64
36ConfigAssetDefaultFrozenbool
37ConfigAssetUnitName[]byte
38ConfigAssetName[]byte
39ConfigAssetURL[]byte
40ConfigAssetMetadataHash[32]byte
41ConfigAssetManageraddress
42ConfigAssetReserveaddress
43ConfigAssetFreezeaddress
44ConfigAssetClawbackaddress
45FreezeAssetuint64
46FreezeAssetAccountaddress
47FreezeAssetFrozenbool
48Assetsuint64
49NumAssetsuint64
50Applicationsuint64
51NumApplicationsuint64
52GlobalNumUintuint64
53GlobalNumByteSliceuint64
54LocalNumUintuint64
55LocalNumByteSliceuint64
56ExtraProgramPagesuint64
57Nonparticipationbool
58Logs[]byte
59NumLogsuint64
60CreatedAssetIDuint64
61CreatedApplicationIDuint64
62LastLog[]byte
63StateProofPK[]byte
64ApprovalProgramPages[]byte
65NumApprovalProgramPagesuint64
66ClearStateProgramPages[]byte
67NumClearStateProgramPagesuint64
0x34
load
-
any
SizeAvailabilityDoc Cost
2v11
Description

Ith scratch space value. All scratch spaces are 0 at program start.

Groups

Loading Values

Immediate Notes
CommentEncodingName
position in scratch space to load fromuint8I
0x35
store
any
-
SizeAvailabilityDoc Cost
2v11
Description

store A to the Ith scratch space

Groups

Loading Values

Immediate Notes
CommentEncodingName
position in scratch space to store touint8I
0x36
txna
-
any
SizeAvailabilityDoc Cost
3v21
Description

Ith value of the array field F of the current transaction `txna` can be called using `txn` with 2 immediates.

Groups

Loading Values

Immediate Notes
CommentEncodingNameReference
transaction field indexuint8Ftxna
transaction field array indexuint8I
Argument Details
IndexArgumentType
0ApplicationArgs[]byte
1Accountsaddress
2Assetsuint64
3Applicationsuint64
4Logs[]byte
5ApprovalProgramPages[]byte
6ClearStateProgramPages[]byte
0x37
gtxna
-
any
SizeAvailabilityDoc Cost
4v21
Description

Ith value of the array field F from the Tth transaction in the current group `gtxna` can be called using `gtxn` with 3 immediates.

Groups

Loading Values

Immediate Notes
CommentEncodingNameReference
transaction group indexuint8T
transaction field indexuint8Ftxna
transaction field array indexuint8I
Argument Details
IndexArgumentType
0ApplicationArgs[]byte
1Accountsaddress
2Assetsuint64
3Applicationsuint64
4Logs[]byte
5ApprovalProgramPages[]byte
6ClearStateProgramPages[]byte
0x38
gtxns
uint64
any
SizeAvailabilityDoc Cost
2v31
Description

field F of the Ath transaction in the current group

Groups

Loading Values

Notes

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.

Immediate Notes
CommentEncodingNameReference
transaction field indexuint8Ftxn
Argument Details
IndexArgumentType
0Senderaddress
1Feeuint64
2FirstValiduint64
3FirstValidTimeuint64
4LastValiduint64
5Note[]byte
6Lease[32]byte
7Receiveraddress
8Amountuint64
9CloseRemainderToaddress
10VotePK[32]byte
11SelectionPK[32]byte
12VoteFirstuint64
13VoteLastuint64
14VoteKeyDilutionuint64
15Type[]byte
16TypeEnumuint64
17XferAssetuint64
18AssetAmountuint64
19AssetSenderaddress
20AssetReceiveraddress
21AssetCloseToaddress
22GroupIndexuint64
23TxID[32]byte
24ApplicationIDuint64
25OnCompletionuint64
26ApplicationArgs[]byte
27NumAppArgsuint64
28Accountsaddress
29NumAccountsuint64
30ApprovalProgram[]byte
31ClearStateProgram[]byte
32RekeyToaddress
33ConfigAssetuint64
34ConfigAssetTotaluint64
35ConfigAssetDecimalsuint64
36ConfigAssetDefaultFrozenbool
37ConfigAssetUnitName[]byte
38ConfigAssetName[]byte
39ConfigAssetURL[]byte
40ConfigAssetMetadataHash[32]byte
41ConfigAssetManageraddress
42ConfigAssetReserveaddress
43ConfigAssetFreezeaddress
44ConfigAssetClawbackaddress
45FreezeAssetuint64
46FreezeAssetAccountaddress
47FreezeAssetFrozenbool
48Assetsuint64
49NumAssetsuint64
50Applicationsuint64
51NumApplicationsuint64
52GlobalNumUintuint64
53GlobalNumByteSliceuint64
54LocalNumUintuint64
55LocalNumByteSliceuint64
56ExtraProgramPagesuint64
57Nonparticipationbool
58Logs[]byte
59NumLogsuint64
60CreatedAssetIDuint64
61CreatedApplicationIDuint64
62LastLog[]byte
63StateProofPK[]byte
64ApprovalProgramPages[]byte
65NumApprovalProgramPagesuint64
66ClearStateProgramPages[]byte
67NumClearStateProgramPagesuint64
0x39
gtxnsa
uint64
any
SizeAvailabilityDoc Cost
3v31
Description

Ith value of the array field F from the Ath transaction in the current group `gtxnsa` can be called using `gtxns` with 2 immediates.

Groups

Loading Values

Immediate Notes
CommentEncodingNameReference
transaction field indexuint8Ftxna
transaction field array indexuint8I
Argument Details
IndexArgumentType
0ApplicationArgs[]byte
1Accountsaddress
2Assetsuint64
3Applicationsuint64
4Logs[]byte
5ApprovalProgramPages[]byte
6ClearStateProgramPages[]byte
0x3a
gload
-
any
SizeAvailabilityDoc Cost
3v41
Description

Ith scratch space value of the Tth transaction in the current group

Groups

Loading Values

Notes

`gload` fails unless the requested transaction is an ApplicationCall and T < GroupIndex.

Immediate Notes
CommentEncodingName
transaction group indexuint8T
position in scratch space to load fromuint8I
0x3b
gloads
uint64
any
SizeAvailabilityDoc Cost
2v41
Description

Ith scratch space value of the Ath transaction in the current group

Groups

Loading Values

Notes

`gloads` fails unless the requested transaction is an ApplicationCall and A < GroupIndex.

Immediate Notes
CommentEncodingName
position in scratch space to load fromuint8I
0x3c
gaid
-
uint64
SizeAvailabilityDoc Cost
2v41
Description

ID of the asset or application created in the Tth transaction of the current group

Groups

Loading Values

Notes

`gaid` fails unless the requested transaction created an asset or application and T < GroupIndex.

Immediate Notes
CommentEncodingName
transaction group indexuint8T
0x3d
gaids
uint64
uint64
SizeAvailabilityDoc Cost
1v41
Description

ID of the asset or application created in the Ath transaction of the current group

Groups

Loading Values

Notes

`gaids` fails unless the requested transaction created an asset or application and A < GroupIndex.

0x3e
loads
uint64
any
SizeAvailabilityDoc Cost
1v51
Description

Ath scratch space value. All scratch spaces are 0 at program start.

Groups

Loading Values

0x3f
stores
uint64
any
-
SizeAvailabilityDoc Cost
1v51
Description

store B to the Ath scratch space

Groups

Loading Values

0x40
bnz
uint64
-
SizeAvailabilityDoc Cost
3v11
Description

branch to TARGET if value A is not zero

Groups

Flow Control

Notes

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

Immediate Notes
CommentEncodingName
branch offsetint16 (big-endian)TARGET
0x41
bz
uint64
-
SizeAvailabilityDoc Cost
3v21
Description

branch to TARGET if value A is zero

Groups

Flow Control

Notes

See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`.

Immediate Notes
CommentEncodingName
branch offsetint16 (big-endian)TARGET
0x42
b
-
-
SizeAvailabilityDoc Cost
3v21
Description

branch unconditionally to TARGET

Groups

Flow Control

Notes

See `bnz` for details on how branches work. `b` always jumps to the offset.

Immediate Notes
CommentEncodingName
branch offsetint16 (big-endian)TARGET
0x43
return
uint64
-
SizeAvailabilityDoc Cost
1v21
Description

use A as success value; end

Groups

Flow Control

0x44
assert
uint64
-
SizeAvailabilityDoc Cost
1v31
Description

immediately fail unless A is a non-zero number

Groups

Flow Control

0x45
bury
any
-
SizeAvailabilityDoc Cost
2v81
Description

replace the Nth value from the top of the stack with A. bury 0 fails.

Groups

Flow Control

Immediate Notes
CommentEncodingName
depthuint8N
0x46
popn
-
-
SizeAvailabilityDoc Cost
2v81
Description

remove N values from the top of the stack

Groups

Flow Control

Immediate Notes
CommentEncodingName
stack depthuint8N
0x47
dupn
any
-
SizeAvailabilityDoc Cost
2v81
Description

duplicate A, N times

Groups

Flow Control

Immediate Notes
CommentEncodingName
copy countuint8N
0x48
pop
any
-
SizeAvailabilityDoc Cost
1v11
Description

discard A

Groups

Flow Control

0x49
dup
any
any
any
SizeAvailabilityDoc Cost
1v11
Description

duplicate A

Groups

Flow Control

0x4a
dup2
any
any
any
any
any
any
SizeAvailabilityDoc Cost
1v21
Description

duplicate A and B

Groups

Flow Control

0x4b
dig
any
any
any
SizeAvailabilityDoc Cost
2v31
Description

Nth value from the top of the stack. dig 0 is equivalent to dup

Groups

Flow Control

Immediate Notes
CommentEncodingName
depthuint8N
0x4c
swap
any
any
any
any
SizeAvailabilityDoc Cost
1v31
Description

swaps A and B on stack

Groups

Flow Control

0x4d
select
any
any
uint64
any
SizeAvailabilityDoc Cost
1v31
Description

selects one of two values based on top-of-stack: B if C != 0, else A

Groups

Flow Control

0x4e
cover
any
any
SizeAvailabilityDoc Cost
2v51
Description

remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth <= N.

Groups

Flow Control

Immediate Notes
CommentEncodingName
depthuint8N
0x4f
uncover
any
any
SizeAvailabilityDoc Cost
2v51
Description

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.

Groups

Flow Control

Immediate Notes
CommentEncodingName
depthuint8N
0x50
concat
[]byte
[]byte
[]byte
SizeAvailabilityDoc Cost
1v21
Description

join A and B

Groups

Byte Array Manipulation

Notes

`concat` fails if the result would be greater than 4096 bytes.

0x51
substring
[]byte
[]byte
SizeAvailabilityDoc Cost
3v21
Description

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

Groups

Byte Array Manipulation

Immediate Notes
CommentEncodingName
start positionuint8S
end positionuint8E
0x52
substring3
[]byte
uint64
uint64
[]byte
SizeAvailabilityDoc Cost
1v21
Description

A range of bytes from A starting at B up to but not including C. If C < B, or either is larger than the array length, the program fails

Groups

Byte Array Manipulation

0x53
getbit
any
uint64
uint64
SizeAvailabilityDoc Cost
1v31
Description

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

Groups

Byte Array Manipulation

Notes

see explanation of bit ordering in setbit

0x54
setbit
any
uint64
uint64
any
SizeAvailabilityDoc Cost
1v31
Description

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

Groups

Byte Array Manipulation

Notes

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.

0x55
getbyte
[]byte
uint64
uint64
SizeAvailabilityDoc Cost
1v31
Description

Bth byte of A, as an integer. If B is greater than or equal to the array length, the program fails

Groups

Byte Array Manipulation

0x56
setbyte
[]byte
uint64
uint64
[]byte
SizeAvailabilityDoc Cost
1v31
Description

Copy of A with the Bth byte set to small integer (between 0..255) C. If B is greater than or equal to the array length, the program fails

Groups

Byte Array Manipulation

0x57
extract
[]byte
[]byte
SizeAvailabilityDoc Cost
3v51
Description

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

Groups

Byte Array Manipulation

Immediate Notes
CommentEncodingName
start positionuint8S
lengthuint8L
0x58
extract3
[]byte
uint64
uint64
[]byte
SizeAvailabilityDoc Cost
1v51
Description

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.

Groups

Byte Array Manipulation

0x59
extract_uint16
[]byte
uint64
uint64
SizeAvailabilityDoc Cost
1v51
Description

A uint16 formed from a range of big-endian bytes from A starting at B up to but not including B+2. If B+2 is larger than the array length, the program fails

Groups

Byte Array Manipulation

0x5a
extract_uint32
[]byte
uint64
uint64
SizeAvailabilityDoc Cost
1v51
Description

A uint32 formed from a range of big-endian bytes from A starting at B up to but not including B+4. If B+4 is larger than the array length, the program fails

Groups

Byte Array Manipulation

0x5b
extract_uint64
[]byte
uint64
uint64
SizeAvailabilityDoc Cost
1v51
Description

A uint64 formed from a range of big-endian bytes from A starting at B up to but not including B+8. If B+8 is larger than the array length, the program fails

Groups

Byte Array Manipulation

0x5c
replace2
[]byte
[]byte
[]byte
SizeAvailabilityDoc Cost
2v71
Description

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.

Groups

Byte Array Manipulation

Immediate Notes
CommentEncodingName
start positionuint8S
0x5d
replace3
[]byte
uint64
[]byte
[]byte
SizeAvailabilityDoc Cost
1v71
Description

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.

Groups

Byte Array Manipulation

0x5e
base64_decode
[]byte
[]byte
SizeAvailabilityDoc Cost
2v71 + 1 per 16 bytes of A
Description

decode A which was base64-encoded using _encoding_ E. Fail if A is not base64 encoded with encoding E

Groups

Byte Array Manipulation

Notes

*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`.

Immediate Notes
CommentEncodingNameReference
encoding indexuint8Ebase64
Argument Details
IndexArgumentType
0URLEncodingany
1StdEncodingany
0x5f
json_ref
[]byte
[]byte
any
SizeAvailabilityDoc Cost
2v725 + 2 per 7 bytes of A
Description

key B's value, of type R, from a [valid](jsonspec.md) utf-8 encoded json object A

Groups

Byte Array Manipulation

Notes

*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.

Immediate Notes
CommentEncodingNameReference
return type indexuint8Rjson_ref
Argument Details
IndexArgumentType
0JSONString[]byte
1JSONUint64uint64
2JSONObject[]byte
0x60
balance
any
uint64
SizeAvailabilityDoc Cost
1v21
Description

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`

Groups

State Access

Notes

params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value.

0x61
app_opted_in
any
uint64
bool
SizeAvailabilityDoc Cost
1v21
Description

1 if account A is opted in to application B, else 0

Groups

State Access

Notes

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.

0x62
app_local_get
any
stateKey
any
SizeAvailabilityDoc Cost
1v21
Description

local state of the key B in the current application in account A

Groups

State Access

Notes

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.

0x63
app_local_get_ex
any
uint64
stateKey
any
bool
SizeAvailabilityDoc Cost
1v21
Description

X is the local state of application B, key C in account A. Y is 1 if key existed, else 0

Groups

State Access

Notes

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.

0x64
app_global_get
stateKey
any
SizeAvailabilityDoc Cost
1v21
Description

global state of the key A in the current application

Groups

State Access

Notes

params: state key. Return: value. The value is zero (of type uint64) if the key does not exist.

0x65
app_global_get_ex
uint64
stateKey
any
bool
SizeAvailabilityDoc Cost
1v21
Description

X is the global state of application A, key B. Y is 1 if key existed, else 0

Groups

State Access

Notes

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.

0x66
app_local_put
any
stateKey
any
-
SizeAvailabilityDoc Cost
1v21
Description

write C to key B in account A's local state of the current application

Groups

State Access

Notes

params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value.

0x67
app_global_put
stateKey
any
-
SizeAvailabilityDoc Cost
1v21
Description

write B to key A in the global state of the current application

Groups

State Access

0x68
app_local_del
any
stateKey
-
SizeAvailabilityDoc Cost
1v21
Description

delete key B from account A's local state of the current application

Groups

State Access

Notes

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

0x69
app_global_del
stateKey
-
SizeAvailabilityDoc Cost
1v21
Description

delete key A from the global state of the current application

Groups

State Access

Notes

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

0x70
asset_holding_get
any
uint64
any
bool
SizeAvailabilityDoc Cost
2v21
Description

X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0

Groups

State Access

Notes

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.

Immediate Notes
CommentEncodingNameReference
asset holding field indexuint8Fasset_holding
Argument Details
IndexArgumentType
0AssetBalanceuint64
1AssetFrozenbool
0x71
asset_params_get
uint64
any
bool
SizeAvailabilityDoc Cost
2v21
Description

X is field F from asset A. Y is 1 if A exists, else 0

Groups

State Access

Notes

params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value.

Immediate Notes
CommentEncodingNameReference
asset params field indexuint8Fasset_params
Argument Details
IndexArgumentType
0AssetTotaluint64
1AssetDecimalsuint64
2AssetDefaultFrozenbool
3AssetUnitName[]byte
4AssetName[]byte
5AssetURL[]byte
6AssetMetadataHash[32]byte
7AssetManageraddress
8AssetReserveaddress
9AssetFreezeaddress
10AssetClawbackaddress
11AssetCreatoraddress
0x72
app_params_get
uint64
any
bool
SizeAvailabilityDoc Cost
2v51
Description

X is field F from app A. Y is 1 if A exists, else 0

Groups

State Access

Notes

params: Txn.ForeignApps offset or an _available_ app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value.

Immediate Notes
CommentEncodingNameReference
app params field indexuint8Fapp_params
Argument Details
IndexArgumentType
0AppApprovalProgram[]byte
1AppClearStateProgram[]byte
2AppGlobalNumUintuint64
3AppGlobalNumByteSliceuint64
4AppLocalNumUintuint64
5AppLocalNumByteSliceuint64
6AppExtraProgramPagesuint64
7AppCreatoraddress
8AppAddressaddress
0x73
acct_params_get
any
any
bool
SizeAvailabilityDoc Cost
2v61
Description

X is field F from account A. Y is 1 if A owns positive algos, else 0

Groups

State Access

Immediate Notes
CommentEncodingNameReference
account params field indexuint8Facct_params
Argument Details
IndexArgumentType
0AcctBalanceuint64
1AcctMinBalanceuint64
2AcctAuthAddraddress
3AcctTotalNumUintuint64
4AcctTotalNumByteSliceuint64
5AcctTotalExtraAppPagesuint64
6AcctTotalAppsCreateduint64
7AcctTotalAppsOptedInuint64
8AcctTotalAssetsCreateduint64
9AcctTotalAssetsuint64
10AcctTotalBoxesuint64
11AcctTotalBoxBytesuint64
12AcctIncentiveEligiblebool
13AcctLastProposeduint64
14AcctLastHeartbeatuint64
0x74
voter_params_get
any
any
bool
SizeAvailabilityDoc Cost
2v111
Description

X is field F from online account A as of the balance round: 320 rounds before the current round. Y is 1 if A had positive algos online in the agreement round, else Y is 0 and X is a type specific zero-value

Groups

State Access

Immediate Notes
CommentEncodingNameReference
voter params field indexuint8Fvoter_params
0x75
online_stake
-
uint64
SizeAvailabilityDoc Cost
1v111
Description

the total online stake in the agreement round

Groups

State Access

0x78
min_balance
any
uint64
SizeAvailabilityDoc Cost
1v31
Description

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.

Groups

State Access

Notes

params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value.

0x80
pushbytes
-
[]byte
SizeAvailabilityDoc Cost
0v31
Description

immediate BYTES

Groups

Loading Values

Notes

pushbytes args are not added to the bytecblock during assembly processes

Immediate Notes
CommentEncodingName
a byte constantvaruint length, bytesBYTES
0x81
pushint
-
uint64
SizeAvailabilityDoc Cost
0v31
Description

immediate UINT

Groups

Loading Values

Notes

pushint args are not added to the intcblock during assembly processes

Immediate Notes
CommentEncodingName
an int constantvaruintUINT
0x82
pushbytess
-
-
SizeAvailabilityDoc Cost
0v81
Description

push sequences of immediate byte arrays to stack (first byte array being deepest)

Groups

Loading Values

Notes

pushbytess args are not added to the bytecblock during assembly processes

Immediate Notes
CommentEncodingName
a list of byte constantsvaruint count, [varuint length, bytes ...]BYTES ...
0x83
pushints
-
-
SizeAvailabilityDoc Cost
0v81
Description

push sequence of immediate uints to stack in the order they appear (first uint being deepest)

Groups

Loading Values

Notes

pushints args are not added to the intcblock during assembly processes

Immediate Notes
CommentEncodingName
a list of int constantsvaruint count, [varuint ...]UINT ...
0x84
ed25519verify_bare
[]byte
[64]byte
[32]byte
bool
SizeAvailabilityDoc Cost
1v71900
Description

for (data A, signature B, pubkey C) verify the signature of the data against the pubkey => {0 or 1}

Groups

Cryptography

0x88
callsub
-
-
SizeAvailabilityDoc Cost
3v41
Description

branch unconditionally to TARGET, saving the next instruction on the call stack

Groups

Flow Control

Notes

The call stack is separate from the data stack. Only `callsub`, `retsub`, and `proto` manipulate it.

Immediate Notes
CommentEncodingName
branch offsetint16 (big-endian)TARGET
0x89
retsub
-
-
SizeAvailabilityDoc Cost
1v41
Description

pop the top instruction from the call stack and branch to it

Groups

Flow Control

Notes

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.

0x8a
proto
-
-
SizeAvailabilityDoc Cost
3v81
Description

Prepare top call frame for a retsub that will assume A args and R return values.

Groups

Flow Control

Notes

Fails unless the last instruction executed was a `callsub`.

Immediate Notes
CommentEncodingName
number of argumentsuint8A
number of return valuesuint8R
0x8b
frame_dig
-
any
SizeAvailabilityDoc Cost
2v81
Description

Nth (signed) value from the frame pointer.

Groups

Flow Control

Immediate Notes
CommentEncodingName
frame slotint8I
0x8c
frame_bury
any
-
SizeAvailabilityDoc Cost
2v81
Description

replace the Nth (signed) value from the frame pointer in the stack with A

Groups

Flow Control

Immediate Notes
CommentEncodingName
frame slotint8I
0x8d
switch
uint64
-
SizeAvailabilityDoc Cost
0v81
Description

branch to the Ath label. Continue at following instruction if index A exceeds the number of labels.

Groups

Flow Control

Immediate Notes
CommentEncodingName
list of labelsvaruint count, [int16 (big-endian) ...]TARGET ...
0x8e
match
-
-
SizeAvailabilityDoc Cost
0v81
Description

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.

Groups

Flow Control

Notes

`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.

Immediate Notes
CommentEncodingName
list of labelsvaruint count, [int16 (big-endian) ...]TARGET ...
0x90
shl
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v41
Description

A times 2^B, modulo 2^64

Groups

Arithmetic

0x91
shr
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v41
Description

A divided by 2^B

Groups

Arithmetic

0x92
sqrt
uint64
uint64
SizeAvailabilityDoc Cost
1v44
Description

The largest integer I such that I^2 <= A

Groups

Arithmetic

0x93
bitlen
any
uint64
SizeAvailabilityDoc Cost
1v41
Description

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

Groups

Arithmetic

Notes

bitlen interprets arrays as big-endian integers, unlike setbit/getbit

0x94
exp
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v41
Description

A raised to the Bth power. Fail if A == B == 0 and on overflow

Groups

Arithmetic

0x95
expw
uint64
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v410
Description

A raised to the Bth power as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low. Fail if A == B == 0 or if the results exceeds 2^128-1

Groups

Arithmetic

0x96
bsqrt
bigint
bigint
SizeAvailabilityDoc Cost
1v640
Description

The largest integer I such that I^2 <= A. A and I are interpreted as big-endian unsigned integers

Groups

Byte Array Arithmetic

0x97
divw
uint64
uint64
uint64
uint64
SizeAvailabilityDoc Cost
1v61
Description

A,B / C. Fail if C == 0 or if result overflows.

Groups

Arithmetic

Notes

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.

0x98
sha3_256
[]byte
[32]byte
SizeAvailabilityDoc Cost
1v7130
Description

SHA3_256 hash of value A, yields [32]byte

Groups

Cryptography

0xa0
b+
bigint
bigint
[]byte
SizeAvailabilityDoc Cost
1v410
Description

A plus B. A and B are interpreted as big-endian unsigned integers

Groups

Byte Array Arithmetic

0xa1
b-
bigint
bigint
bigint
SizeAvailabilityDoc Cost
1v410
Description

A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.

Groups

Byte Array Arithmetic

0xa2
b/
bigint
bigint
bigint
SizeAvailabilityDoc Cost
1v420
Description

A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.

Groups

Byte Array Arithmetic

0xa3
b*
bigint
bigint
[]byte
SizeAvailabilityDoc Cost
1v420
Description

A times B. A and B are interpreted as big-endian unsigned integers.

Groups

Byte Array Arithmetic

0xa4
b<
bigint
bigint
bool
SizeAvailabilityDoc Cost
1v41
Description

1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers

Groups

Byte Array Arithmetic

0xa5
b>
bigint
bigint
bool
SizeAvailabilityDoc Cost
1v41
Description

1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers

Groups

Byte Array Arithmetic

0xa6
b<=
bigint
bigint
bool
SizeAvailabilityDoc Cost
1v41
Description

1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers

Groups

Byte Array Arithmetic

0xa7
b>=
bigint
bigint
bool
SizeAvailabilityDoc Cost
1v41
Description

1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers

Groups

Byte Array Arithmetic

0xa8
b==
bigint
bigint
bool
SizeAvailabilityDoc Cost
1v41
Description

1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers

Groups

Byte Array Arithmetic

0xa9
b!=
bigint
bigint
bool
SizeAvailabilityDoc Cost
1v41
Description

0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers

Groups

Byte Array Arithmetic

0xaa
b%
bigint
bigint
bigint
SizeAvailabilityDoc Cost
1v420
Description

A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.

Groups

Byte Array Arithmetic

0xab
b|
[]byte
[]byte
[]byte
SizeAvailabilityDoc Cost
1v46
Description

A bitwise-or B. A and B are zero-left extended to the greater of their lengths

Groups

Byte Array Logic

0xac
b&
[]byte
[]byte
[]byte
SizeAvailabilityDoc Cost
1v46
Description

A bitwise-and B. A and B are zero-left extended to the greater of their lengths

Groups

Byte Array Logic

0xad
b^
[]byte
[]byte
[]byte
SizeAvailabilityDoc Cost
1v46
Description

A bitwise-xor B. A and B are zero-left extended to the greater of their lengths

Groups

Byte Array Logic

0xae
b~
[]byte
[]byte
SizeAvailabilityDoc Cost
1v44
Description

A with all bits inverted

Groups

Byte Array Logic

0xaf
bzero
uint64
[]byte
SizeAvailabilityDoc Cost
1v41
Description

zero filled byte-array of length A

Groups

Loading Values

0xb0
log
[]byte
-
SizeAvailabilityDoc Cost
1v51
Description

write A to log state of the current application

Groups

State Access

Notes

`log` fails if called more than MaxLogCalls times in a program, or if the sum of logged bytes exceeds 1024 bytes.

0xb1
itxn_begin
-
-
SizeAvailabilityDoc Cost
1v51
Description

begin preparation of a new inner transaction in a new transaction group

Groups

Inner Transactions

Notes

`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.

0xb2
itxn_field
any
-
SizeAvailabilityDoc Cost
2v51
Description

set field F of the current inner transaction to A

Groups

Inner Transactions

Notes

`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_.)

Immediate Notes
CommentEncodingNameReference
transaction field indexuint8Ftxn
Argument Details
IndexArgumentType
0Senderaddress
1Feeuint64
2Note[]byte
3Receiveraddress
4Amountuint64
5CloseRemainderToaddress
6VotePK[32]byte
7SelectionPK[32]byte
8VoteFirstuint64
9VoteLastuint64
10VoteKeyDilutionuint64
11Type[]byte
12TypeEnumuint64
13XferAssetuint64
14AssetAmountuint64
15AssetSenderaddress
16AssetReceiveraddress
17AssetCloseToaddress
18ApplicationIDuint64
19OnCompletionuint64
20ApplicationArgs[]byte
21Accountsaddress
22ApprovalProgram[]byte
23ClearStateProgram[]byte
24RekeyToaddress
25ConfigAssetuint64
26ConfigAssetTotaluint64
27ConfigAssetDecimalsuint64
28ConfigAssetDefaultFrozenbool
29ConfigAssetUnitName[]byte
30ConfigAssetName[]byte
31ConfigAssetURL[]byte
32ConfigAssetMetadataHash[32]byte
33ConfigAssetManageraddress
34ConfigAssetReserveaddress
35ConfigAssetFreezeaddress
36ConfigAssetClawbackaddress
37FreezeAssetuint64
38FreezeAssetAccountaddress
39FreezeAssetFrozenbool
40Assetsuint64
41Applicationsuint64
42GlobalNumUintuint64
43GlobalNumByteSliceuint64
44LocalNumUintuint64
45LocalNumByteSliceuint64
46ExtraProgramPagesuint64
47Nonparticipationbool
48StateProofPK[]byte
49ApprovalProgramPages[]byte
50ClearStateProgramPages[]byte
0xb3
itxn_submit
-
-
SizeAvailabilityDoc Cost
1v51
Description

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.

Groups

Inner Transactions

Notes

`itxn_submit` resets the current transaction so that it can not be resubmitted. A new `itxn_begin` is required to prepare another inner transaction.

0xb4
itxn
-
any
SizeAvailabilityDoc Cost
2v51
Description

field F of the last inner transaction

Groups

Inner Transactions

Immediate Notes
CommentEncodingNameReference
transaction field indexuint8Ftxn
Argument Details
IndexArgumentType
0Senderaddress
1Feeuint64
2FirstValiduint64
3FirstValidTimeuint64
4LastValiduint64
5Note[]byte
6Lease[32]byte
7Receiveraddress
8Amountuint64
9CloseRemainderToaddress
10VotePK[32]byte
11SelectionPK[32]byte
12VoteFirstuint64
13VoteLastuint64
14VoteKeyDilutionuint64
15Type[]byte
16TypeEnumuint64
17XferAssetuint64
18AssetAmountuint64
19AssetSenderaddress
20AssetReceiveraddress
21AssetCloseToaddress
22GroupIndexuint64
23TxID[32]byte
24ApplicationIDuint64
25OnCompletionuint64
26ApplicationArgs[]byte
27NumAppArgsuint64
28Accountsaddress
29NumAccountsuint64
30ApprovalProgram[]byte
31ClearStateProgram[]byte
32RekeyToaddress
33ConfigAssetuint64
34ConfigAssetTotaluint64
35ConfigAssetDecimalsuint64
36ConfigAssetDefaultFrozenbool
37ConfigAssetUnitName[]byte
38ConfigAssetName[]byte
39ConfigAssetURL[]byte
40ConfigAssetMetadataHash[32]byte
41ConfigAssetManageraddress
42ConfigAssetReserveaddress
43ConfigAssetFreezeaddress
44ConfigAssetClawbackaddress
45FreezeAssetuint64
46FreezeAssetAccountaddress
47FreezeAssetFrozenbool
48Assetsuint64
49NumAssetsuint64
50Applicationsuint64
51NumApplicationsuint64
52GlobalNumUintuint64
53GlobalNumByteSliceuint64
54LocalNumUintuint64
55LocalNumByteSliceuint64
56ExtraProgramPagesuint64
57Nonparticipationbool
58Logs[]byte
59NumLogsuint64
60CreatedAssetIDuint64
61CreatedApplicationIDuint64
62LastLog[]byte
63StateProofPK[]byte
64ApprovalProgramPages[]byte
65NumApprovalProgramPagesuint64
66ClearStateProgramPages[]byte
67NumClearStateProgramPagesuint64
0xb5
itxna
-
any
SizeAvailabilityDoc Cost
3v51
Description

Ith value of the array field F of the last inner transaction

Groups

Inner Transactions

Immediate Notes
CommentEncodingNameReference
transaction field indexuint8Ftxna
a transaction field array indexuint8I
Argument Details
IndexArgumentType
0ApplicationArgs[]byte
1Accountsaddress
2Assetsuint64
3Applicationsuint64
4Logs[]byte
5ApprovalProgramPages[]byte
6ClearStateProgramPages[]byte
0xb6
itxn_next
-
-
SizeAvailabilityDoc Cost
1v61
Description

begin preparation of a new inner transaction in the same transaction group

Groups

Inner Transactions

Notes

`itxn_next` initializes the transaction exactly as `itxn_begin` does

0xb7
gitxn
-
any
SizeAvailabilityDoc Cost
3v61
Description

field F of the Tth transaction in the last inner group submitted

Groups

Inner Transactions

Immediate Notes
CommentEncodingNameReference
transaction group indexuint8T
transaction field indexuint8Ftxn
Argument Details
IndexArgumentType
0Senderaddress
1Feeuint64
2FirstValiduint64
3FirstValidTimeuint64
4LastValiduint64
5Note[]byte
6Lease[32]byte
7Receiveraddress
8Amountuint64
9CloseRemainderToaddress
10VotePK[32]byte
11SelectionPK[32]byte
12VoteFirstuint64
13VoteLastuint64
14VoteKeyDilutionuint64
15Type[]byte
16TypeEnumuint64
17XferAssetuint64
18AssetAmountuint64
19AssetSenderaddress
20AssetReceiveraddress
21AssetCloseToaddress
22GroupIndexuint64
23TxID[32]byte
24ApplicationIDuint64
25OnCompletionuint64
26ApplicationArgs[]byte
27NumAppArgsuint64
28Accountsaddress
29NumAccountsuint64
30ApprovalProgram[]byte
31ClearStateProgram[]byte
32RekeyToaddress
33ConfigAssetuint64
34ConfigAssetTotaluint64
35ConfigAssetDecimalsuint64
36ConfigAssetDefaultFrozenbool
37ConfigAssetUnitName[]byte
38ConfigAssetName[]byte
39ConfigAssetURL[]byte
40ConfigAssetMetadataHash[32]byte
41ConfigAssetManageraddress
42ConfigAssetReserveaddress
43ConfigAssetFreezeaddress
44ConfigAssetClawbackaddress
45FreezeAssetuint64
46FreezeAssetAccountaddress
47FreezeAssetFrozenbool
48Assetsuint64
49NumAssetsuint64
50Applicationsuint64
51NumApplicationsuint64
52GlobalNumUintuint64
53GlobalNumByteSliceuint64
54LocalNumUintuint64
55LocalNumByteSliceuint64
56ExtraProgramPagesuint64
57Nonparticipationbool
58Logs[]byte
59NumLogsuint64
60CreatedAssetIDuint64
61CreatedApplicationIDuint64
62LastLog[]byte
63StateProofPK[]byte
64ApprovalProgramPages[]byte
65NumApprovalProgramPagesuint64
66ClearStateProgramPages[]byte
67NumClearStateProgramPagesuint64
0xb8
gitxna
-
any
SizeAvailabilityDoc Cost
4v61
Description

Ith value of the array field F from the Tth transaction in the last inner group submitted

Groups

Inner Transactions

Immediate Notes
CommentEncodingNameReference
transaction group indexuint8T
transaction field indexuint8Ftxna
transaction field array indexuint8I
Argument Details
IndexArgumentType
0ApplicationArgs[]byte
1Accountsaddress
2Assetsuint64
3Applicationsuint64
4Logs[]byte
5ApprovalProgramPages[]byte
6ClearStateProgramPages[]byte
0xb9
box_create
boxName
uint64
bool
SizeAvailabilityDoc Cost
1v81
Description

create a box named A, of length B. Fail if the name A is empty or B exceeds 32,768. Returns 0 if A already existed, else 1

Groups

Box Access

Notes

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`.

0xba
box_extract
boxName
uint64
uint64
[]byte
SizeAvailabilityDoc Cost
1v81
Description

read C bytes from box A, starting at offset B. Fail if A does not exist, or the byte range is outside A's size.

Groups

Box Access

0xbb
box_replace
boxName
uint64
[]byte
-
SizeAvailabilityDoc Cost
1v81
Description

write byte-array C into box A, starting at offset B. Fail if A does not exist, or the byte range is outside A's size.

Groups

Box Access

0xbc
box_del
boxName
bool
SizeAvailabilityDoc Cost
1v81
Description

delete box named A if it exists. Return 1 if A existed, 0 otherwise

Groups

Box Access

0xbd
box_len
boxName
uint64
bool
SizeAvailabilityDoc Cost
1v81
Description

X is the length of box A if A exists, else 0. Y is 1 if A exists, else 0.

Groups

Box Access

0xbe
box_get
boxName
[]byte
bool
SizeAvailabilityDoc Cost
1v81
Description

X is the contents of box A if A exists, else ''. Y is 1 if A exists, else 0.

Groups

Box Access

Notes

For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `box_replace`

0xbf
box_put
boxName
[]byte
-
SizeAvailabilityDoc Cost
1v81
Description

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

Groups

Box Access

Notes

For boxes that exceed 4,096 bytes, consider `box_create`, `box_extract`, and `box_replace`

0xc0
txnas
uint64
any
SizeAvailabilityDoc Cost
2v51
Description

Ath value of the array field F of the current transaction

Groups

Loading Values

Immediate Notes
CommentEncodingNameReference
transaction field indexuint8Ftxna
Argument Details
IndexArgumentType
0ApplicationArgs[]byte
1Accountsaddress
2Assetsuint64
3Applicationsuint64
4Logs[]byte
5ApprovalProgramPages[]byte
6ClearStateProgramPages[]byte
0xc1
gtxnas
uint64
any
SizeAvailabilityDoc Cost
3v51
Description

Ath value of the array field F from the Tth transaction in the current group

Groups

Loading Values

Immediate Notes
CommentEncodingNameReference
transaction group indexuint8T
transaction field indexuint8Ftxna
Argument Details
IndexArgumentType
0ApplicationArgs[]byte
1Accountsaddress
2Assetsuint64
3Applicationsuint64
4Logs[]byte
5ApprovalProgramPages[]byte
6ClearStateProgramPages[]byte
0xc2
gtxnsas
uint64
uint64
any
SizeAvailabilityDoc Cost
2v51
Description

Bth value of the array field F from the Ath transaction in the current group

Groups

Loading Values

Immediate Notes
CommentEncodingNameReference
transaction field indexuint8Ftxna
Argument Details
IndexArgumentType
0ApplicationArgs[]byte
1Accountsaddress
2Assetsuint64
3Applicationsuint64
4Logs[]byte
5ApprovalProgramPages[]byte
6ClearStateProgramPages[]byte
0xc3
args
uint64
[]byte
SizeAvailabilityDoc Cost
1v51
Description

Ath LogicSig argument

Groups

Loading Values

0xc4
gloadss
uint64
uint64
any
SizeAvailabilityDoc Cost
1v61
Description

Bth scratch space value of the Ath transaction in the current group

Groups

Loading Values

0xc5
itxnas
uint64
any
SizeAvailabilityDoc Cost
2v61
Description

Ath value of the array field F of the last inner transaction

Groups

Inner Transactions

Immediate Notes
CommentEncodingNameReference
transaction field indexuint8Ftxna
0xc6
gitxnas
uint64
any
SizeAvailabilityDoc Cost
3v61
Description

Ath value of the array field F from the Tth transaction in the last inner group submitted

Groups

Inner Transactions

Immediate Notes
CommentEncodingNameReference
transaction group indexuint8T
transaction field indexuint8Ftxna
0xd0
vrf_verify
[]byte
[80]byte
[32]byte
[64]byte
bool
SizeAvailabilityDoc Cost
2v75700
Description

Verify the proof B of message A against pubkey C. Returns vrf output and verification flag.

Groups

Cryptography

Notes

`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/).

Immediate Notes
CommentEncodingNameReference
parameters indexuint8Svrf_verify
0xd1
block
uint64
any
SizeAvailabilityDoc Cost
2v71
Description

field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)

Groups

State Access

Immediate Notes
CommentEncodingNameReference
block field indexuint8Fblock
Argument Details
IndexArgumentType
0BlkSeed[32]byte
1BlkTimestampuint64
2BlkProposeraddress
3BlkFeesCollecteduint64
4BlkBonusuint64
5BlkBranch[32]byte
6BlkFeeSinkaddress
7BlkProtocol[]byte
8BlkTxnCounteruint64
9BlkProposerPayoutuint64
0xd2
box_splice
boxName
uint64
uint64
[]byte
-
SizeAvailabilityDoc Cost
1v101
Description

set box A to contain its previous bytes up to index B, followed by D, followed by the original bytes of A that began at index B+C.

Groups

Box Access

Notes

Boxes are of constant length. If C < len(D), then len(D)-C bytes will be removed from the end. If C > len(D), zero bytes will be appended to the end to reach the box length.

0xd3
box_resize
boxName
uint64
-
SizeAvailabilityDoc Cost
1v101
Description

change the size of box named A to be of length B, adding zero bytes to end or removing bytes from the end, as needed. Fail if the name A is empty, A is not an existing box, or B exceeds 32,768.

Groups

Box Access

0xe0
ec_add
[]byte
[]byte
[]byte
SizeAvailabilityDoc Cost
2v10BN254g1=125; BN254g2=170; BLS12_381g1=205; BLS12_381g2=290
Description

for curve points A and B, return the curve point A + B

Groups

Cryptography

Notes

A and B are curve points in affine representation: field element X concatenated with field element Y. Field element `Z` is encoded as follows. For the base field elements (Fp), `Z` is encoded as a big-endian number and must be lower than the field modulus. For 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). The point at infinity is encoded as `(X,Y) = (0,0)`. Groups G1 and G2 are denoted additively. Fails if A or B is not in G. A and/or B are allowed to be the point at infinity. Does _not_ check if A and B are in the main prime-order subgroup.

Immediate Notes
CommentEncodingNameReference
curve indexuint8GEC
0xe1
ec_scalar_mul
[]byte
[]byte
[]byte
SizeAvailabilityDoc Cost
2v10BN254g1=1810; BN254g2=3430; BLS12_381g1=2950; BLS12_381g2=6530
Description

for curve point A and scalar B, return the curve point BA, the point A multiplied by the scalar B.

Groups

Cryptography

Notes

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.

Immediate Notes
CommentEncodingNameReference
curve indexuint8GEC
0xe2
ec_pairing_check
[]byte
[]byte
bool
SizeAvailabilityDoc Cost
2v10BN254g1=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
Description

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

Groups

Cryptography

Notes

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.

Immediate Notes
CommentEncodingNameReference
curve indexuint8GEC
0xe3
ec_multi_scalar_mul
[]byte
[]byte
[]byte
SizeAvailabilityDoc Cost
2v10BN254g1=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
Description

for curve points A and scalars B, return curve point B0A0 + B1A1 + B2A2 + ... + BnAn

Groups

Cryptography

Notes

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. The 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.

Immediate Notes
CommentEncodingNameReference
curve indexuint8GEC
0xe4
ec_subgroup_check
[]byte
bool
SizeAvailabilityDoc Cost
2v10BN254g1=20; BN254g2=3100; BLS12_381g1=1850; BLS12_381g2=2340
Description

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.

Groups

Cryptography

Immediate Notes
CommentEncodingNameReference
curve indexuint8GEC
0xe5
ec_map_to
[]byte
[]byte
SizeAvailabilityDoc Cost
2v10BN254g1=630; BN254g2=3300; BLS12_381g1=1950; BLS12_381g2=8150
Description

maps field element A to group G

Groups

Cryptography

Notes

BN254 points are mapped by the SVDW map. BLS12-381 points are mapped by the SSWU map. G1 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.

Immediate Notes
CommentEncodingNameReference
curve indexuint8GEC
0xe6
mimc
[]byte
[32]byte
SizeAvailabilityDoc Cost
2v11BN254Mp110=10 + 550 per 32 bytes of A; BLS12_381Mp111=10 + 550 per 32 bytes of A
Description

MiMC hash of scalars A, using curve and parameters specified by configuration C

Groups

Cryptography

Notes

A is a list of concatenated 32 byte big-endian unsigned integer scalars. Fail if A's length is not a multiple of 32 or any element exceeds the curve modulus. The MiMC hash function has known collisions since any input which is a multiple of the elliptic curve modulus will hash to the same value. MiMC is thus not a general purpose hash function, but meant to be used in zero knowledge applications to match a zk-circuit implementation.

Immediate Notes
CommentEncodingNameReference
configuration indexuint8CMimc Configurations