TVM Instructions
This information is very low-level and could be hard to understand for newcomers. So feel free to read about it later.
Introduction
This document provides a list of TVM instructions along with their opcodes and mnemonics.
- TVM.pdf concept document for TON Virtual Machine (may include outdated information).
- TVM Retracer
Fift is a stack-based programming language designed to manage TON smart contracts. The Fift assembler is a Fift library that converts mnemonics of TVM instructions into their binary representation.
A description of Fift, including an introduction to the Fift assembler, can be found here.
This document specifies the corresponding mnemonic for each instruction.
Note the following:
- Fift is a stack-based language, therefore all the arguments of any instruction are written before it (e.g.
5 PUSHINT
,s0 s4 XCHG
). - Stack registers are denoted by
s0, s1, ..., s15
. Other stack registers (up to 255) are denoted byi s()
(e.g.100 s()
). - Control registers are denoted by
c0, c1, ..., c15
.
Gas prices
The gas price of each instruction is specified in this document. The basic gas price of an instruction is 10 + b
, where b
is the instruction length in bits. Some operations have additional fees:
- Parsing cells: Transforming a cell into a slice costs 100 gas units if the cell is loading for the first time and 25 for subsequent loads during the same transaction. For such instructions, two gas prices are specified (e.g.
CTOS
:118/43
). - Cell creation: 500 gas units.
- Throwing exceptions: 50 gas units. In this document the exception fee is only specified for an instruction if its primary purpose is to throw (e.g.
THROWIF
,FITS
). If the instruction only throws in some cases, two gas prices are specified (e.g.FITS
:26/76
). - Tuple creation: 1 gas unit for every tuple element.
- Implicit jumps: 10 gas units for an implicit jump, 5 gas units for an implicit back jump. This fee is not a part of any instruction.
- Moving stack elements between continuations: 1 gas unit per element, however moving the first 32 elements is free.
Quick search
A full machine-readable list of TVM instructions is available here.
Each section of TVM Instructions includes a built-in search component for finding opcodes specific to that section as well.
On this page, however, the search covers all existing opcodes, providing a comprehensive search option across the entire opcode range.
Feel free to use the search field below to find a specific instruction:
- Overview
- Stack Manipulation
- Tuple, List and Null
- Constants and Literals
- Arithmetic Operations
- Data Comparison
- Cell Manipulation
- Continuation and Control Flow
- Exception Generation and Handling
- Dictionary Manipulation
- Application-specific Primitives
- Miscellaneous
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
0i | s[i] XCHG0 |
| Interchanges s0 with s[i] , 1 <= i <= 15 . | 18 |
2i | s[i] PUSH |
| Pushes a copy of the old s[i] into the stack. | 18 |
D3cc | [cc+1] LDU | s - x s' | Loads an unsigned cc+1 -bit integer x from Slice s . | 26 |
82lxxx | [xxx] PUSHINT
[xxx] INT | - xxx | Pushes integer | 23 |
BA | EQUAL | x y - x=y | Returns -1 if x=y , 0 otherwise. | 18 |
F2E4_n | [n] THROWIFNOT | f - | For 0 <= n < 2^11 , an encoding of [n] THROWIFNOT for larger values of n . | 34/84 |
81xxxx | [xxxx] PUSHINT
[xxxx] INT | - xxxx | Pushes integer xxxx . -2^15 <= xx < 2^15 . | 34 |
3i | s[i] POP |
| Pops the old s0 value into the old s[i] . | 18 |
9xccc | [builder] PUSHCONT
[builder] CONT | - c | Pushes a continuation made from | 18 |
CBcc | [cc+1] STU | x b - b' | Stores an unsigned cc+1 -bit integer x into Builder b . In all other respects it is similar to STI . | 26 |
7i | [x] PUSHINT
[x] INT | - x | Pushes integer | 18 |
E0 | IFJMP | f c - | Jumps to c (similarly to JMPX ), but only if f is non-zero. | 18 |
D0 | CTOS | c - s | Converts a Cell into a Slice. Notice that c must be either an ordinary cell, or an exotic cell which is automatically loaded to yield an ordinary cell c' , converted into a Slice afterwards. | 118/43 |
FA40 | LDMSGADDR | s - s' s'' | Loads from Slice s the only prefix that is a valid MsgAddress , and returns both this prefix s' and the remainder s'' of s as slices. | 26 |
C8 | NEWC | - b | Creates a new empty Builder. | 18 |
1i | s1 s[i] XCHG |
| Interchanges s1 with s[i] , 2 <= i <= 15 . | 18 |
C9 | ENDC | b - c | Converts a Builder into an ordinary Cell. | 518 |
DB3C | [ref] CALLREF |
| Equivalent to PUSHREFCONT CALLX . | 126/51 |
F85_k | [k] GETGLOB | - x | Returns the | 26 |
ED5i | c[i] POPCTR
c[i] POP | x - | Pops a value x from the stack and stores it into control register c(i) , if supported in the current codepage. Notice that if a control register accepts only values of a specific type, a type-checking exception may occur. | 26 |
CF16 | STSLICER | b s - b' | Equivalent to SWAP STSLICE . | 26 |
F82i | [i] GETPARAM | - x | Returns the | 26 |
F87_k | [k] SETGLOB | x - | Assigns | 26+|c7'| |
11ii | s0 [ii] s() XCHG |
| Interchanges s0 with s[ii] , 0 <= ii <= 255 . | 26 |
D4 | LDREF | s - c s' | Loads a cell reference c from s . | 18 |
F2A_n | [n] THROWIFNOT | f - | Throws exception 0 <= n <= 63 with parameter zero only if integer f=0 . | 26/76 |
59 | ROTREV
-ROT | a b c - c a b | Equivalent to 2 1 BLKSWAP or to s2 s2 XCHG2 . | 18 |
A4 | INC | x - x+1 | Equivalent to 1 ADDCONST . | 18 |
F26_n | [n] THROWIF | f - | Throws exception 0 <= n <= 63 with parameter zero only if integer f!=0 . | 26/76 |
F901 | HASHSU | s - x | Computes the hash of a Slice s and returns it as a 256-bit unsigned integer x . The result is the same as if an ordinary cell containing only data and references from s had been created and its hash computed by HASHCU . | 526 |
BE | GEQ | x y - x>=y | Equivalent to LESS NOT . | 18 |
D718 | LDSLICEX | s l - s'' s' | Loads the first 0 <= l <= 1023 bits from Slice s into a separate Slice s'' , returning the remainder of s as s' . | 26 |
F800 | ACCEPT | - | Sets current gas limit | 26 |
F910 | CHKSIGNU | h s k - ? | Checks the Ed25519-signature | 26 |
50ij | s[i] s[j] XCHG2 |
| Equivalent to s1 s[i] XCHG s[j] XCHG0 . | 26 |
D74E_n | [n] PLDREFIDX | s - c | Returns the n -th cell reference of Slice s , where 0 <= n <= 3 . | 26 |
FFnn | [nn] SETCP | - | Selects TVM codepage 0 <= nn < 240 . If the codepage is not supported, throws an invalid opcode exception. | 26 |
DD | IFNOTRET
IF: | f - | Performs a RET , but only if integer f is zero. | 18 |
FA00 | LDGRAMS
LDVARUINT16 | s - x s' | Loads (deserializes) a | 26 |
ED4i | c[i] PUSHCTR
c[i] PUSH | - x | Pushes the current value of control register c(i) . If the control register is not supported in the current codepage, or if it does not have a value, an exception is triggered. | 26 |
CC | STREF | c b - b' | Stores a reference to Cell c into Builder b . | 18 |
F0nn | [nn] CALL
[nn] CALLDICT | - nn | Calls the continuation in |
|
FA02 | STGRAMS
STVARUINT16 | b x - b' | Stores (serializes) an Integer x in the range 0...2^120-1 into Builder b , and returns the resulting Builder b' . The serialization of x consists of a 4-bit unsigned big-endian integer l , which is the smallest integer l>=0 , such that x<2^(8l) , followed by an 8l -bit unsigned big-endian representation of x . If x does not belong to the supported range, a range check exception is thrown. | 26 |
10ij | s[i] s[j] XCHG |
| Interchanges s[i] with s[j] , 1 <= i < j <= 15 . | 26 |
8F_rxxcccc | [builder] PUSHCONT
[builder] CONT | - c | Pushes a continuation made from | 26 |
6Cij | [i] [j] BLKDROP2 |
| Drops | 26 |
83xx | [xx+1] PUSHPOW2 | - 2^(xx+1) | (Quietly) pushes | 26 |
80xx | [xx] PUSHINT
[xx] INT | - xx | Pushes integer xx . -128 <= xx <= 127 . | 26 |
F400 | STDICT
STOPTREF | D b - b' | Stores dictionary | 26 |
C0yy | [yy] EQINT | x - x=yy | Returns | 26 |
5F0i | [i] BLKDROP |
| Equivalent to DROP performed i times. | 26 |
F404 | LDDICT
LDOPTREF | s - D s' | Loads (parses) a dictionary D from Slice s , and returns the remainder of s as s' . May be applied to dictionaries or to values of arbitrary (^Y)? types. | 26 |
58 | ROT | a b c - b c a | Equivalent to 1 2 BLKSWAP or to s2 s1 XCHG2 . | 18 |
D749 | SBITS | s - l | Returns the number of data bits in Slice s . | 26 |
52ij | s[i] s[j-1] PUXC |
| Equivalent to s[i] PUSH SWAP s[j] XCHG0 . | 26 |
B0 | AND | x y - x&y | Bitwise and of two signed integers x and y , sign-extended to infinity. | 18 |
D70Bcc | [cc+1] PLDU | s - x | Preloads an unsigned cc+1 -bit integer from s . | 34 |
E2 | IFELSE | f c c' - | If integer f is non-zero, executes c , otherwise executes c' . Equivalent to CONDSELCHK EXECUTE . | 18 |
CAcc | [cc+1] STI | x b - b' | Stores a signed cc+1 -bit integer x into Builder b for 0 <= cc <= 255 , throws a range check exception if x does not fit into cc+1 bits. | 26 |
A0 | ADD | x y - x+y | 18 | |
55ij | [i+1] [j+1] BLKSWAP |
| Permutes two blocks | 26 |
F2D4_n | [n] THROWIF | f - | For 0 <= n < 2^11 , an encoding of [n] THROWIF for larger values of n . | 34/84 |
E302 | [ref] IFJMPREF | f - | Equivalent to PUSHREFCONT IFJMP . | 26/126/51 |
A1 | SUB | x y - x-y | 18 | |
4ijk | s[i] s[j] s[k] XCHG3 |
| Equivalent to s2 s[i] XCHG s1 s[j] XCHG s[k] XCHG0 . | 26 |
D2cc | [cc+1] LDI | s - x s' | Loads (i.e., parses) a signed cc+1 -bit integer x from Slice s , and returns the remainder of s as s' . | 26 |
FB00 | SENDRAWMSG | c x - | Sends a raw message contained in Cell c , which should contain a correctly serialized object Message X , with the only exception that the source address is allowed to have dummy value addr_none (to be automatically replaced with the current smart-contract address), and ihr_fee , fwd_fee , created_lt and created_at fields can have arbitrary values (to be rewritten with correct values during the action phase of the current transaction). Integer parameter x contains the flags. Currently x=0 is used for ordinary messages; x=128 is used for messages that are to carry all the remaining balance of the current smart contract (instead of the value originally indicated in the message); x=64 is used for messages that carry all the remaining value of the inbound message in addition to the value initially indicated in the new message (if bit 0 is not set, the gas fees are deducted from this amount); x'=x+1 means that the sender wants to pay transfer fees separately; x'=x+2 means that any errors arising while processing this message during the action phase should be ignored. Finally, x'=x+32 means that the current account must be destroyed if its resulting balance is zero. This flag is usually employed together with +128 . | 526 |
C705 | SDEQ | s s' - ? | Checks whether the data parts of s and s' coincide, equivalent to SDLEXCMP ISZERO . | 26 |
53ij | s[i] s[j] PUSH2 |
| Equivalent to s[i] PUSH s[j+1] PUSH . | 26 |
D1 | ENDS | s - | Removes a Slice s from the stack, and throws an exception if it is not empty. | 18/68 |
57ii | [ii] s() POP |
| Pops the old | 26 |
51ij | s[i] s[j] XCPU |
| Equivalent to s[i] XCHG0 s[j] PUSH . | 26 |
C2yy | [yy] GTINT
[yy+1] GEQINT | x - x>yy | Returns | 26 |
C700 | SEMPTY | s - ? | Checks whether a Slice s is empty (i.e., contains no bits of data and no cell references). | 26 |
6F0n | [n] TUPLE | x_1 ... x_n - t | Creates a new Tuple | 26+n |
8Drxxsssss | [slice] PUSHSLICE
[slice] SLICE | - s | Pushes the slice | 28 |
D721 | SDSKIPFIRST | s l - s' | Returns all but the first 0 <= l <= 1023 bits of s . It is equivalent to LDSLICEX NIP . | 26 |
6FA1 | NULLSWAPIFNOT | x - x or null x | Pushes a Null under the topmost Integer x , but only if x=0 . May be used for stack alignment after quiet primitives such as PLDUXQ . | 26 |
DE | IF | f c - | Performs EXECUTE for c (i.e., executes c ), but only if integer f is non-zero. Otherwise simply discards both values. | 18 |
F900 | HASHCU | c - x | Computes the representation hash of a Cell c and returns it as a 256-bit unsigned integer x . Useful for signing and checking signatures of arbitrary entities represented by a tree of cells. | 26 |
6D | NULL
PUSHNULL | - null | Pushes the only value of type Null. | 18 |
84xx | [xx+1] PUSHPOW2DEC | - 2^(xx+1)-1 | Pushes 2^(xx+1)-1 for 0 <= xx <= 255 . | 26 |
545ijk | s[i] s[j-1] s[k-1] PUXCPU |
| Equivalent to s[i] s[j-1] PUXC s[k] PUSH . | 34 |
A3 | NEGATE | x - -x | Equivalent to | 18 |
A8 | MUL | x y - x*y | 18 | |
F2F0 | THROWANY | n - 0 n | Throws exception | 76 |
541ijk | s[i] s[j] s[k] XC2PU |
| Equivalent to s[i] s[j] XCHG2 s[k] PUSH . | 34 |
6E | ISNULL | x - ? | Checks whether x is a Null, and returns -1 or 0 accordingly. | 18 |
B1 | OR | x y - x|y | Bitwise or of two integers. | 18 |
F40E | DICTUGET | i D n - x -1 or 0 | Similar to DICTIGET , but with unsigned (big-endian) n -bit Integer i used as a key. |
|
FA44 | REWRITESTDADDR | s - x y | Parses Slice s containing a valid MsgAddressInt (usually a msg_addr_std ), applies rewriting from the anycast (if present) to the same-length prefix of the address, and returns both the workchain x and the 256-bit address y as integers. If the address is not 256-bit, or if s is not a valid serialization of MsgAddressInt , throws a cell deserialization exception. | 26 |
BC | GREATER | x y - x>y | 18 | |
5B | DROP2
2DROP | a b - | Equivalent to DROP DROP . | 18 |
542ijk | s[i] s[j] s[k-1] XCPUXC |
| Equivalent to s1 s[i] XCHG s[j] s[k-1] PUXC . | 34 |
E30D | [ref] IFREFELSE | f c - | Equivalent to PUSHREFCONT SWAP IFELSE , with the optimization that the cell reference is not actually loaded into a Slice and then converted into an ordinary Continuation if f=0 . Similar remarks apply to the next two primitives: cells are converted into continuations only when necessary. | 26/126/51 |
A904 | DIV | x y - q | q=floor(x/y) , r=x-y*q | 26 |
56ii | [ii] s() PUSH |
| Pushes a copy of the old | 26 |
8Bxsss | [slice] PUSHSLICE
[slice] SLICE | - s | Pushes the slice | 22 |
B9 | LESS | x y - x<y | Returns -1 if x<y , 0 otherwise. | 18 |
547ijk | s[i] s[j] s[k] PUSH3 |
| Equivalent to s[i] PUSH s[j+1] s[k+1] PUSH2 . | 34 |
B3 | NOT | x - ~x | Bitwise not of an integer. | 26 |
E6 | UNTIL | c - | Executes continuation c , then pops an integer x from the resulting stack. If x is zero, performs another iteration of this loop. The actual implementation of this primitive involves an extraordinary continuation ec_until with its arguments set to the body of the loop (continuation c ) and the original current continuation cc . This extraordinary continuation is then saved into the savelist of c as c.c0 and the modified c is then executed. The other loop primitives are implemented similarly with the aid of suitable extraordinary continuations. | 18 |
F2F4 | THROWANYIFNOT | n f - | Throws exception 0 <= n<2^16 with parameter zero only if f=0 . | 26/76 |
C1yy | [yy] LESSINT
[yy-1] LEQINT | x - x<yy | Returns | 26 |
C3yy | [yy] NEQINT | x - x!=yy | Returns | 26 |
EDFB | SAMEALTSAVE | - | Sets | 26 |
CF00 | STIX | x b l - b' | Stores a signed l -bit integer x into b for 0 <= l <= 257 . | 26 |
BB | LEQ | x y - x<=y | 18 | |
AAcc | [cc+1] LSHIFT# | x - x*2^(cc+1) | 0 <= cc <= 255 | 26 |
E8 | WHILE | c' c - | Executes c' and pops an integer x from the resulting stack. If x is zero, exists the loop and transfers control to the original cc . If x is non-zero, executes c , and then begins a new iteration. | 18 |
EDAi | c[i] SAVE
c[i] SAVECTR |
| Saves the current value of c(i) into the savelist of continuation c0 . If an entry for c[i] is already present in the savelist of c0 , nothing is done. Equivalent to c[i] PUSHCTR c[i] SETRETCTR . | 26 |
5A | SWAP2
2SWAP | a b c d - c d a b | Equivalent to 2 2 BLKSWAP or to s3 s2 XCHG2 . | 18 |
D8 | EXECUTE
CALLX | c - | Calls, or executes, continuation c . | 18 |
6F2n | [n] UNTUPLE | t - x_1 ... x_n | Unpacks a Tuple | 26+n |
A9B4tt | [tt+1] MULRSHIFT# | x y - floor(x*y/2^(tt+1)) | 34 | |
FEij | {i*16+j} DEBUG | - | 26 | |
E300 | [ref] IFREF | f - | Equivalent to | 26/126/51 |
8A | [ref] PUSHREFCONT | - cont | Similar to PUSHREFSLICE , but makes a simple ordinary Continuation out of the cell. | 118/43 |
6F1k | [k] INDEX | t - x | Returns the | 26 |
A984 | MULDIV | x y z - q | q=floor(x*y/z) | 26 |
89 | [ref] PUSHREFSLICE | - s | Similar to PUSHREF , but converts the cell into a Slice. | 118/43 |
BD | NEQ | x y - x!=y | Equivalent to EQUAL NOT . | 18 |
ABcc | [cc+1] RSHIFT# | x - floor(x/2^(cc+1)) | 0 <= cc <= 255 | 18 |
F417 | DICTUSETREF | c i D n - D' | Similar to DICTISETREF , but with i unsigned. |
|
CF01 | STUX | x b l - b' | Stores an unsigned l -bit integer x into b for 0 <= l <= 256 . | 26 |
A6cc | [cc] ADDCONST
[cc] ADDINT
[-cc] SUBCONST
[-cc] SUBINT | x - x+cc | -128 <= cc <= 127 . | 26 |
F443 | DICTUSETB | b i D n - D' |
| |
B608 | MIN | x y - x or y | Computes the minimum of two integers x and y . | 26 |
66 | TUCK | a b - b a b | Equivalent to SWAP OVER or to s1 s1 XCPU . | 18 |
5C | DUP2
2DUP | a b - a b a b | Equivalent to s1 s0 PUSH2 . | 18 |
E1 | IFNOTJMP | f c - | Jumps to c (similarly to JMPX ), but only if f is zero. | 18 |
F40A | DICTGET | k D n - x -1 or 0 | Looks up key |
|
E30F | [ref] [ref] IFREFELSEREF | f - | Equivalent to PUSHREFCONT PUSHREFCONT IFELSE . | 126/51 |
546ijk | s[i] s[j-1] s[k-2] PU2XC |
| Equivalent to s[i] PUSH SWAP s[j] s[k-1] PUXC . | 34 |
F40F | DICTUGETREF | i D n - c -1 or 0 | Similar to DICTIGETREF , but with an unsigned n -bit Integer key i . |
|
543ijk | s[i] s[j] s[k] XCPU2 |
| Equivalent to s[i] XCHG0 s[j] s[k] PUSH2 . | 34 |
6FA5 | NULLSWAPIFNOT2 | x - x or null null x | Pushes two nulls under the topmost Integer | 26 |
A985 | MULDIVR | x y z - q' | q'=round(x*y/z) | 26 |
E30E | [ref] IFELSEREF | f c - | Equivalent to PUSHREFCONT IFELSE . | 26/126/51 |
DC | IFRET
IFNOT: | f - | Performs a RET , but only if integer f is non-zero. If f is a NaN , throws an integer overflow exception. | 18 |
DF | IFNOT | f c - | Executes continuation c , but only if integer f is zero. Otherwise simply discards both values. | 18 |
F836 | GETGASFEE | gas_used is_mc - price | Calculates gas fee |
|
E4 | REPEAT | n c - | Executes continuation | 18 |
CF31 | BBITS | b - x | Returns the number of data bits already stored in Builder b . | 26 |
FB02 | RAWRESERVE | x y - | Creates an output action which would reserve exactly x nanograms (if y=0 ), at most x nanograms (if y=2 ), or all but x nanograms (if y=1 or y=3 ), from the remaining balance of the account. It is roughly equivalent to creating an outbound message carrying x nanograms (or b-x nanograms, where b is the remaining balance) to oneself, so that the subsequent output actions would not be able to spend more money than the remainder. Bit +2 in y means that the external action does not fail if the specified amount cannot be reserved; instead, all remaining balance is reserved. Bit +8 in y means x:=-x before performing any further actions. Bit +4 in y means that x is increased by the original balance of the current account (before the compute phase), including all extra currencies, before performing any other checks and actions. Currently x must be a non-negative integer, and y must be in the range 0...15 . | 526 |
544ijk | s[i] s[j-1] s[k-1] PUXC2 |
| Equivalent to s[i] PUSH s2 XCHG0 s[j] s[k] XCHG2 . | 34 |
ED6i | c[i] SETCONT
c[i] SETCONTCTR | x c - c' | Stores x into the savelist of continuation c as c(i) , and returns the resulting continuation c' . Almost all operations with continuations may be expressed in terms of SETCONTCTR , POPCTR , and PUSHCTR . | 26 |
CF17 | STBR
BCONCAT | b b' - b'' | Concatenates two builders.
Equivalent to | 26 |
D74A | SREFS | s - r | Returns the number of references in Slice s . | 26 |
F416 | DICTUSET | x i D n - D' | Similar to DICTISET , but with i an unsigned n -bit integer. |
|
F80F | COMMIT | - | Commits the current state of registers c4 (''persistent data'') and c5 (''actions'') so that the current execution is considered ''successful'' with the saved values even if an exception is thrown later. | 26 |
A7cc | [cc] MULCONST
[cc] MULINT | x - x*cc | -128 <= cc <= 127 . | 26 |
F2F2 | THROWANYIF | n f - | Throws exception 0 <= n < 2^16 with parameter zero only if f!=0 . | 26/76 |
F815 | ADDRAND
RANDOMIZE | x - | Mixes unsigned 256-bit Integer x into the random seed r by setting the random seed to Sha of the concatenation of two 32-byte strings: the first with the big-endian representation of the old seed r , and the second with the big-endian representation of x . | 26 |
88 | [ref] PUSHREF | - c | Pushes the reference | 18 |
F405 | PLDDICT
PLDOPTREF | s - D | Preloads a dictionary | 26 |
F833 | CONFIGOPTPARAM | i - c^? | Returns the value of the global configuration parameter with integer index |
|
A5 | DEC | x - x-1 | Equivalent to -1 ADDCONST . | 18 |
F2C4_n | [n] THROW | - 0 nn | For 0 <= n < 2^11 , an encoding of [n] THROW for larger values of n . | 84 |
6F8C | TPUSH
COMMA | t x - t' | Appends a value x to a Tuple t=(x_1,...,x_n) , but only if the resulting Tuple t'=(x_1,...,x_n,x) is of length at most 255. Otherwise throws a type check exception. | 26+|t'| |
F838 | GETFORWARDFEE | cells bits is_mc - price | Calculates forward fee. |
|
5Eij | [i+2] [j] REVERSE |
| Reverses the order of s[j+i+1] ... s[j] . | 26 |
F486 | DICTUMIN | D n - x i -1 or 0 | Similar to DICTMIN , but returns the key as an unsigned n -bit Integer i . |
|
6F88 | TLEN | t - n | Returns the length of a Tuple. | 26 |
F46B | DICTUGETOPTREF | i D n - c^? | DICTGETOPTREF , but with i an unsigned n -bit integer. If the key i is out of range, also returns Null. |
|
F45B | DICTUDEL | i D n - D' ? | Similar to DICTIDEL , but with i an unsigned n -bit integer. |
|
A908 | MOD | x y - r | 26 | |
C701 | SDEMPTY | s - ? | Checks whether Slice s has no bits of data. | 26 |
A938tt | [tt+1] MODPOW2# | x - x mod 2^(tt+1) | 34 | |
F466 | DICTUDELGET | i D n - D' x -1 or D 0 | DICTDELGET , but with i an unsigned n -bit integer. |
|
F811 | RAND | y - z | Generates a new pseudo-random integer | 26+|c7|+|c1_1| |
B609 | MAX | x y - x or y | Computes the maximum of two integers x and y . | 26 |
D6cc | [cc+1] LDSLICE | s - s'' s' | Cuts the next cc+1 bits of s into a separate Slice s'' . | 26 |
F401 | SKIPDICT
SKIPOPTREF | s - s' | Equivalent to LDDICT NIP . | 26 |
F810 | RANDU256 | - x | Generates a new pseudo-random unsigned 256-bit Integer x . The algorithm is as follows: if r is the old value of the random seed, considered as a 32-byte array (by constructing the big-endian representation of an unsigned 256-bit integer), then its sha512(r) is computed; the first 32 bytes of this hash are stored as the new value r' of the random seed, and the remaining 32 bytes are returned as the next random value x . | 26+|c7|+|c1_1| |
EDF1 | COMPOSALT
BOOLOR | c c' - c'' | Computes the alternative composition compose1(c, c') , which has the meaning of ''perform c , and, if not successful, perform c' '' (if c is a boolean circuit). Equivalent to SWAP c1 SETCONT . | 26 |
F2FF | TRY | c c' - | Sets c2 to c' , first saving the old value of c2 both into the savelist of c' and into the savelist of the current continuation, which is stored into c.c0 and c'.c0 . Then runs c similarly to EXECUTE . If c does not throw any exceptions, the original value of c2 is automatically restored on return from c . If an exception occurs, the execution is transferred to c' , but the original value of c2 is restored in the process, so that c' can re-throw the exception by THROWANY if it cannot handle it by itself. | 26 |
F22_n | [n] THROW | - 0 n | Throws exception | 76 |
D70Acc | [cc+1] PLDI | s - x | Preloads a signed cc+1 -bit integer from Slice s . | 34 |
F441 | DICTSETB | b k D n - D' |
| |
F902 | SHA256U | s - x | Computes Sha of the data bits of Slice s . If the bit length of s is not divisible by eight, throws a cell underflow exception. The hash value is returned as a 256-bit unsigned integer x . | 26 |
5D | OVER2
2OVER | a b c d - a b c d a b | Equivalent to s3 s2 PUSH2 . | 18 |
FA03 | STVARINT16 | b x - b' | Similar to STVARUINT16 , but serializes a signed Integer x in the range -2^119...2^119-1 . | 26 |
AE | POW2 | y - 2^y |
| 18 |
F47C | DICTUGETNEXT | i D n - x' i' -1 or 0 | Similar to DICTGETNEXT , but interprets all keys in dictionary D as big-endian unsigned n -bit integers, and computes the minimal key i' that is larger than Integer i (which does not necessarily fit into n bits, and is not necessarily non-negative). |
|
ED11 | SETCONTVARARGS | x_1 x_2...x_r c r n - c' | Similar to SETCONTARGS , but with 0 <= r <= 255 and -1 <= n <= 255 taken from the stack. | 26+s'' |
FB04 | SETCODE | c - | Creates an output action that would change this smart contract code to that given by Cell c . Notice that this change will take effect only after the successful termination of the current run of the smart contract. | 526 |
F83A | GETORIGINALFWDFEE | fwd_fee is_mc - orig_fwd_fee | Calculate fwd_fee * 2^16 / first_frac . Can be used to get the original fwd_fee of the message. |
|
C702 | SREMPTY | s - ? | Checks whether Slice s has no references. | 26 |
DB0p | [p] -1 CALLXARGS | c - | Calls continuation c with 0 <= p <= 15 parameters, expecting an arbitrary number of return values. | 26 |
E303 | [ref] IFNOTJMPREF | f - | Equivalent to PUSHREFCONT IFNOTJMP . | 26/126/51 |
D719 | PLDSLICEX | s l - s'' | Returns the first 0 <= l <= 1023 bits of s as s'' . | 26 |
F801 | SETGASLIMIT | g - | Sets current gas limit g_l to the minimum of g and g_m , and resets the gas credit g_c to zero. If the gas consumed so far (including the present instruction) exceeds the resulting value of g_l , an (unhandled) out of gas exception is thrown before setting new gas limits. Notice that SETGASLIMIT with an argument g >= 2^63-1 is equivalent to ACCEPT . | 26 |
6F81 | INDEXVAR | t k - x | Similar to k INDEX , but with 0 <= k <= 254 taken from the stack. | 26 |
CF40 | STZEROES | b n - b' | Stores n binary zeroes into Builder b . | 26 |
D701 | LDUX | s l - x s' | Loads an unsigned l -bit integer x from (the first l bits of) s , with 0 <= l <= 256 . | 26 |
A906 | DIVC | x y - q'' | q''=ceil(x/y) , r''=x-y*q'' | 26 |
CE | STSLICE | s b - b' | Stores Slice s into Builder b . | 18 |
F12_n | [n] CALL
[n] CALLDICT | - n | For 0 <= n < 2^14 , an encoding of [n] CALL for larger values of n . |
|
D736 | SPLIT | s l r - s' s'' | Splits the first 0 <= l <= 1023 data bits and first 0 <= r <= 4 references from s into s' , returning the remainder of s as s'' . | 26 |
FA46 | REWRITEVARADDR | s - x s' | A variant of REWRITESTDADDR that returns the (rewritten) address as a Slice s , even if it is not exactly 256 bit long (represented by a msg_addr_var ). | 26 |
F911 | CHKSIGNS | d s k - ? | Checks whether s is a valid Ed25519-signature of the data portion of Slice d using public key k , similarly to CHKSIGNU . If the bit length of Slice d is not divisible by eight, throws a cell underflow exception. The verification of Ed25519 signatures is the standard one, with Sha used to reduce d to the 256-bit number that is actually signed. | 26 |
F941 | CDATASIZE | c n - x y z | A non-quiet version of CDATASIZEQ that throws a cell overflow exception (8) on failure. |
|
B60B | ABS | x - |x| | Computes the absolute value of an integer x . | 26 |
FA01 | LDVARINT16 | s - x s' | Similar to | 26 |
D700 | LDIX | s l - x s' | Loads a signed l -bit (0 <= l <= 257 ) integer x from Slice s , and returns the remainder of s as s' . | 26 |
A986 | MULDIVC | x y z - q' | q'=ceil(x*y/z) | 26 |
F48E | DICTUMAX | D n - x i -1 or 0 | Similar to DICTMAX , but returns the key as an unsigned n -bit Integer i . |
|
F93010 | BLS_G1_ADD | x y - x+y | Addition on G1. | 3934 |
F93013 | BLS_G1_MUL | x s - x*s | Multiplies G1 point x by scalar s . Any s is valid, including negative. | 5234 |
F48F | DICTUMAXREF | D n - c i -1 or 0 | Similar to DICTUMAX , but returns the only reference in the value. |
|
C70B | SDPPFXREV | s s' - ? | Checks whether s' is a proper prefix of s . | 26 |
F837 | GETSTORAGEFEE | cells bits seconds is_mc - price | Calculates storage fees (only current StoragePrices entry is used). |
|
D723 | SDSKIPLAST | s l - s' | Returns all but the last 0 <= l <= 1023 bits of s . | 26 |
F90403 | HASHEXT_KECCAK256 | s_1 ... s_n n - h | Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n . | 1/11 gas per byte |
D722 | SDCUTLAST | s l - s' | Returns the last 0 <= l <= 1023 bits of s . | 26 |
A90C | DIVMOD | x y - q r | 26 | |
F453 | DICTUADDB | b i D n - D' -1 or D 0 |
| |
F4A6_n | [ref] [n] DICTPUSHCONST | - D n | Pushes a non-empty constant dictionary D (as a Cell^? ) along with its key length 0 <= n <= 1023 , stored as a part of the instruction. The dictionary itself is created from the first of remaining references of the current continuation. In this way, the complete DICTPUSHCONST instruction can be obtained by first serializing xF4A4_ , then the non-empty dictionary itself (one 1 bit and a cell reference), and then the unsigned 10-bit integer n (as if by a STU 10 instruction). An empty dictionary can be pushed by a NEWDICT primitive instead. | 34 |
ED1E | BLESS | s - c | Transforms a Slice s into a simple ordinary continuation c , with c.code=s and an empty stack and savelist. | 26 |
F940 | CDATASIZEQ | c n - x y z -1 or 0 | Recursively computes the count of distinct cells x , data bits y , and cell references z in the dag rooted at Cell c , effectively returning the total storage used by this dag taking into account the identification of equal cells. The values of x , y , and z are computed by a depth-first traversal of this dag, with a hash table of visited cell hashes used to prevent visits of already-visited cells. The total count of visited cells x cannot exceed non-negative Integer n ; otherwise the computation is aborted before visiting the (n+1) -st cell and a zero is returned to indicate failure. If c is Null, returns x=y=z=0 . |
|
D74B | SBITREFS | s - l r | Returns both the number of data bits and the number of references in s . | 26 |
D5 | LDREFRTOS | s - s' s'' | Equivalent to LDREF SWAP CTOS . | 118/43 |
F839 | GETPRECOMPILEDGAS | - x | Returns gas usage for the current contract if it is precompiled, null otherwise. |
|
D724 | SDSUBSTR | s l l' - s' | Returns 0 <= l' <= 1023 bits of s starting from offset 0 <= l <= 1023 , thus extracting a bit substring out of the data of s . | 26 |
CF13 | STB | b' b - b'' | Appends all data from Builder b' to Builder b . | 26 |
F487 | DICTUMINREF | D n - c i -1 or 0 | Similar to DICTUMIN , but returns the only reference in the value. |
|
F83C | GETFORWARDFEESIMPLE | cells bits is_mc - price | Same as GETFORWARDFEE , but without lump price (just (bits*bit_price + cells*cell_price) / 2^16 ). |
|
F4A1 | DICTUGETJMP | i D n - | Similar to DICTIGETJMP , but performs DICTUGET instead of DICTIGET . |
|
D739 | XCTOS | c - s ? | Transforms an ordinary or exotic cell into a Slice, as if it were an ordinary cell. A flag is returned indicating whether c is exotic. If that be the case, its type can later be deserialized from the first eight bits of s . |
|
F40D | DICTIGETREF | i D n - c -1 or 0 | Combines DICTIGET with DICTGETREF : it uses signed n -bit Integer i as a key and returns a Cell instead of a Slice on success. |
|
F807 | GASCONSUMED | - g_c | Returns gas consumed by VM so far (including this instruction). | 26 |
DApr | [p] [r] CALLXARGS | c - | Calls continuation | 26 |
F40C | DICTIGET | i D n - x -1 or 0 | Similar to DICTGET , but with a signed (big-endian) n -bit Integer i as a key. If i does not fit into n bits, returns 0 . If i is a NaN , throws an integer overflow exception. |
|
F4A8 | PFXDICTGETQ | s D n - s' x s'' -1 or s 0 | Looks up the unique prefix of Slice s present in the prefix code dictionary represented by Cell^? D and 0 <= n <= 1023 . If found, the prefix of s is returned as s' , and the corresponding value (also a Slice) as x . The remainder of s is returned as a Slice s'' . If no prefix of s is a key in prefix code dictionary D , returns the unchanged s and a zero flag to indicate failure. |
|
F814 | SETRAND | x - | Sets the random seed to unsigned 256-bit Integer x . | 26+|c7|+|c1_1| |
F47F | DICTUGETPREVEQ | i D n - x' i' -1 or 0 | Similar to DICTGETPREVEQ , but interprets keys a unsigned n -bit integers. |
|
B2 | XOR | x y - x xor y | Bitwise xor of two integers. | 18 |
F912 | ECRECOVER | hash v r s - 0 or h x1 x2 -1 | Recovers the public key from a secp256k1 signature, identical to Bitcoin/Ethereum operations. Takes a 32-byte hash as uint256 hash and a 65-byte signature as uint8 v , uint256 r , and uint256 s . In TON, the v value is strictly 0 or 1; no extra flags or extended values are supported. If the public key cannot be recovered, the instruction returns 0 . On success, it returns the recovered 65-byte public key as uint8 h , uint256 x1 , and uint256 x2 , followed by -1 . | 1526 |
E301 | [ref] IFNOTREF | f - | Equivalent to PUSHREFCONT IFNOT . | 26/126/51 |
F46A | DICTIGETOPTREF | i D n - c^? | DICTGETOPTREF , but with i a signed n -bit integer. If the key i is out of range, also returns Null. |
|
F482 | DICTMIN | D n - x k -1 or 0 | Computes the minimal key k (represented by a Slice with n data bits) in dictionary D , and returns k along with the associated value x . |
|
F40B | DICTGETREF | k D n - c -1 or 0 | Similar to |
|
F470 | PFXDICTSET | x k D n - D' -1 or D 0 |
| |
A98C | MULDIVMOD | x y z - q r | q=floor(x*y/z) , r=x*y-z*q | 26 |
D703 | PLDUX | s l - x | Preloads an unsigned l -bit integer from s , for 0 <= l <= 256 . | 26 |
6F8D | TPOP | t - t' x | Detaches the last element x=x_n from a non-empty Tuple t=(x_1,...,x_n) , and returns both the resulting Tuple t'=(x_1,...,x_{n-1}) and the original last element x . | 26+|t'| |
F93012 | BLS_G1_NEG | x - -x | Negation on G1. | 784 |
F93030 | BLS_PAIRING | x_1 y_1 ... x_n y_n n - bool | Given G1 points x_i and G2 points y_i , calculates and multiply pairings of x_i,y_i . Returns true if the result is the multiplicative identity in FP12, false otherwise. Returns false if n=0 . | 20034+n*11800 |
B603 | UBITSIZE | x - c | Computes smallest c >= 0 such that x fits into a c -bit unsigned integer (0 <= x < 2^c ), or throws a range check exception. | 26 |
D9 | JMPX | c - | Jumps, or transfers control, to continuation | 18 |
F4A0 | DICTIGETJMP | i D n - | Similar to DICTIGET , but with x BLESS ed into a continuation with a subsequent JMPX to it on success. On failure, does nothing. This is useful for implementing switch /case constructions. |
|
F44B | DICTUREPLACEB | b i D n - D' -1 or D 0 |
| |
F1A_n | [n] PREPARE
[n] PREPAREDICT | - n c | Equivalent to |
|
F415 | DICTISETREF | c i D n - D' | Similar to DICTSETREF , but with the key a signed n -bit integer as in DICTISET . |
|
C704 | SDLEXCMP | s s' - x | Compares the data of s lexicographically with the data of s' , returning -1 , 0, or 1 depending on the result. | 26 |
F90400 | HASHEXT_SHA256 | s_1 ... s_n n - h | Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n . | 1/33 gas per byte |
F496 | DICTUREMMIN | D n - D' x i -1 or D 0 | Similar to DICTREMMIN , but returns the key as an unsigned n -bit Integer i . |
|
F41E | DICTUSETGET | x i D n - D' y -1 or D' 0 | DICTISETGET , but with i an unsigned n -bit integer. |
|
F497 | DICTUREMMINREF | D n - D' c i -1 or D 0 | Similar to DICTUREMMIN , but returns the only reference in the value. |
|
FA42 | PARSEMSGADDR | s - t | Decomposes Slice s containing a valid MsgAddress into a Tuple t with separate fields of this MsgAddress . If s is not a valid MsgAddress , a cell deserialization exception is thrown. | 26 |
6F85 | SETINDEXVAR | t x k - t' | Similar to k SETINDEX , but with 0 <= k <= 254 taken from the stack. | 26+|t'| |
00 | NOP | - | Does nothing. | 18 |
6F84 | EXPLODEVAR | t n - x_1 ... x_m m | Similar to n EXPLODE , but with 0 <= n <= 255 taken from the stack. | 26+m |
D765 | CDEPTH | c - x | Returns the depth of Cell c . If c has no references, then x=0 ; otherwise x is one plus the maximum of depths of cells referred to from c . If c is a Null instead of a Cell, returns zero. | 26 |
FA41 | LDMSGADDRQ | s - s' s'' -1 or s 0 | A quiet version of LDMSGADDR : on success, pushes an extra -1 ; on failure, pushes the original s and a zero. | 26 |
B601 | UFITSX | x c - x | Checks whether x is a c -bit unsigned integer for 0 <= c <= 1023 . | 26/76 |
AC | LSHIFT | x y - x*2^y | 0 <= y <= 1023 | 18 |
F943 | SDATASIZE | s n - x y z | A non-quiet version of SDATASIZEQ that throws a cell overflow exception (8) on failure. |
|
A935tt | [tt+1] RSHIFTR# | x - round(x/2^(tt+1)) | 34 | |
CFC0_xysss | [slice] STSLICECONST | b - b' | Stores a constant subslice | 24 |
FB06 | SETLIBCODE | c x - | Creates an output action that would modify the collection of this smart contract libraries by adding or removing library with code given in Cell c . If x=0 , the library is actually removed if it was previously present in the collection (if not, this action does nothing). If x=1 , the library is added as a private library, and if x=2 , the library is added as a public library (and becomes available to all smart contracts if the current smart contract resides in the masterchain); if the library was present in the collection before, its public/private status is changed according to x . Values of x other than 0...2 are invalid. | 526 |
C4 | ISNAN | x - x=NaN | Checks whether x is a NaN . | 18 |
AD | RSHIFT | x y - floor(x/2^y) | 0 <= y <= 1023 | 18 |
F83400 | PREVMCBLOCKS | - t | Retrives last_mc_blocks part of PrevBlocksInfo from c7 (parameter 13). |
|
83FF | PUSHNAN | - NaN | Pushes a NaN . | 26 |
6F5k | [k] SETINDEX | t x - t' | Computes Tuple | 26+|t| |
F47E | DICTUGETPREV | i D n - x' i' -1 or 0 | Similar to DICTGETPREV , but interprets keys as unsigned n -bit integers. |
|
F484 | DICTIMIN | D n - x i -1 or 0 | Similar to DICTMIN , but computes the minimal key i under the assumption that all keys are big-endian signed n -bit integers. Notice that the key and value returned may differ from those computed by DICTMIN and DICTUMIN . |
|
6F89 | QTLEN | t - n or -1 | Similar to TLEN , but returns -1 if t is not a Tuple. | 26 |
FB08 | SENDMSG | c x - fee | Creates an output action and returns a fee for creating a message. Mode has the same effect as in the case of SENDRAWMSG . Additionally +1024 means - do not create an action, only estimate fee. Other modes affect the fee calculation as follows: +64 substitutes the entire balance of the incoming message as an outcoming value (slightly inaccurate, gas expenses that cannot be estimated before the computation is completed are not taken into account), +128 substitutes the value of the entire balance of the contract before the start of the computation phase (slightly inaccurate, since gas expenses that cannot be estimated before the completion of the computation phase are not taken into account). | 526 |
F436 | DICTUADD | x i D n - D' -1 or D 0 | DICTADD , but with i an unsigned n -bit integer. |
|
E308 | IFRETALT | f - | Performs RETALT if integer f!=0 . | 26 |
F83401 | PREVKEYBLOCK | - t | Retrives prev_key_block part of PrevBlocksInfo from c7 (parameter 13). |
|
A9B5tt | [tt+1] MULRSHIFTR# | x y - round(x*y/2^(tt+1)) | 34 | |
F414 | DICTISET | x i D n - D' | Similar to DICTSET , but with the key represented by a (big-endian) signed n -bit integer i . If i does not fit into n bits, a range check exception is generated. |
|
F469 | DICTGETOPTREF | k D n - c^? | A variant of DICTGETREF that returns Null instead of the value c^? if the key k is absent from dictionary D . |
|
BF | CMP | x y - sgn(x-y) | Computes the sign of | 18 |
F924 | RIST255_MUL | x n - x*n | Multiplies point x by a scalar n . Any n is valid, including negative. | 2026 |
D720 | SDCUTFIRST | s l - s' | Returns the first 0 <= l <= 1023 bits of s . It is equivalent to PLDSLICEX . | 26 |
D764 | SDEPTH | s - x | Returns the depth of Slice s . If s has no references, then x=0 ; otherwise x is one plus the maximum of depths of cells referred to from s . | 26 |
CF41 | STONES | b n - b' | Stores n binary ones into Builder b . | 26 |
F90600 | HASHEXTA_SHA256 | b s_1 ... s_n n - b' | Calculates hash of the concatenation of slices (or builders) s_1...s_n . Appends the resulting hash to a builder b . | 1/33 gas per byte |
F925 | RIST255_MULBASE | n - g*n | Multiplies the generator point g by a scalar n . Any n is valid, including negative. | 776 |
F840 | GETGLOBVAR | k - x | Returns the | 26 |
F45A | DICTIDEL | i D n - D' ? | A version of DICTDEL with the key represented by a signed n -bit Integer i . If i does not fit into n bits, simply returns D 0 (''key not found, dictionary unmodified''). |
|
D72E_xsss | [slice] SDBEGINSQ | s - s'' -1 or s 0 | A quiet version of SDBEGINS . | 31 |
D732 | SCUTLAST | s l r - s' | Returns the last 0 <= l <= 1023 data bits and last 0 <= r <= 4 references of s . | 26 |
F467 | DICTUDELGETREF | i D n - D' c -1 or D 0 | DICTDELGETREF , but with i an unsigned n -bit integer. |
|
F407 | PLDDICTQ | s - D -1 or 0 | A quiet version of PLDDICT . | 26 |
F462 | DICTDELGET | k D n - D' x -1 or D 0 | Deletes n -bit key, represented by a Slice k , from dictionary D . If the key is present, returns the modified dictionary D' , the original value x associated with the key k (represented by a Slice), and the success flag -1 . Otherwise, returns the original dictionary D and 0 . |
|
F83B | GETGASFEESIMPLE | gas_used is_mc - price | Same as GETGASFEE , but without flat price (just (gas_used * price) / 2^16) . |
|
A936tt | [tt+1] RSHIFTC# | x - ceil(x/2^(tt+1)) | 34 | |
C709 | SDPFXREV | s s' - ? | Checks whether s' is a prefix of s , equivalent to SWAP SDPFX . | 26 |
B7A8 | QMUL | x y - x*y | 26 | |
B7A98C | QMULDIVMOD | x y z - q r | 34 | |
F478 | DICTIGETNEXT | i D n - x' i' -1 or 0 | Similar to DICTGETNEXT , but interprets all keys in dictionary D as big-endian signed n -bit integers, and computes the minimal key i' that is larger than Integer i (which does not necessarily fit into n bits). |
|
F412 | DICTSET | x k D n - D' | Sets the value associated with n -bit key k (represented by a Slice as in DICTGET ) in dictionary D (also represented by a Slice) to value x (again a Slice), and returns the resulting dictionary as D' . |
|
D751 | LDULE4 | s - x s' | Loads a little-endian unsigned 32-bit integer. | 26 |
F413 | DICTSETREF | c k D n - D' | Similar to DICTSET , but with the value set to a reference to Cell c . |
|
F437 | DICTUADDREF | c i D n - D' -1 or D 0 | DICTADDREF , but with i an unsigned n -bit integer. |
|
F835 | GLOBALID | - i | Retrieves global_id from 19 network config. |
|
C713 | SDCNTTRAIL1 | s - n | Returns the number of trailing ones in s . | 26 |
CF11 | STBREF | b' b - b'' | Equivalent to SWAP STBREFR . | 526 |
DB35 | JMPXDATA | c - | Similar to CALLCC , but the remainder of the current continuation (the old value of cc ) is converted into a Slice before pushing it into the stack of c . | 26 |
CF23 | ENDXC | b x - c | If | 526 |
A9D6tt | [tt+1] LSHIFT#DIVC | x y - ceil(2^(tt+1)*x/y) | 26 | |
F90401 | HASHEXT_SHA512 | s_1 ... s_n n - h1 h2 | Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n . | 1/16 gas per byte |
F920 | RIST255_FROMHASH | h1 h2 - x | Deterministically generates a valid point x from a 512-bit hash (given as two 256-bit integers). | 626 |
F926 | RIST255_PUSHL | - l | Pushes integer l=2^252+27742317777372353535851937790883648493, which is the order of the group. | 26 |
F923 | RIST255_SUB | x y - x-y | Subtraction of two points on curve. | 626 |
F485 | DICTIMINREF | D n - c i -1 or 0 | Similar to DICTIMIN , but returns the only reference in the value. |
|
D714_c | [32(c+1)] PLDUZ | s - s x | Preloads the first 32(c+1) bits of Slice s into an unsigned integer x , for 0 <= c <= 7 . If s is shorter than necessary, missing bits are assumed to be zero. This operation is intended to be used along with IFBITJMP and similar instructions. | 26 |
F4BC | DICTIGETJMPZ | i D n - i or nothing | A variant of DICTIGETJMP that returns index i on failure. |
|
F2CC_n | [n] THROWARG | x - x nn | Throws exception 0 <= n < 2^11 with parameter x , by copying x and n into the stack of c2 and transferring control to c2 . | 84 |
F435 | DICTIADDREF | c i D n - D' -1 or D 0 | DICTADDREF , but with i a signed n -bit integer. |
|
8Crxxssss | [slice] PUSHSLICE
[slice] SLICE | - s | Pushes the slice | 25 |
F47B | DICTIGETPREVEQ | i D n - x' i' -1 or 0 | Similar to DICTGETPREVEQ , but interprets keys as signed n -bit integers. |
|
D71Dcc | [cc+1] PLDSLICE | s - s'' | Returns the first 0 < cc+1 <= 256 bits of s as s'' . | 34 |
F451 | DICTADDB | b k D n - D' -1 or D 0 |
| |
A9D5tt | [tt+1] LSHIFT#DIVR | x y - round(2^(tt+1)*x/y) | 34 | |
DB4fff | flags RUNVM | x_1 ... x_n n code [r] [c4] [c7] [g_l] [g_m] - x'_1 ... x'_m exitcode [data'] [c4'] [c5] [g_c] | Runs child VM with code code and stack x_1...x_n . Returns the resulting stack x'_1...x'_m and exitcode. Other arguments and return values are enabled by flags. |
|
A9BD | MULRSHIFTR#MOD | x y - q=round(x*y/2^(tt+1)) r=xy-q*2^(tt+1) | 34 | |
A9CD | LSHIFTDIVMODR | x y z - q=round(2^z*x/y) r=2^z*x-q*y | 26 | |
A925 | RSHIFTR | x y - round(x/2^y) | 26 | |
B5cc | [cc+1] UFITS | x - x | Checks whether x is a cc+1 -bit unsigned integer for 0 <= cc <= 255 (i.e., whether 0 <= x < 2^(cc+1) ). | 26/76 |
A905 | DIVR | x y - q' | q'=round(x/y) , r'=x-y*q' | 26 |
B8 | SGN | x - sgn(x) | Computes the sign of an integer | 18 |
CF0Bcc | [cc+1] STUR | b x - b' | Equivalent to SWAP [cc+1] STU . | 34 |
D72A_xsss | [slice] SDBEGINS | s - s'' | Checks whether s begins with constant bitstring sss of length 8x+3 (with continuation bit assumed), where 0 <= x <= 127 , and removes sss from s on success. | 31 |
C703 | SDFIRST | s - ? | Checks whether the first bit of Slice s is a one. | 26 |
F921 | RIST255_VALIDATE | x - | Checks that integer x is a valid representation of some curve point. Throws range_chk on error. | 226 |
CF3D | BCHKBITSQ | b x - ? | Checks whether x bits can be stored into b , 0 <= x <= 1023 . | 26 |
F475 | DICTGETNEXTEQ | k D n - x' k' -1 or 0 | Similar to DICTGETNEXT , but computes the minimal key k' that is lexicographically greater than or equal to k . |
|
CF29 | STULE4 | x b - b' | Stores a little-endian unsigned 32-bit integer. | 26 |
F459 | DICTDEL | k D n - D' -1 or D 0 | Deletes n -bit key, represented by a Slice k , from dictionary D . If the key is present, returns the modified dictionary D' and the success flag -1 . Otherwise, returns the original dictionary D and 0 . |
|
F47D | DICTUGETNEXTEQ | i D n - x' i' -1 or 0 | Similar to DICTGETNEXTEQ , but interprets keys as unsigned n -bit integers. |
|
E309 | IFNOTRETALT | f - | Performs RETALT if integer f=0 . | 26 |
D705 | LDUXQ | s l - x s' -1 or s 0 | Quiet version of LDUX . | 26 |
F48A | DICTMAX | D n - x k -1 or 0 | Computes the maximal key k (represented by a Slice with n data bits) in dictionary D , and returns k along with the associated value x . |
|
CF0Acc | [cc+1] STIR | b x - b' | Equivalent to SWAP [cc+1] STI . | 34 |
C710 | SDCNTLEAD0 | s - n | Returns the number of leading zeroes in s . | 26 |
EB | AGAINEND
AGAIN: | - | Similar to AGAIN , but performed with respect to the current continuation cc . | 18 |
F442 | DICTISETB | b i D n - D' |
| |
F424 | DICTIREPLACE | x i D n - D' -1 or D 0 | DICTREPLACE , but with i a signed n -bit integer. |
|
85xx | [xx+1] PUSHNEGPOW2 | - -2^(xx+1) | Pushes -2^(xx+1) for 0 <= xx <= 255 . | 26 |
CF14 | STREFR | b c - b' | Equivalent to SWAP STREF . | 26 |
F93014 | BLS_G1_MULTIEXP | x_1 s_1 ... x_n s_n n - x_1*s_1+...+x_n*s_n | Calculates x_1*s_1+...+x_n*s_n for G1 points x_i and scalars s_i . Returns zero point if n=0 . Any s_i is valid, including negative. | 11409+n*630+n/floor(max(log2(n),4))*8820 |
FA45 | REWRITESTDADDRQ | s - x y -1 or 0 | A quiet version of primitive REWRITESTDADDR . | 26 |
F47A | DICTIGETPREV | i D n - x' i' -1 or 0 | Similar to DICTGETPREV , but interprets keys as signed n -bit integers. |
|
F914 | P256_CHKSIGNU | h sig k - ? | Checks seck256r1-signature sig of a number h (a 256-bit unsigned integer, usually computed as the hash of some data) and public key k . Returns -1 on success, 0 on failure. Public key is a 33-byte slice (encoded according to Sec. 2.3.4 point 2 of SECG SEC 1). Signature sig is a 64-byte slice (two 256-bit unsigned integers r and s ). | 3526 |
ECrn | [r] [n] SETCONTARGS | x_1 x_2...x_r c - c' | Pushes 0 <= r <= 15 values x_1...x_r into the stack of (a copy of) the continuation c , starting with x_1 . When n is 15 (-1 in Fift notation), does nothing with c.nargs . For 0 <= n <= 14 , sets c.nargs to the final size of the stack of c' plus n . In other words, transforms c into a closure or a partially applied function, with 0 <= n <= 14 arguments missing. | 26+s'' |
63 | BLKSWX |
| Pops integers i ,j from the stack, then performs [i] [j] BLKSWAP . | 18 |
6F6k | [k] INDEXQ | t - x | Returns the k -th element of a Tuple t , where 0 <= k <= 15 . In other words, returns x_{k+1} if t=(x_1,...,x_n) . If k>=n , or if t is Null, returns a Null instead of x . | 26 |
D73A | XLOAD | c - c' | Loads an exotic cell c and returns an ordinary cell c' . If c is already ordinary, does nothing. If c cannot be loaded, throws an exception. |
|
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
0i | s[i] XCHG0 |
| Interchanges s0 with s[i] , 1 <= i <= 15 . | 18 |
2i | s[i] PUSH |
| Pushes a copy of the old s[i] into the stack. | 18 |
3i | s[i] POP |
| Pops the old s0 value into the old s[i] . | 18 |
1i | s1 s[i] XCHG |
| Interchanges s1 with s[i] , 2 <= i <= 15 . | 18 |
11ii | s0 [ii] s() XCHG |
| Interchanges s0 with s[ii] , 0 <= ii <= 255 . | 26 |
59 | ROTREV
-ROT | a b c - c a b | Equivalent to 2 1 BLKSWAP or to s2 s2 XCHG2 . | 18 |
50ij | s[i] s[j] XCHG2 |
| Equivalent to s1 s[i] XCHG s[j] XCHG0 . | 26 |
10ij | s[i] s[j] XCHG |
| Interchanges s[i] with s[j] , 1 <= i < j <= 15 . | 26 |
6Cij | [i] [j] BLKDROP2 |
| Drops | 26 |
5F0i | [i] BLKDROP |
| Equivalent to DROP performed i times. | 26 |
58 | ROT | a b c - b c a | Equivalent to 1 2 BLKSWAP or to s2 s1 XCHG2 . | 18 |
52ij | s[i] s[j-1] PUXC |
| Equivalent to s[i] PUSH SWAP s[j] XCHG0 . | 26 |
55ij | [i+1] [j+1] BLKSWAP |
| Permutes two blocks | 26 |
4ijk | s[i] s[j] s[k] XCHG3 |
| Equivalent to s2 s[i] XCHG s1 s[j] XCHG s[k] XCHG0 . | 26 |
53ij | s[i] s[j] PUSH2 |
| Equivalent to s[i] PUSH s[j+1] PUSH . | 26 |
57ii | [ii] s() POP |
| Pops the old | 26 |
51ij | s[i] s[j] XCPU |
| Equivalent to s[i] XCHG0 s[j] PUSH . | 26 |
545ijk | s[i] s[j-1] s[k-1] PUXCPU |
| Equivalent to s[i] s[j-1] PUXC s[k] PUSH . | 34 |
541ijk | s[i] s[j] s[k] XC2PU |
| Equivalent to s[i] s[j] XCHG2 s[k] PUSH . | 34 |
5B | DROP2
2DROP | a b - | Equivalent to DROP DROP . | 18 |
542ijk | s[i] s[j] s[k-1] XCPUXC |
| Equivalent to s1 s[i] XCHG s[j] s[k-1] PUXC . | 34 |
56ii | [ii] s() PUSH |
| Pushes a copy of the old | 26 |
547ijk | s[i] s[j] s[k] PUSH3 |
| Equivalent to s[i] PUSH s[j+1] s[k+1] PUSH2 . | 34 |
5A | SWAP2
2SWAP | a b c d - c d a b | Equivalent to 2 2 BLKSWAP or to s3 s2 XCHG2 . | 18 |
66 | TUCK | a b - b a b | Equivalent to SWAP OVER or to s1 s1 XCPU . | 18 |
5C | DUP2
2DUP | a b - a b a b | Equivalent to s1 s0 PUSH2 . | 18 |
546ijk | s[i] s[j-1] s[k-2] PU2XC |
| Equivalent to s[i] PUSH SWAP s[j] s[k-1] PUXC . | 34 |
543ijk | s[i] s[j] s[k] XCPU2 |
| Equivalent to s[i] XCHG0 s[j] s[k] PUSH2 . | 34 |
544ijk | s[i] s[j-1] s[k-1] PUXC2 |
| Equivalent to s[i] PUSH s2 XCHG0 s[j] s[k] XCHG2 . | 34 |
5Eij | [i+2] [j] REVERSE |
| Reverses the order of s[j+i+1] ... s[j] . | 26 |
5D | OVER2
2OVER | a b c d - a b c d a b | Equivalent to s3 s2 PUSH2 . | 18 |
00 | NOP | - | Does nothing. | 18 |
63 | BLKSWX |
| Pops integers i ,j from the stack, then performs [i] [j] BLKSWAP . | 18 |
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
6F0n | [n] TUPLE | x_1 ... x_n - t | Creates a new Tuple | 26+n |
6FA1 | NULLSWAPIFNOT | x - x or null x | Pushes a Null under the topmost Integer x , but only if x=0 . May be used for stack alignment after quiet primitives such as PLDUXQ . | 26 |
6D | NULL
PUSHNULL | - null | Pushes the only value of type Null. | 18 |
6E | ISNULL | x - ? | Checks whether x is a Null, and returns -1 or 0 accordingly. | 18 |
6F2n | [n] UNTUPLE | t - x_1 ... x_n | Unpacks a Tuple | 26+n |
6F1k | [k] INDEX | t - x | Returns the | 26 |
6FA5 | NULLSWAPIFNOT2 | x - x or null null x | Pushes two nulls under the topmost Integer | 26 |
6F8C | TPUSH
COMMA | t x - t' | Appends a value x to a Tuple t=(x_1,...,x_n) , but only if the resulting Tuple t'=(x_1,...,x_n,x) is of length at most 255. Otherwise throws a type check exception. | 26+|t'| |
6F88 | TLEN | t - n | Returns the length of a Tuple. | 26 |
6F81 | INDEXVAR | t k - x | Similar to k INDEX , but with 0 <= k <= 254 taken from the stack. | 26 |
6F8D | TPOP | t - t' x | Detaches the last element x=x_n from a non-empty Tuple t=(x_1,...,x_n) , and returns both the resulting Tuple t'=(x_1,...,x_{n-1}) and the original last element x . | 26+|t'| |
6F85 | SETINDEXVAR | t x k - t' | Similar to k SETINDEX , but with 0 <= k <= 254 taken from the stack. | 26+|t'| |
6F84 | EXPLODEVAR | t n - x_1 ... x_m m | Similar to n EXPLODE , but with 0 <= n <= 255 taken from the stack. | 26+m |
6F5k | [k] SETINDEX | t x - t' | Computes Tuple | 26+|t| |
6F89 | QTLEN | t - n or -1 | Similar to TLEN , but returns -1 if t is not a Tuple. | 26 |
6F6k | [k] INDEXQ | t - x | Returns the k -th element of a Tuple t , where 0 <= k <= 15 . In other words, returns x_{k+1} if t=(x_1,...,x_n) . If k>=n , or if t is Null, returns a Null instead of x . | 26 |
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
82lxxx | [xxx] PUSHINT
[xxx] INT | - xxx | Pushes integer | 23 |
81xxxx | [xxxx] PUSHINT
[xxxx] INT | - xxxx | Pushes integer xxxx . -2^15 <= xx < 2^15 . | 34 |
9xccc | [builder] PUSHCONT
[builder] CONT | - c | Pushes a continuation made from | 18 |
7i | [x] PUSHINT
[x] INT | - x | Pushes integer | 18 |
8F_rxxcccc | [builder] PUSHCONT
[builder] CONT | - c | Pushes a continuation made from | 26 |
83xx | [xx+1] PUSHPOW2 | - 2^(xx+1) | (Quietly) pushes | 26 |
80xx | [xx] PUSHINT
[xx] INT | - xx | Pushes integer xx . -128 <= xx <= 127 . | 26 |
8Drxxsssss | [slice] PUSHSLICE
[slice] SLICE | - s | Pushes the slice | 28 |
84xx | [xx+1] PUSHPOW2DEC | - 2^(xx+1)-1 | Pushes 2^(xx+1)-1 for 0 <= xx <= 255 . | 26 |
8Bxsss | [slice] PUSHSLICE
[slice] SLICE | - s | Pushes the slice | 22 |
8A | [ref] PUSHREFCONT | - cont | Similar to PUSHREFSLICE , but makes a simple ordinary Continuation out of the cell. | 118/43 |
89 | [ref] PUSHREFSLICE | - s | Similar to PUSHREF , but converts the cell into a Slice. | 118/43 |
88 | [ref] PUSHREF | - c | Pushes the reference | 18 |
83FF | PUSHNAN | - NaN | Pushes a NaN . | 26 |
8Crxxssss | [slice] PUSHSLICE
[slice] SLICE | - s | Pushes the slice | 25 |
85xx | [xx+1] PUSHNEGPOW2 | - -2^(xx+1) | Pushes -2^(xx+1) for 0 <= xx <= 255 . | 26 |
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
A4 | INC | x - x+1 | Equivalent to 1 ADDCONST . | 18 |
B0 | AND | x y - x&y | Bitwise and of two signed integers x and y , sign-extended to infinity. | 18 |
A0 | ADD | x y - x+y | 18 | |
A1 | SUB | x y - x-y | 18 | |
A3 | NEGATE | x - -x | Equivalent to | 18 |
A8 | MUL | x y - x*y | 18 | |
B1 | OR | x y - x|y | Bitwise or of two integers. | 18 |
A904 | DIV | x y - q | q=floor(x/y) , r=x-y*q | 26 |
B3 | NOT | x - ~x | Bitwise not of an integer. | 26 |
AAcc | [cc+1] LSHIFT# | x - x*2^(cc+1) | 0 <= cc <= 255 | 26 |
A9B4tt | [tt+1] MULRSHIFT# | x y - floor(x*y/2^(tt+1)) | 34 | |
A984 | MULDIV | x y z - q | q=floor(x*y/z) | 26 |
ABcc | [cc+1] RSHIFT# | x - floor(x/2^(cc+1)) | 0 <= cc <= 255 | 18 |
A6cc | [cc] ADDCONST
[cc] ADDINT
[-cc] SUBCONST
[-cc] SUBINT | x - x+cc | -128 <= cc <= 127 . | 26 |
B608 | MIN | x y - x or y | Computes the minimum of two integers x and y . | 26 |
A985 | MULDIVR | x y z - q' | q'=round(x*y/z) | 26 |
A7cc | [cc] MULCONST
[cc] MULINT | x - x*cc | -128 <= cc <= 127 . | 26 |
A5 | DEC | x - x-1 | Equivalent to -1 ADDCONST . | 18 |
A908 | MOD | x y - r | 26 | |
A938tt | [tt+1] MODPOW2# | x - x mod 2^(tt+1) | 34 | |
B609 | MAX | x y - x or y | Computes the maximum of two integers x and y . | 26 |
AE | POW2 | y - 2^y |
| 18 |
A906 | DIVC | x y - q'' | q''=ceil(x/y) , r''=x-y*q'' | 26 |
B60B | ABS | x - |x| | Computes the absolute value of an integer x . | 26 |
A986 | MULDIVC | x y z - q' | q'=ceil(x*y/z) | 26 |
A90C | DIVMOD | x y - q r | 26 | |
B2 | XOR | x y - x xor y | Bitwise xor of two integers. | 18 |
A98C | MULDIVMOD | x y z - q r | q=floor(x*y/z) , r=x*y-z*q | 26 |
B603 | UBITSIZE | x - c | Computes smallest c >= 0 such that x fits into a c -bit unsigned integer (0 <= x < 2^c ), or throws a range check exception. | 26 |
B601 | UFITSX | x c - x | Checks whether x is a c -bit unsigned integer for 0 <= c <= 1023 . | 26/76 |
AC | LSHIFT | x y - x*2^y | 0 <= y <= 1023 | 18 |
A935tt | [tt+1] RSHIFTR# | x - round(x/2^(tt+1)) | 34 | |
AD | RSHIFT | x y - floor(x/2^y) | 0 <= y <= 1023 | 18 |
A9B5tt | [tt+1] MULRSHIFTR# | x y - round(x*y/2^(tt+1)) | 34 | |
A936tt | [tt+1] RSHIFTC# | x - ceil(x/2^(tt+1)) | 34 | |
B7A8 | QMUL | x y - x*y | 26 | |
B7A98C | QMULDIVMOD | x y z - q r | 34 | |
A9D6tt | [tt+1] LSHIFT#DIVC | x y - ceil(2^(tt+1)*x/y) | 26 | |
A9D5tt | [tt+1] LSHIFT#DIVR | x y - round(2^(tt+1)*x/y) | 34 | |
A9BD | MULRSHIFTR#MOD | x y - q=round(x*y/2^(tt+1)) r=xy-q*2^(tt+1) | 34 | |
A9CD | LSHIFTDIVMODR | x y z - q=round(2^z*x/y) r=2^z*x-q*y | 26 | |
A925 | RSHIFTR | x y - round(x/2^y) | 26 | |
B5cc | [cc+1] UFITS | x - x | Checks whether x is a cc+1 -bit unsigned integer for 0 <= cc <= 255 (i.e., whether 0 <= x < 2^(cc+1) ). | 26/76 |
A905 | DIVR | x y - q' | q'=round(x/y) , r'=x-y*q' | 26 |
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
BA | EQUAL | x y - x=y | Returns -1 if x=y , 0 otherwise. | 18 |
BE | GEQ | x y - x>=y | Equivalent to LESS NOT . | 18 |
C0yy | [yy] EQINT | x - x=yy | Returns | 26 |
C705 | SDEQ | s s' - ? | Checks whether the data parts of s and s' coincide, equivalent to SDLEXCMP ISZERO . | 26 |
C2yy | [yy] GTINT
[yy+1] GEQINT | x - x>yy | Returns | 26 |
C700 | SEMPTY | s - ? | Checks whether a Slice s is empty (i.e., contains no bits of data and no cell references). | 26 |
BC | GREATER | x y - x>y | 18 | |
B9 | LESS | x y - x<y | Returns -1 if x<y , 0 otherwise. | 18 |
C1yy | [yy] LESSINT
[yy-1] LEQINT | x - x<yy | Returns | 26 |
C3yy | [yy] NEQINT | x - x!=yy | Returns | 26 |
BB | LEQ | x y - x<=y | 18 | |
BD | NEQ | x y - x!=y | Equivalent to EQUAL NOT . | 18 |
C701 | SDEMPTY | s - ? | Checks whether Slice s has no bits of data. | 26 |
C702 | SREMPTY | s - ? | Checks whether Slice s has no references. | 26 |
C70B | SDPPFXREV | s s' - ? | Checks whether s' is a proper prefix of s . | 26 |
C704 | SDLEXCMP | s s' - x | Compares the data of s lexicographically with the data of s' , returning -1 , 0, or 1 depending on the result. | 26 |
C4 | ISNAN | x - x=NaN | Checks whether x is a NaN . | 18 |
BF | CMP | x y - sgn(x-y) | Computes the sign of | 18 |
C709 | SDPFXREV | s s' - ? | Checks whether s' is a prefix of s , equivalent to SWAP SDPFX . | 26 |
C713 | SDCNTTRAIL1 | s - n | Returns the number of trailing ones in s . | 26 |
B8 | SGN | x - sgn(x) | Computes the sign of an integer | 18 |
C703 | SDFIRST | s - ? | Checks whether the first bit of Slice s is a one. | 26 |
C710 | SDCNTLEAD0 | s - n | Returns the number of leading zeroes in s . | 26 |
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
D3cc | [cc+1] LDU | s - x s' | Loads an unsigned cc+1 -bit integer x from Slice s . | 26 |
CBcc | [cc+1] STU | x b - b' | Stores an unsigned cc+1 -bit integer x into Builder b . In all other respects it is similar to STI . | 26 |
D0 | CTOS | c - s | Converts a Cell into a Slice. Notice that c must be either an ordinary cell, or an exotic cell which is automatically loaded to yield an ordinary cell c' , converted into a Slice afterwards. | 118/43 |
C8 | NEWC | - b | Creates a new empty Builder. | 18 |
C9 | ENDC | b - c | Converts a Builder into an ordinary Cell. | 518 |
CF16 | STSLICER | b s - b' | Equivalent to SWAP STSLICE . | 26 |
D4 | LDREF | s - c s' | Loads a cell reference c from s . | 18 |
D718 | LDSLICEX | s l - s'' s' | Loads the first 0 <= l <= 1023 bits from Slice s into a separate Slice s'' , returning the remainder of s as s' . | 26 |
D74E_n | [n] PLDREFIDX | s - c | Returns the n -th cell reference of Slice s , where 0 <= n <= 3 . | 26 |
CC | STREF | c b - b' | Stores a reference to Cell c into Builder b . | 18 |
D749 | SBITS | s - l | Returns the number of data bits in Slice s . | 26 |
D70Bcc | [cc+1] PLDU | s - x | Preloads an unsigned cc+1 -bit integer from s . | 34 |
CAcc | [cc+1] STI | x b - b' | Stores a signed cc+1 -bit integer x into Builder b for 0 <= cc <= 255 , throws a range check exception if x does not fit into cc+1 bits. | 26 |
D2cc | [cc+1] LDI | s - x s' | Loads (i.e., parses) a signed cc+1 -bit integer x from Slice s , and returns the remainder of s as s' . | 26 |
D1 | ENDS | s - | Removes a Slice s from the stack, and throws an exception if it is not empty. | 18/68 |
D721 | SDSKIPFIRST | s l - s' | Returns all but the first 0 <= l <= 1023 bits of s . It is equivalent to LDSLICEX NIP . | 26 |
CF00 | STIX | x b l - b' | Stores a signed l -bit integer x into b for 0 <= l <= 257 . | 26 |
CF01 | STUX | x b l - b' | Stores an unsigned l -bit integer x into b for 0 <= l <= 256 . | 26 |
CF31 | BBITS | b - x | Returns the number of data bits already stored in Builder b . | 26 |
CF17 | STBR
BCONCAT | b b' - b'' | Concatenates two builders.
Equivalent to | 26 |
D74A | SREFS | s - r | Returns the number of references in Slice s . | 26 |
D6cc | [cc+1] LDSLICE | s - s'' s' | Cuts the next cc+1 bits of s into a separate Slice s'' . | 26 |
D70Acc | [cc+1] PLDI | s - x | Preloads a signed cc+1 -bit integer from Slice s . | 34 |
D719 | PLDSLICEX | s l - s'' | Returns the first 0 <= l <= 1023 bits of s as s'' . | 26 |
CF40 | STZEROES | b n - b' | Stores n binary zeroes into Builder b . | 26 |
D701 | LDUX | s l - x s' | Loads an unsigned l -bit integer x from (the first l bits of) s , with 0 <= l <= 256 . | 26 |
CE | STSLICE | s b - b' | Stores Slice s into Builder b . | 18 |
D736 | SPLIT | s l r - s' s'' | Splits the first 0 <= l <= 1023 data bits and first 0 <= r <= 4 references from s into s' , returning the remainder of s as s'' . | 26 |
D700 | LDIX | s l - x s' | Loads a signed l -bit (0 <= l <= 257 ) integer x from Slice s , and returns the remainder of s as s' . | 26 |
D723 | SDSKIPLAST | s l - s' | Returns all but the last 0 <= l <= 1023 bits of s . | 26 |
D722 | SDCUTLAST | s l - s' | Returns the last 0 <= l <= 1023 bits of s . | 26 |
D74B | SBITREFS | s - l r | Returns both the number of data bits and the number of references in s . | 26 |
D5 | LDREFRTOS | s - s' s'' | Equivalent to LDREF SWAP CTOS . | 118/43 |
D724 | SDSUBSTR | s l l' - s' | Returns 0 <= l' <= 1023 bits of s starting from offset 0 <= l <= 1023 , thus extracting a bit substring out of the data of s . | 26 |
CF13 | STB | b' b - b'' | Appends all data from Builder b' to Builder b . | 26 |
D739 | XCTOS | c - s ? | Transforms an ordinary or exotic cell into a Slice, as if it were an ordinary cell. A flag is returned indicating whether c is exotic. If that be the case, its type can later be deserialized from the first eight bits of s . |
|
D703 | PLDUX | s l - x | Preloads an unsigned l -bit integer from s , for 0 <= l <= 256 . | 26 |
D765 | CDEPTH | c - x | Returns the depth of Cell c . If c has no references, then x=0 ; otherwise x is one plus the maximum of depths of cells referred to from c . If c is a Null instead of a Cell, returns zero. | 26 |
CFC0_xysss | [slice] STSLICECONST | b - b' | Stores a constant subslice | 24 |
D720 | SDCUTFIRST | s l - s' | Returns the first 0 <= l <= 1023 bits of s . It is equivalent to PLDSLICEX . | 26 |
D764 | SDEPTH | s - x | Returns the depth of Slice s . If s has no references, then x=0 ; otherwise x is one plus the maximum of depths of cells referred to from s . | 26 |
CF41 | STONES | b n - b' | Stores n binary ones into Builder b . | 26 |
D72E_xsss | [slice] SDBEGINSQ | s - s'' -1 or s 0 | A quiet version of SDBEGINS . | 31 |
D732 | SCUTLAST | s l r - s' | Returns the last 0 <= l <= 1023 data bits and last 0 <= r <= 4 references of s . | 26 |
D751 | LDULE4 | s - x s' | Loads a little-endian unsigned 32-bit integer. | 26 |
CF11 | STBREF | b' b - b'' | Equivalent to SWAP STBREFR . | 526 |
CF23 | ENDXC | b x - c | If | 526 |
D714_c | [32(c+1)] PLDUZ | s - s x | Preloads the first 32(c+1) bits of Slice s into an unsigned integer x , for 0 <= c <= 7 . If s is shorter than necessary, missing bits are assumed to be zero. This operation is intended to be used along with IFBITJMP and similar instructions. | 26 |
D71Dcc | [cc+1] PLDSLICE | s - s'' | Returns the first 0 < cc+1 <= 256 bits of s as s'' . | 34 |
CF0Bcc | [cc+1] STUR | b x - b' | Equivalent to SWAP [cc+1] STU . | 34 |
D72A_xsss | [slice] SDBEGINS | s - s'' | Checks whether s begins with constant bitstring sss of length 8x+3 (with continuation bit assumed), where 0 <= x <= 127 , and removes sss from s on success. | 31 |
CF3D | BCHKBITSQ | b x - ? | Checks whether x bits can be stored into b , 0 <= x <= 1023 . | 26 |
CF29 | STULE4 | x b - b' | Stores a little-endian unsigned 32-bit integer. | 26 |
D705 | LDUXQ | s l - x s' -1 or s 0 | Quiet version of LDUX . | 26 |
CF0Acc | [cc+1] STIR | b x - b' | Equivalent to SWAP [cc+1] STI . | 34 |
CF14 | STREFR | b c - b' | Equivalent to SWAP STREF . | 26 |
D73A | XLOAD | c - c' | Loads an exotic cell c and returns an ordinary cell c' . If c is already ordinary, does nothing. If c cannot be loaded, throws an exception. |
|
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
E0 | IFJMP | f c - | Jumps to c (similarly to JMPX ), but only if f is non-zero. | 18 |
DB3C | [ref] CALLREF |
| Equivalent to PUSHREFCONT CALLX . | 126/51 |
ED5i | c[i] POPCTR
c[i] POP | x - | Pops a value x from the stack and stores it into control register c(i) , if supported in the current codepage. Notice that if a control register accepts only values of a specific type, a type-checking exception may occur. | 26 |
DD | IFNOTRET
IF: | f - | Performs a RET , but only if integer f is zero. | 18 |
ED4i | c[i] PUSHCTR
c[i] PUSH | - x | Pushes the current value of control register c(i) . If the control register is not supported in the current codepage, or if it does not have a value, an exception is triggered. | 26 |
F0nn | [nn] CALL
[nn] CALLDICT | - nn | Calls the continuation in |
|
E2 | IFELSE | f c c' - | If integer f is non-zero, executes c , otherwise executes c' . Equivalent to CONDSELCHK EXECUTE . | 18 |
E302 | [ref] IFJMPREF | f - | Equivalent to PUSHREFCONT IFJMP . | 26/126/51 |
DE | IF | f c - | Performs EXECUTE for c (i.e., executes c ), but only if integer f is non-zero. Otherwise simply discards both values. | 18 |
E30D | [ref] IFREFELSE | f c - | Equivalent to PUSHREFCONT SWAP IFELSE , with the optimization that the cell reference is not actually loaded into a Slice and then converted into an ordinary Continuation if f=0 . Similar remarks apply to the next two primitives: cells are converted into continuations only when necessary. | 26/126/51 |
E6 | UNTIL | c - | Executes continuation c , then pops an integer x from the resulting stack. If x is zero, performs another iteration of this loop. The actual implementation of this primitive involves an extraordinary continuation ec_until with its arguments set to the body of the loop (continuation c ) and the original current continuation cc . This extraordinary continuation is then saved into the savelist of c as c.c0 and the modified c is then executed. The other loop primitives are implemented similarly with the aid of suitable extraordinary continuations. | 18 |
EDFB | SAMEALTSAVE | - | Sets | 26 |
E8 | WHILE | c' c - | Executes c' and pops an integer x from the resulting stack. If x is zero, exists the loop and transfers control to the original cc . If x is non-zero, executes c , and then begins a new iteration. | 18 |
EDAi | c[i] SAVE
c[i] SAVECTR |
| Saves the current value of c(i) into the savelist of continuation c0 . If an entry for c[i] is already present in the savelist of c0 , nothing is done. Equivalent to c[i] PUSHCTR c[i] SETRETCTR . | 26 |
D8 | EXECUTE
CALLX | c - | Calls, or executes, continuation c . | 18 |
E300 | [ref] IFREF | f - | Equivalent to | 26/126/51 |
E1 | IFNOTJMP | f c - | Jumps to c (similarly to JMPX ), but only if f is zero. | 18 |
E30F | [ref] [ref] IFREFELSEREF | f - | Equivalent to PUSHREFCONT PUSHREFCONT IFELSE . | 126/51 |
E30E | [ref] IFELSEREF | f c - | Equivalent to PUSHREFCONT IFELSE . | 26/126/51 |
DC | IFRET
IFNOT: | f - | Performs a RET , but only if integer f is non-zero. If f is a NaN , throws an integer overflow exception. | 18 |
DF | IFNOT | f c - | Executes continuation c , but only if integer f is zero. Otherwise simply discards both values. | 18 |
E4 | REPEAT | n c - | Executes continuation | 18 |
ED6i | c[i] SETCONT
c[i] SETCONTCTR | x c - c' | Stores x into the savelist of continuation c as c(i) , and returns the resulting continuation c' . Almost all operations with continuations may be expressed in terms of SETCONTCTR , POPCTR , and PUSHCTR . | 26 |
EDF1 | COMPOSALT
BOOLOR | c c' - c'' | Computes the alternative composition compose1(c, c') , which has the meaning of ''perform c , and, if not successful, perform c' '' (if c is a boolean circuit). Equivalent to SWAP c1 SETCONT . | 26 |
ED11 | SETCONTVARARGS | x_1 x_2...x_r c r n - c' | Similar to SETCONTARGS , but with 0 <= r <= 255 and -1 <= n <= 255 taken from the stack. | 26+s'' |
DB0p | [p] -1 CALLXARGS | c - | Calls continuation c with 0 <= p <= 15 parameters, expecting an arbitrary number of return values. | 26 |
E303 | [ref] IFNOTJMPREF | f - | Equivalent to PUSHREFCONT IFNOTJMP . | 26/126/51 |
F12_n | [n] CALL
[n] CALLDICT | - n | For 0 <= n < 2^14 , an encoding of [n] CALL for larger values of n . |
|
ED1E | BLESS | s - c | Transforms a Slice s into a simple ordinary continuation c , with c.code=s and an empty stack and savelist. | 26 |
DApr | [p] [r] CALLXARGS | c - | Calls continuation | 26 |
E301 | [ref] IFNOTREF | f - | Equivalent to PUSHREFCONT IFNOT . | 26/126/51 |
D9 | JMPX | c - | Jumps, or transfers control, to continuation | 18 |
F1A_n | [n] PREPARE
[n] PREPAREDICT | - n c | Equivalent to |
|
E308 | IFRETALT | f - | Performs RETALT if integer f!=0 . | 26 |
DB35 | JMPXDATA | c - | Similar to CALLCC , but the remainder of the current continuation (the old value of cc ) is converted into a Slice before pushing it into the stack of c . | 26 |
DB4fff | flags RUNVM | x_1 ... x_n n code [r] [c4] [c7] [g_l] [g_m] - x'_1 ... x'_m exitcode [data'] [c4'] [c5] [g_c] | Runs child VM with code code and stack x_1...x_n . Returns the resulting stack x'_1...x'_m and exitcode. Other arguments and return values are enabled by flags. |
|
E309 | IFNOTRETALT | f - | Performs RETALT if integer f=0 . | 26 |
EB | AGAINEND
AGAIN: | - | Similar to AGAIN , but performed with respect to the current continuation cc . | 18 |
ECrn | [r] [n] SETCONTARGS | x_1 x_2...x_r c - c' | Pushes 0 <= r <= 15 values x_1...x_r into the stack of (a copy of) the continuation c , starting with x_1 . When n is 15 (-1 in Fift notation), does nothing with c.nargs . For 0 <= n <= 14 , sets c.nargs to the final size of the stack of c' plus n . In other words, transforms c into a closure or a partially applied function, with 0 <= n <= 14 arguments missing. | 26+s'' |
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
F2E4_n | [n] THROWIFNOT | f - | For 0 <= n < 2^11 , an encoding of [n] THROWIFNOT for larger values of n . | 34/84 |
F2A_n | [n] THROWIFNOT | f - | Throws exception 0 <= n <= 63 with parameter zero only if integer f=0 . | 26/76 |
F26_n | [n] THROWIF | f - | Throws exception 0 <= n <= 63 with parameter zero only if integer f!=0 . | 26/76 |
F2D4_n | [n] THROWIF | f - | For 0 <= n < 2^11 , an encoding of [n] THROWIF for larger values of n . | 34/84 |
F2F0 | THROWANY | n - 0 n | Throws exception | 76 |
F2F4 | THROWANYIFNOT | n f - | Throws exception 0 <= n<2^16 with parameter zero only if f=0 . | 26/76 |
F2F2 | THROWANYIF | n f - | Throws exception 0 <= n < 2^16 with parameter zero only if f!=0 . | 26/76 |
F2C4_n | [n] THROW | - 0 nn | For 0 <= n < 2^11 , an encoding of [n] THROW for larger values of n . | 84 |
F2FF | TRY | c c' - | Sets c2 to c' , first saving the old value of c2 both into the savelist of c' and into the savelist of the current continuation, which is stored into c.c0 and c'.c0 . Then runs c similarly to EXECUTE . If c does not throw any exceptions, the original value of c2 is automatically restored on return from c . If an exception occurs, the execution is transferred to c' , but the original value of c2 is restored in the process, so that c' can re-throw the exception by THROWANY if it cannot handle it by itself. | 26 |
F22_n | [n] THROW | - 0 n | Throws exception | 76 |
F2CC_n | [n] THROWARG | x - x nn | Throws exception 0 <= n < 2^11 with parameter x , by copying x and n into the stack of c2 and transferring control to c2 . | 84 |
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
F400 | STDICT
STOPTREF | D b - b' | Stores dictionary | 26 |
F404 | LDDICT
LDOPTREF | s - D s' | Loads (parses) a dictionary D from Slice s , and returns the remainder of s as s' . May be applied to dictionaries or to values of arbitrary (^Y)? types. | 26 |
F40E | DICTUGET | i D n - x -1 or 0 | Similar to DICTIGET , but with unsigned (big-endian) n -bit Integer i used as a key. |
|
F417 | DICTUSETREF | c i D n - D' | Similar to DICTISETREF , but with i unsigned. |
|
F443 | DICTUSETB | b i D n - D' |
| |
F40A | DICTGET | k D n - x -1 or 0 | Looks up key |
|
F40F | DICTUGETREF | i D n - c -1 or 0 | Similar to DICTIGETREF , but with an unsigned n -bit Integer key i . |
|
F416 | DICTUSET | x i D n - D' | Similar to DICTISET , but with i an unsigned n -bit integer. |
|
F405 | PLDDICT
PLDOPTREF | s - D | Preloads a dictionary | 26 |
F486 | DICTUMIN | D n - x i -1 or 0 | Similar to DICTMIN , but returns the key as an unsigned n -bit Integer i . |
|
F46B | DICTUGETOPTREF | i D n - c^? | DICTGETOPTREF , but with i an unsigned n -bit integer. If the key i is out of range, also returns Null. |
|
F45B | DICTUDEL | i D n - D' ? | Similar to DICTIDEL , but with i an unsigned n -bit integer. |
|
F466 | DICTUDELGET | i D n - D' x -1 or D 0 | DICTDELGET , but with i an unsigned n -bit integer. |
|
F401 | SKIPDICT
SKIPOPTREF | s - s' | Equivalent to LDDICT NIP . | 26 |
F441 | DICTSETB | b k D n - D' |
| |
F47C | DICTUGETNEXT | i D n - x' i' -1 or 0 | Similar to DICTGETNEXT , but interprets all keys in dictionary D as big-endian unsigned n -bit integers, and computes the minimal key i' that is larger than Integer i (which does not necessarily fit into n bits, and is not necessarily non-negative). |
|
F48E | DICTUMAX | D n - x i -1 or 0 | Similar to DICTMAX , but returns the key as an unsigned n -bit Integer i . |
|
F48F | DICTUMAXREF | D n - c i -1 or 0 | Similar to DICTUMAX , but returns the only reference in the value. |
|
F453 | DICTUADDB | b i D n - D' -1 or D 0 |
| |
F4A6_n | [ref] [n] DICTPUSHCONST | - D n | Pushes a non-empty constant dictionary D (as a Cell^? ) along with its key length 0 <= n <= 1023 , stored as a part of the instruction. The dictionary itself is created from the first of remaining references of the current continuation. In this way, the complete DICTPUSHCONST instruction can be obtained by first serializing xF4A4_ , then the non-empty dictionary itself (one 1 bit and a cell reference), and then the unsigned 10-bit integer n (as if by a STU 10 instruction). An empty dictionary can be pushed by a NEWDICT primitive instead. | 34 |
F487 | DICTUMINREF | D n - c i -1 or 0 | Similar to DICTUMIN , but returns the only reference in the value. |
|
F4A1 | DICTUGETJMP | i D n - | Similar to DICTIGETJMP , but performs DICTUGET instead of DICTIGET . |
|
F40D | DICTIGETREF | i D n - c -1 or 0 | Combines DICTIGET with DICTGETREF : it uses signed n -bit Integer i as a key and returns a Cell instead of a Slice on success. |
|
F40C | DICTIGET | i D n - x -1 or 0 | Similar to DICTGET , but with a signed (big-endian) n -bit Integer i as a key. If i does not fit into n bits, returns 0 . If i is a NaN , throws an integer overflow exception. |
|
F4A8 | PFXDICTGETQ | s D n - s' x s'' -1 or s 0 | Looks up the unique prefix of Slice s present in the prefix code dictionary represented by Cell^? D and 0 <= n <= 1023 . If found, the prefix of s is returned as s' , and the corresponding value (also a Slice) as x . The remainder of s is returned as a Slice s'' . If no prefix of s is a key in prefix code dictionary D , returns the unchanged s and a zero flag to indicate failure. |
|
F47F | DICTUGETPREVEQ | i D n - x' i' -1 or 0 | Similar to DICTGETPREVEQ , but interprets keys a unsigned n -bit integers. |
|
F46A | DICTIGETOPTREF | i D n - c^? | DICTGETOPTREF , but with i a signed n -bit integer. If the key i is out of range, also returns Null. |
|
F482 | DICTMIN | D n - x k -1 or 0 | Computes the minimal key k (represented by a Slice with n data bits) in dictionary D , and returns k along with the associated value x . |
|
F40B | DICTGETREF | k D n - c -1 or 0 | Similar to |
|
F470 | PFXDICTSET | x k D n - D' -1 or D 0 |
| |
F4A0 | DICTIGETJMP | i D n - | Similar to DICTIGET , but with x BLESS ed into a continuation with a subsequent JMPX to it on success. On failure, does nothing. This is useful for implementing switch /case constructions. |
|
F44B | DICTUREPLACEB | b i D n - D' -1 or D 0 |
| |
F415 | DICTISETREF | c i D n - D' | Similar to DICTSETREF , but with the key a signed n -bit integer as in DICTISET . |
|
F496 | DICTUREMMIN | D n - D' x i -1 or D 0 | Similar to DICTREMMIN , but returns the key as an unsigned n -bit Integer i . |
|
F41E | DICTUSETGET | x i D n - D' y -1 or D' 0 | DICTISETGET , but with i an unsigned n -bit integer. |
|
F497 | DICTUREMMINREF | D n - D' c i -1 or D 0 | Similar to DICTUREMMIN , but returns the only reference in the value. |
|
F47E | DICTUGETPREV | i D n - x' i' -1 or 0 | Similar to DICTGETPREV , but interprets keys as unsigned n -bit integers. |
|
F484 | DICTIMIN | D n - x i -1 or 0 | Similar to DICTMIN , but computes the minimal key i under the assumption that all keys are big-endian signed n -bit integers. Notice that the key and value returned may differ from those computed by DICTMIN and DICTUMIN . |
|
F436 | DICTUADD | x i D n - D' -1 or D 0 | DICTADD , but with i an unsigned n -bit integer. |
|
F414 | DICTISET | x i D n - D' | Similar to DICTSET , but with the key represented by a (big-endian) signed n -bit integer i . If i does not fit into n bits, a range check exception is generated. |
|
F469 | DICTGETOPTREF | k D n - c^? | A variant of DICTGETREF that returns Null instead of the value c^? if the key k is absent from dictionary D . |
|
F45A | DICTIDEL | i D n - D' ? | A version of DICTDEL with the key represented by a signed n -bit Integer i . If i does not fit into n bits, simply returns D 0 (''key not found, dictionary unmodified''). |
|
F467 | DICTUDELGETREF | i D n - D' c -1 or D 0 | DICTDELGETREF , but with i an unsigned n -bit integer. |
|
F407 | PLDDICTQ | s - D -1 or 0 | A quiet version of PLDDICT . | 26 |
F462 | DICTDELGET | k D n - D' x -1 or D 0 | Deletes n -bit key, represented by a Slice k , from dictionary D . If the key is present, returns the modified dictionary D' , the original value x associated with the key k (represented by a Slice), and the success flag -1 . Otherwise, returns the original dictionary D and 0 . |
|
F478 | DICTIGETNEXT | i D n - x' i' -1 or 0 | Similar to DICTGETNEXT , but interprets all keys in dictionary D as big-endian signed n -bit integers, and computes the minimal key i' that is larger than Integer i (which does not necessarily fit into n bits). |
|
F412 | DICTSET | x k D n - D' | Sets the value associated with n -bit key k (represented by a Slice as in DICTGET ) in dictionary D (also represented by a Slice) to value x (again a Slice), and returns the resulting dictionary as D' . |
|
F413 | DICTSETREF | c k D n - D' | Similar to DICTSET , but with the value set to a reference to Cell c . |
|
F437 | DICTUADDREF | c i D n - D' -1 or D 0 | DICTADDREF , but with i an unsigned n -bit integer. |
|
F485 | DICTIMINREF | D n - c i -1 or 0 | Similar to DICTIMIN , but returns the only reference in the value. |
|
F4BC | DICTIGETJMPZ | i D n - i or nothing | A variant of DICTIGETJMP that returns index i on failure. |
|
F435 | DICTIADDREF | c i D n - D' -1 or D 0 | DICTADDREF , but with i a signed n -bit integer. |
|
F47B | DICTIGETPREVEQ | i D n - x' i' -1 or 0 | Similar to DICTGETPREVEQ , but interprets keys as signed n -bit integers. |
|
F451 | DICTADDB | b k D n - D' -1 or D 0 |
| |
F475 | DICTGETNEXTEQ | k D n - x' k' -1 or 0 | Similar to DICTGETNEXT , but computes the minimal key k' that is lexicographically greater than or equal to k . |
|
F459 | DICTDEL | k D n - D' -1 or D 0 | Deletes n -bit key, represented by a Slice k , from dictionary D . If the key is present, returns the modified dictionary D' and the success flag -1 . Otherwise, returns the original dictionary D and 0 . |
|
F47D | DICTUGETNEXTEQ | i D n - x' i' -1 or 0 | Similar to DICTGETNEXTEQ , but interprets keys as unsigned n -bit integers. |
|
F48A | DICTMAX | D n - x k -1 or 0 | Computes the maximal key k (represented by a Slice with n data bits) in dictionary D , and returns k along with the associated value x . |
|
F442 | DICTISETB | b i D n - D' |
| |
F424 | DICTIREPLACE | x i D n - D' -1 or D 0 | DICTREPLACE , but with i a signed n -bit integer. |
|
F47A | DICTIGETPREV | i D n - x' i' -1 or 0 | Similar to DICTGETPREV , but interprets keys as signed n -bit integers. |
|
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
FA40 | LDMSGADDR | s - s' s'' | Loads from Slice s the only prefix that is a valid MsgAddress , and returns both this prefix s' and the remainder s'' of s as slices. | 26 |
F85_k | [k] GETGLOB | - x | Returns the | 26 |
F82i | [i] GETPARAM | - x | Returns the | 26 |
F87_k | [k] SETGLOB | x - | Assigns | 26+|c7'| |
F901 | HASHSU | s - x | Computes the hash of a Slice s and returns it as a 256-bit unsigned integer x . The result is the same as if an ordinary cell containing only data and references from s had been created and its hash computed by HASHCU . | 526 |
F800 | ACCEPT | - | Sets current gas limit | 26 |
F910 | CHKSIGNU | h s k - ? | Checks the Ed25519-signature | 26 |
FA00 | LDGRAMS
LDVARUINT16 | s - x s' | Loads (deserializes) a | 26 |
FA02 | STGRAMS
STVARUINT16 | b x - b' | Stores (serializes) an Integer x in the range 0...2^120-1 into Builder b , and returns the resulting Builder b' . The serialization of x consists of a 4-bit unsigned big-endian integer l , which is the smallest integer l>=0 , such that x<2^(8l) , followed by an 8l -bit unsigned big-endian representation of x . If x does not belong to the supported range, a range check exception is thrown. | 26 |
FB00 | SENDRAWMSG | c x - | Sends a raw message contained in Cell c , which should contain a correctly serialized object Message X , with the only exception that the source address is allowed to have dummy value addr_none (to be automatically replaced with the current smart-contract address), and ihr_fee , fwd_fee , created_lt and created_at fields can have arbitrary values (to be rewritten with correct values during the action phase of the current transaction). Integer parameter x contains the flags. Currently x=0 is used for ordinary messages; x=128 is used for messages that are to carry all the remaining balance of the current smart contract (instead of the value originally indicated in the message); x=64 is used for messages that carry all the remaining value of the inbound message in addition to the value initially indicated in the new message (if bit 0 is not set, the gas fees are deducted from this amount); x'=x+1 means that the sender wants to pay transfer fees separately; x'=x+2 means that any errors arising while processing this message during the action phase should be ignored. Finally, x'=x+32 means that the current account must be destroyed if its resulting balance is zero. This flag is usually employed together with +128 . | 526 |
F900 | HASHCU | c - x | Computes the representation hash of a Cell c and returns it as a 256-bit unsigned integer x . Useful for signing and checking signatures of arbitrary entities represented by a tree of cells. | 26 |
FA44 | REWRITESTDADDR | s - x y | Parses Slice s containing a valid MsgAddressInt (usually a msg_addr_std ), applies rewriting from the anycast (if present) to the same-length prefix of the address, and returns both the workchain x and the 256-bit address y as integers. If the address is not 256-bit, or if s is not a valid serialization of MsgAddressInt , throws a cell deserialization exception. | 26 |
F836 | GETGASFEE | gas_used is_mc - price | Calculates gas fee |
|
FB02 | RAWRESERVE | x y - | Creates an output action which would reserve exactly x nanograms (if y=0 ), at most x nanograms (if y=2 ), or all but x nanograms (if y=1 or y=3 ), from the remaining balance of the account. It is roughly equivalent to creating an outbound message carrying x nanograms (or b-x nanograms, where b is the remaining balance) to oneself, so that the subsequent output actions would not be able to spend more money than the remainder. Bit +2 in y means that the external action does not fail if the specified amount cannot be reserved; instead, all remaining balance is reserved. Bit +8 in y means x:=-x before performing any further actions. Bit +4 in y means that x is increased by the original balance of the current account (before the compute phase), including all extra currencies, before performing any other checks and actions. Currently x must be a non-negative integer, and y must be in the range 0...15 . | 526 |
F80F | COMMIT | - | Commits the current state of registers c4 (''persistent data'') and c5 (''actions'') so that the current execution is considered ''successful'' with the saved values even if an exception is thrown later. | 26 |
F815 | ADDRAND
RANDOMIZE | x - | Mixes unsigned 256-bit Integer x into the random seed r by setting the random seed to Sha of the concatenation of two 32-byte strings: the first with the big-endian representation of the old seed r , and the second with the big-endian representation of x . | 26 |
F833 | CONFIGOPTPARAM | i - c^? | Returns the value of the global configuration parameter with integer index |
|
F838 | GETFORWARDFEE | cells bits is_mc - price | Calculates forward fee. |
|
F811 | RAND | y - z | Generates a new pseudo-random integer | 26+|c7|+|c1_1| |
F810 | RANDU256 | - x | Generates a new pseudo-random unsigned 256-bit Integer x . The algorithm is as follows: if r is the old value of the random seed, considered as a 32-byte array (by constructing the big-endian representation of an unsigned 256-bit integer), then its sha512(r) is computed; the first 32 bytes of this hash are stored as the new value r' of the random seed, and the remaining 32 bytes are returned as the next random value x . | 26+|c7|+|c1_1| |
F902 | SHA256U | s - x | Computes Sha of the data bits of Slice s . If the bit length of s is not divisible by eight, throws a cell underflow exception. The hash value is returned as a 256-bit unsigned integer x . | 26 |
FA03 | STVARINT16 | b x - b' | Similar to STVARUINT16 , but serializes a signed Integer x in the range -2^119...2^119-1 . | 26 |
FB04 | SETCODE | c - | Creates an output action that would change this smart contract code to that given by Cell c . Notice that this change will take effect only after the successful termination of the current run of the smart contract. | 526 |
F83A | GETORIGINALFWDFEE | fwd_fee is_mc - orig_fwd_fee | Calculate fwd_fee * 2^16 / first_frac . Can be used to get the original fwd_fee of the message. |
|
F801 | SETGASLIMIT | g - | Sets current gas limit g_l to the minimum of g and g_m , and resets the gas credit g_c to zero. If the gas consumed so far (including the present instruction) exceeds the resulting value of g_l , an (unhandled) out of gas exception is thrown before setting new gas limits. Notice that SETGASLIMIT with an argument g >= 2^63-1 is equivalent to ACCEPT . | 26 |
FA46 | REWRITEVARADDR | s - x s' | A variant of REWRITESTDADDR that returns the (rewritten) address as a Slice s , even if it is not exactly 256 bit long (represented by a msg_addr_var ). | 26 |
F911 | CHKSIGNS | d s k - ? | Checks whether s is a valid Ed25519-signature of the data portion of Slice d using public key k , similarly to CHKSIGNU . If the bit length of Slice d is not divisible by eight, throws a cell underflow exception. The verification of Ed25519 signatures is the standard one, with Sha used to reduce d to the 256-bit number that is actually signed. | 26 |
F941 | CDATASIZE | c n - x y z | A non-quiet version of CDATASIZEQ that throws a cell overflow exception (8) on failure. |
|
FA01 | LDVARINT16 | s - x s' | Similar to | 26 |
F93010 | BLS_G1_ADD | x y - x+y | Addition on G1. | 3934 |
F93013 | BLS_G1_MUL | x s - x*s | Multiplies G1 point x by scalar s . Any s is valid, including negative. | 5234 |
F837 | GETSTORAGEFEE | cells bits seconds is_mc - price | Calculates storage fees (only current StoragePrices entry is used). |
|
F90403 | HASHEXT_KECCAK256 | s_1 ... s_n n - h | Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n . | 1/11 gas per byte |
F940 | CDATASIZEQ | c n - x y z -1 or 0 | Recursively computes the count of distinct cells x , data bits y , and cell references z in the dag rooted at Cell c , effectively returning the total storage used by this dag taking into account the identification of equal cells. The values of x , y , and z are computed by a depth-first traversal of this dag, with a hash table of visited cell hashes used to prevent visits of already-visited cells. The total count of visited cells x cannot exceed non-negative Integer n ; otherwise the computation is aborted before visiting the (n+1) -st cell and a zero is returned to indicate failure. If c is Null, returns x=y=z=0 . |
|
F839 | GETPRECOMPILEDGAS | - x | Returns gas usage for the current contract if it is precompiled, null otherwise. |
|
F83C | GETFORWARDFEESIMPLE | cells bits is_mc - price | Same as GETFORWARDFEE , but without lump price (just (bits*bit_price + cells*cell_price) / 2^16 ). |
|
F807 | GASCONSUMED | - g_c | Returns gas consumed by VM so far (including this instruction). | 26 |
F814 | SETRAND | x - | Sets the random seed to unsigned 256-bit Integer x . | 26+|c7|+|c1_1| |
F912 | ECRECOVER | hash v r s - 0 or h x1 x2 -1 | Recovers the public key from a secp256k1 signature, identical to Bitcoin/Ethereum operations. Takes a 32-byte hash as uint256 hash and a 65-byte signature as uint8 v , uint256 r , and uint256 s . In TON, the v value is strictly 0 or 1; no extra flags or extended values are supported. If the public key cannot be recovered, the instruction returns 0 . On success, it returns the recovered 65-byte public key as uint8 h , uint256 x1 , and uint256 x2 , followed by -1 . | 1526 |
F93012 | BLS_G1_NEG | x - -x | Negation on G1. | 784 |
F93030 | BLS_PAIRING | x_1 y_1 ... x_n y_n n - bool | Given G1 points x_i and G2 points y_i , calculates and multiply pairings of x_i,y_i . Returns true if the result is the multiplicative identity in FP12, false otherwise. Returns false if n=0 . | 20034+n*11800 |
F90400 | HASHEXT_SHA256 | s_1 ... s_n n - h | Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n . | 1/33 gas per byte |
FA42 | PARSEMSGADDR | s - t | Decomposes Slice s containing a valid MsgAddress into a Tuple t with separate fields of this MsgAddress . If s is not a valid MsgAddress , a cell deserialization exception is thrown. | 26 |
FA41 | LDMSGADDRQ | s - s' s'' -1 or s 0 | A quiet version of LDMSGADDR : on success, pushes an extra -1 ; on failure, pushes the original s and a zero. | 26 |
F943 | SDATASIZE | s n - x y z | A non-quiet version of SDATASIZEQ that throws a cell overflow exception (8) on failure. |
|
FB06 | SETLIBCODE | c x - | Creates an output action that would modify the collection of this smart contract libraries by adding or removing library with code given in Cell c . If x=0 , the library is actually removed if it was previously present in the collection (if not, this action does nothing). If x=1 , the library is added as a private library, and if x=2 , the library is added as a public library (and becomes available to all smart contracts if the current smart contract resides in the masterchain); if the library was present in the collection before, its public/private status is changed according to x . Values of x other than 0...2 are invalid. | 526 |
F83400 | PREVMCBLOCKS | - t | Retrives last_mc_blocks part of PrevBlocksInfo from c7 (parameter 13). |
|
FB08 | SENDMSG | c x - fee | Creates an output action and returns a fee for creating a message. Mode has the same effect as in the case of SENDRAWMSG . Additionally +1024 means - do not create an action, only estimate fee. Other modes affect the fee calculation as follows: +64 substitutes the entire balance of the incoming message as an outcoming value (slightly inaccurate, gas expenses that cannot be estimated before the computation is completed are not taken into account), +128 substitutes the value of the entire balance of the contract before the start of the computation phase (slightly inaccurate, since gas expenses that cannot be estimated before the completion of the computation phase are not taken into account). | 526 |
F83401 | PREVKEYBLOCK | - t | Retrives prev_key_block part of PrevBlocksInfo from c7 (parameter 13). |
|
F924 | RIST255_MUL | x n - x*n | Multiplies point x by a scalar n . Any n is valid, including negative. | 2026 |
F90600 | HASHEXTA_SHA256 | b s_1 ... s_n n - b' | Calculates hash of the concatenation of slices (or builders) s_1...s_n . Appends the resulting hash to a builder b . | 1/33 gas per byte |
F925 | RIST255_MULBASE | n - g*n | Multiplies the generator point g by a scalar n . Any n is valid, including negative. | 776 |
F840 | GETGLOBVAR | k - x | Returns the | 26 |
F83B | GETGASFEESIMPLE | gas_used is_mc - price | Same as GETGASFEE , but without flat price (just (gas_used * price) / 2^16) . |
|
F835 | GLOBALID | - i | Retrieves global_id from 19 network config. |
|
F90401 | HASHEXT_SHA512 | s_1 ... s_n n - h1 h2 | Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n . | 1/16 gas per byte |
F920 | RIST255_FROMHASH | h1 h2 - x | Deterministically generates a valid point x from a 512-bit hash (given as two 256-bit integers). | 626 |
F926 | RIST255_PUSHL | - l | Pushes integer l=2^252+27742317777372353535851937790883648493, which is the order of the group. | 26 |
F923 | RIST255_SUB | x y - x-y | Subtraction of two points on curve. | 626 |
F921 | RIST255_VALIDATE | x - | Checks that integer x is a valid representation of some curve point. Throws range_chk on error. | 226 |
F93014 | BLS_G1_MULTIEXP | x_1 s_1 ... x_n s_n n - x_1*s_1+...+x_n*s_n | Calculates x_1*s_1+...+x_n*s_n for G1 points x_i and scalars s_i . Returns zero point if n=0 . Any s_i is valid, including negative. | 11409+n*630+n/floor(max(log2(n),4))*8820 |
FA45 | REWRITESTDADDRQ | s - x y -1 or 0 | A quiet version of primitive REWRITESTDADDR . | 26 |
F914 | P256_CHKSIGNU | h sig k - ? | Checks seck256r1-signature sig of a number h (a 256-bit unsigned integer, usually computed as the hash of some data) and public key k . Returns -1 on success, 0 on failure. Public key is a 33-byte slice (encoded according to Sec. 2.3.4 point 2 of SECG SEC 1). Signature sig is a 64-byte slice (two 256-bit unsigned integers r and s ). | 3526 |
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
FFnn | [nn] SETCP | - | Selects TVM codepage 0 <= nn < 240 . If the codepage is not supported, throws an invalid opcode exception. | 26 |
FEij | {i*16+j} DEBUG | - | 26 |