Fift: s[i] PUSH
Description: Pushes a copy of the old s[i] into the stack.
Category: stack_basic Stack Basic
Alias: DUP Same as s0 PUSH.
Alias: OVER Same as s1 PUSH.
Fift: s[i] POP
Description: Pops the old s0 value into the old s[i].
Category: stack_basic Stack Basic
Alias: DROP Same as s0 POP, discards the top-of-stack value.
Alias: NIP Same as s1 POP.
Fift: [x] PUSHINT
[x] INT
Description: Pushes integer x into the stack. -5 <= x <= 10.
Here i equals four lower-order bits of x (i=x mod 16).
Category: const_int Const Int
Alias: ZERO
Alias: ONE
Alias: TWO
Alias: TEN
Alias: TRUE
Fift: [builder] PUSHCONT
[builder] CONT
Description: Pushes a continuation made from builder.
Details: Pushes an x-byte continuation for 0 <= x <= 15.
Category: const_data Const Data
Fift: [i+1] [j+1] BLKSWAP
Description: Permutes two blocks s[j+i+1] ... s[j+1] and s[j] ... s0.
0 <= i,j <= 15
Equivalent to [i+1] [j+1] REVERSE[j+1] 0 REVERSE[i+j+2] 0 REVERSE.
Category: stack_complex Stack Complex
Alias: ROT2 Rotates the three topmost pairs of stack entries.
Alias: ROLL Rotates the top i+1 stack entries.
Equivalent to 1 [i+1] BLKSWAP.
Alias: ROLLREV Rotates the top i+1 stack entries in the other direction.
Equivalent to [i+1] 1 BLKSWAP.
Fift: CHKDEPTH
Description: Pops integer i from the stack, then checks whether there are at least i elements, generating a stack underflow exception otherwise.
Category: stack_complex Stack Complex
Fift: ONLYX
Description: Pops integer i from the stack, then leaves only the bottom i elements. Approximately equivalent to DEPTHSWAPSUBDROPX.
Category: stack_complex Stack Complex
Fift: NULL
PUSHNULL
Description: Pushes the only value of type Null.
Category: tuple Tuple
Alias: NEWDICT Returns a new empty dictionary.
It is an alternative mnemonics for PUSHNULL.
Fift: ISNULL
Description: Checks whether x is a Null, and returns -1 or 0 accordingly.
Category: tuple Tuple
Alias: DICTEMPTY Checks whether dictionary D is empty, and returns -1 or 0 accordingly.
It is an alternative mnemonics for ISNULL.
Fift: [xxx] PUSHINT
[xxx] INT
Description: Pushes integer xxx.
Details: 5-bit 0 <= l <= 30 determines the length n=8l+19 of signed big-endian integer xxx.
The total length of this instruction is l+4 bytes or n+13=8l+32 bits.
Category: const_int Const Int
Fift: [ref] PUSHREF
Description: Pushes the reference ref into the stack.
Details: Pushes the first reference of cc.code into the stack as a Cell (and removes this reference from the current continuation).
Category: const_data Const Data
Fift: [ref] PUSHREFCONT
Description: Similar to PUSHREFSLICE, but makes a simple ordinary Continuation out of the cell.
Category: const_data Const Data
Fift: [slice] PUSHSLICE
[slice] SLICE
Description: Pushes the slice slice into the stack.
Details: Pushes the (prefix) subslice of cc.code consisting of its first 8x+4 bits and no references (i.e., essentially a bitstring), where 0 <= x <= 15.
A completion tag is assumed, meaning that all trailing zeroes and the last binary one (if present) are removed from this bitstring.
If the original bitstring consists only of zeroes, an empty slice will be pushed.
Category: const_data Const Data
Fift: [slice] PUSHSLICE
[slice] SLICE
Description: Pushes the slice slice into the stack.
Details: Pushes the (prefix) subslice of cc.code consisting of its first 1 <= r+1 <= 4 references and up to first 8xx+1 bits of data, with 0 <= xx <= 31.
A completion tag is also assumed.
Category: const_data Const Data
Fift: [slice] PUSHSLICE
[slice] SLICE
Description: Pushes the slice slice into the stack.
Details: Pushes the subslice of cc.code consisting of 0 <= r <= 4 references and up to 8xx+6 bits of data, with 0 <= xx <= 127.
A completion tag is assumed.
Category: const_data Const Data
Fift: NEGATE
Description: Equivalent to -1 MULCONST or to ZERO SUBR.
Notice that it triggers an integer overflow exception if x=-2^256.
Category: arithm_basic Arithm Basic
Fift: [cc+1] FITS
Description: Checks whether x is a cc+1-bit signed integer for 0 <= cc <= 255 (i.e., whether -2^cc <= x < 2^cc).
If not, either triggers an integer overflow exception, or replaces x with a NaN (quiet version).
Category: arithm_logical Arithm Logical
Alias: CHKBOOL Checks whether x is a ”boolean value” (i.e., either 0 or -1).
Fift: [cc+1] UFITS
Description: Checks whether x is a cc+1-bit unsigned integer for 0 <= cc <= 255 (i.e., whether 0 <= x < 2^(cc+1)).
Category: arithm_logical Arithm Logical
Alias: CHKBIT Checks whether x is a binary digit (i.e., zero or one).
Fift: CMP
Description: Computes the sign of x-y:
-1 if x<y, 0 if x=y, 1 if x>y.
No integer overflow can occur here unless x or y is a NaN.
Category: compare_int Compare Int
Fift: [cc+1] STI
Description: Stores a signed cc+1-bit integer x into Builderb for 0 <= cc <= 255, throws a range check exception if x does not fit into cc+1 bits.
Category: cell_build Cell Build
Fift: [cc+1] STU
Description: Stores an unsigned cc+1-bit integer x into Builderb. In all other respects it is similar to STI.
Category: cell_build Cell Build
Fift: STSLICE
Description: Stores Slices into Builderb.
Category: cell_build Cell Build
Alias: STDICTS Stores a Slice-represented dictionary s into Builderb.
It is actually a synonym for STSLICE.
Fift: CTOS
Description: 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.
Category: cell_parse Cell Parse
Fift: [cc+1] LDI
Description: Loads (i.e., parses) a signed cc+1-bit integer x from Slices, and returns the remainder of s as s'.
Category: cell_parse Cell Parse
Fift: JMPX
Description: Jumps, or transfers control, to continuation c.
The remainder of the previous current continuation cc is discarded.
Category: cont_basic Cont Basic
Fift: [p] [r] CALLXARGS
Description: Calls continuation c with p parameters and expecting r return values
0 <= p <= 15, 0 <= r <= 15
Category: cont_basic Cont Basic
Fift: IFRET
IFNOT:
Description: Performs a RET, but only if integer f is non-zero. If f is a NaN, throws an integer overflow exception.
Category: cont_conditional Cont Conditional
Fift: IF
Description: Performs EXECUTE for c (i.e., executesc), but only if integer f is non-zero. Otherwise simply discards both values.
Category: cont_conditional Cont Conditional
Fift: IFNOT
Description: Executes continuation c, but only if integer f is zero. Otherwise simply discards both values.
Category: cont_conditional Cont Conditional
Fift: IFELSE
Description: If integer f is non-zero, executes c, otherwise executes c'. Equivalent to CONDSELCHKEXECUTE.
Category: cont_conditional Cont Conditional
Fift: REPEAT
Description: Executes continuation cn times, if integer n is non-negative. If n>=2^31 or n<-2^31, generates a range check exception.
Notice that a RET inside the code of c works as a continue, not as a break. One should use either alternative (experimental) loops or alternative RETALT (along with a SETEXITALT before the loop) to break out of a loop.
Category: cont_loops Cont Loops
Fift: UNTIL
Description: 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.
Category: cont_loops Cont Loops
Fift: UNTILEND
UNTIL:
Description: Similar to UNTIL, but executes the current continuation cc in a loop. When the loop exit condition is satisfied, performs a RET.
Category: cont_loops Cont Loops
Fift: WHILE
Description: 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.
Category: cont_loops Cont Loops
Fift: AGAIN
Description: Similar to REPEAT, but executes c infinitely many times. A RET only begins a new iteration of the infinite loop, which can be exited only by an exception, or a RETALT (or an explicit JMPX).
Category: cont_loops Cont Loops
Fift: [r] [n] SETCONTARGS
Description: 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.
Category: cont_stack Cont Stack
Alias: SETNUMARGS Sets c.nargs to n plus the current depth of c’s stack, where 0 <= n <= 14. If c.nargs is already set to a non-negative value, does nothing.
Alias: SETCONTARGS Pushes 0 <= r <= 15 values x_1...x_r into the stack of (a copy of) the continuation c, starting with x_1. If the final depth of c’s stack turns out to be greater than c.nargs, a stack overflow exception is generated.
Fift: [r] [n] BLESSARGS
Description: 0 <= r <= 15, -1 <= n <= 14
Equivalent to BLESS[r] [n] SETCONTARGS.
The value of n is represented inside the instruction by the 4-bit integer n mod 16.
Category: cont_create Cont Create
Alias: BLESSNUMARGS Also transforms a Slices into a Continuationc, but sets c.nargs to 0 <= n <= 14.
Fift: [nn] CALL
[nn] CALLDICT
Description: Calls the continuation in c3, pushing integer 0 <= nn <= 255 into its stack as an argument.
Approximately equivalent to [nn] PUSHINTc3 PUSHCTREXECUTE.
Category: cont_dict Cont Dict
Fift: [p] [r] TRYARGS
Description: Similar to TRY, but with [p] [r] CALLXARGS internally used instead of EXECUTE.
In this way, all but the top 0 <= p <= 15 stack elements will be saved into current continuation’s stack, and then restored upon return from either c or c', with the top 0 <= r <= 15 values of the resulting stack of c or c' copied as return values.
Category: exceptions Exceptions
Fift: {i*16+j} DEBUG
Description:
Category: debug Debug
Alias: DUMPSTK Dumps the stack (at most the top 255 values) and shows the total stack depth. Does nothing on production versions of TVM.
Alias: STRDUMP Dumps slice with length divisible by 8 from top of stack as a string. Does nothing on production versions of TVM.
Alias: DUMP Dumps slice with length divisible by 8 from top of stack as a string. Does nothing on production versions of TVM.
Fift: [nn] SETCP
Description: Selects TVM codepage 0 <= nn < 240. If the codepage is not supported, throws an invalid opcode exception.
Category: codepage Codepage
Alias: SETCP0 Selects TVM (test) codepage zero as described in this document.
Fift: [n] TUPLE
Description: Creates a new Tuplet=(x_1, ... ,x_n) containing n values x_1,…, x_n.
0 <= n <= 15
Category: tuple Tuple
Alias: NIL Pushes the only Tuplet=() of length zero.
Alias: SINGLE Creates a singleton t:=(x), i.e., a Tuple of length one.
Alias: PAIR Creates pair t:=(x,y).
Alias: TRIPLE Creates triple t:=(x,y,z).
Fift: [k] INDEX
Description: Returns the k-th element of a Tuplet.
0 <= k <= 15.
Category: tuple Tuple
Alias: FIRST Returns the first element of a Tuple.
Alias: SECOND Returns the second element of a Tuple.
Alias: THIRD Returns the third element of a Tuple.
Fift: [n] UNTUPLE
Description: Unpacks a Tuplet=(x_1,...,x_n) of length equal to 0 <= n <= 15.
If t is not a Tuple, or if |t| != n, a type check exception is thrown.
Category: tuple Tuple
Alias: UNSINGLE Unpacks a singleton t=(x).
Alias: UNPAIR Unpacks a pair t=(x,y).
Alias: UNTRIPLE Unpacks a triple t=(x,y,z).
Fift: [k] UNPACKFIRST
Description: Unpacks first 0 <= k <= 15 elements of a Tuplet.
If |t|<k, throws a type check exception.
Category: tuple Tuple
Alias: CHKTUPLE Checks whether t is a Tuple. If not, throws a type check exception.
Fift: [n] EXPLODE
Description: Unpacks a Tuplet=(x_1,...,x_m) and returns its length m, but only if m <= n <= 15. Otherwise throws a type check exception.
Category: tuple Tuple
Fift: [k] SETINDEX
Description: Computes Tuplet' that differs from t only at position t'_{k+1}, which is set to x.
0 <= k <= 15
If k >= |t|, throws a range check exception.
Category: tuple Tuple
Alias: SETFIRST Sets the first component of Tuplet to x and returns the resulting Tuplet'.
Alias: SETSECOND Sets the second component of Tuplet to x and returns the resulting Tuplet'.
Alias: SETTHIRD Sets the third component of Tuplet to x and returns the resulting Tuplet'.
Fift: [k] INDEXQ
Description: Returns the k-th element of a Tuplet, 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.
Category: tuple Tuple
Alias: FIRSTQ Returns the first element of a Tuple.
Alias: SECONDQ Returns the second element of a Tuple.
Alias: THIRDQ Returns the third element of a Tuple.
Fift: [k] SETINDEXQ
Description: Sets the k-th component of Tuplet to x, where 0 <= k < 16, and returns the resulting Tuplet'.
If |t| <= k, first extends the original Tuple to length n'=k+1 by setting all new components to Null. If the original value of t is Null, treats it as an empty Tuple. If t is not Null or Tuple, throws an exception. If x is Null and either |t| <= k or t is Null, then always returns t'=t (and does not consume tuple creation gas).
Category: tuple Tuple
Alias: SETFIRSTQ Sets the first component of Tuplet to x and returns the resulting Tuplet'.
Alias: SETSECONDQ Sets the second component of Tuplet to x and returns the resulting Tuplet'.
Alias: SETTHIRDQ Sets the third component of Tuplet to x and returns the resulting Tuplet'.
Fift: [p] -1 CALLXARGS
Description: Calls continuation c with 0 <= p <= 15 parameters, expecting an arbitrary number of return values.
Category: cont_basic Cont Basic
Fift: [p] JMPXARGS
Description: Jumps to continuation c, passing only the top 0 <= p <= 15 values from the current stack to it (the remainder of the current stack is discarded).
Category: cont_basic Cont Basic
Fift: flags RUNVM
Description: 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.
Category: cont_basic Cont Basic
Fift: [p] RETURNARGS
Description: Leaves only the top 0 <= p <= 15 values in the current stack (somewhat similarly to ONLYTOPX), with all the unused bottom values not discarded, but saved into continuation c0 in the same way as SETCONTARGS does.
Category: cont_stack Cont Stack
Fift: c[i] PUSHCTR
c[i] PUSH
Description: 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.
Category: cont_registers Cont Registers
Alias: PUSHROOT Pushes the ”global data root” cell reference, thus enabling access to persistent smart-contract data.
Fift: c[i] POPCTR
c[i] POP
Description: 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.
Category: cont_registers Cont Registers
Alias: POPROOT Sets the ”global data root” cell reference, thus allowing modification of persistent smart-contract data.
Fift: c[i] SETCONT
c[i] SETCONTCTR
Description: 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.
Category: cont_registers Cont Registers
Fift: c[i] POPSAVE
c[i] POPCTRSAVE
Description: Similar to c[i] POPCTR, but also saves the old value of c[i] into continuation c0.
Equivalent (up to exceptions) to c[i] SAVECTRc[i] POPCTR.
Category: cont_registers Cont Registers
Fift: c[i] SAVE
c[i] SAVECTR
Description: 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] PUSHCTRc[i] SETRETCTR.
Category: cont_registers Cont Registers
Fift: c[i] SAVEALT
c[i] SAVEALTCTR
Description: Similar to c[i] SAVE, but saves the current value of c[i] into the savelist of c1, not c0.
Category: cont_registers Cont Registers
Fift: [i] GETPARAM
Description: Returns the i-th parameter from the Tuple provided at c7 for 0 <= i <= 15. Equivalent to c7 PUSHCTRFIRST[i] INDEX.
If one of these internal operations fails, throws an appropriate type checking or range checking exception.
Category: app_config App Config
Alias: NOW Returns the current Unix time as an Integer. If it is impossible to recover the requested value starting from c7, throws a type checking or range checking exception as appropriate.
Equivalent to 3 GETPARAM.
Alias: BLOCKLT Returns the starting logical time of the current block.
Equivalent to 4 GETPARAM.
Alias: LTIME Returns the logical time of the current transaction.
Equivalent to 5 GETPARAM.
Alias: RANDSEED Returns the current random seed as an unsigned 256-bit Integer.
Equivalent to 6 GETPARAM.
Alias: BALANCE Returns the remaining balance of the smart contract as a Tuple consisting of an Integer (the remaining Gram balance in nanograms) and a Maybe Cell (a dictionary with 32-bit keys representing the balance of ”extra currencies”).
Equivalent to 7 GETPARAM.
Note that RAW primitives such as SENDRAWMSG do not update this field.
Alias: MYADDR Returns the internal address of the current smart contract as a Slice with a MsgAddressInt. If necessary, it can be parsed further using primitives such as PARSEMSGADDR or REWRITESTDADDR.
Equivalent to 8 GETPARAM.
Alias: CONFIGROOT Returns the Maybe CellD with the current global configuration dictionary. Equivalent to 9 GETPARAM .
Alias: MYCODE Retrieves code of smart-contract from c7. Equivalent to 10 GETPARAM .
Alias: INCOMINGVALUE Retrieves value of incoming message from c7. Equivalent to 11 GETPARAM .
Alias: STORAGEFEES Retrieves value of storage phase fees from c7. Equivalent to 12 GETPARAM .
Alias: PREVBLOCKSINFOTUPLE Retrives PrevBlocksInfo: [last_mc_blocks, prev_key_block] from c7. Equivalent to 13 GETPARAM .
Fift: {string} DEBUGSTR
{string} {x} DEBUGSTRI
Description: 0 <= n < 16. Length of ssss is n+1 bytes.
{string} is a string literal.
DEBUGSTR: ssss is the given string.
DEBUGSTRI: ssss is one-byte integer 0 <= x <= 255 followed by the given string.
Category: debug Debug
Fift: [z-16] SETCP
Description: Selects TVM codepage z-16 for 1 <= z <= 15. Negative codepages -13...-1 are reserved for restricted versions of TVM needed to validate runs of TVM in other codepages. Negative codepage -14 is reserved for experimental codepages, not necessarily compatible between different TVM implementations, and should be disabled in the production versions of TVM.
Category: codepage Codepage
Fift: TPUSH
COMMA
Description: Appends a value x to a Tuplet=(x_1,...,x_n), but only if the resulting Tuplet'=(x_1,...,x_n,x) is of length at most 255. Otherwise throws a type check exception.
Category: tuple Tuple
Fift: TPOP
Description: Detaches the last element x=x_n from a non-empty Tuplet=(x_1,...,x_n), and returns both the resulting Tuplet'=(x_1,...,x_{n-1}) and the original last element x.
Category: tuple Tuple
Fift: NULLSWAPIFNOT
Description: Pushes a Null under the topmost Integerx, but only if x=0. May be used for stack alignment after quiet primitives such as PLDUXQ.
Category: tuple Tuple
Fift: NULLROTRIF
Description: Pushes a Null under the second stack entry from the top, but only if the topmost Integery is non-zero.
Category: tuple Tuple
Fift: NULLROTRIFNOT
Description: Pushes a Null under the second stack entry from the top, but only if the topmost Integery is zero. May be used for stack alignment after quiet primitives such as LDUXQ.
Category: tuple Tuple
Fift: NULLSWAPIF2
Description: Pushes two nulls under the topmost Integerx, but only if x!=0.
Equivalent to NULLSWAPIFNULLSWAPIF.
Category: tuple Tuple
Fift: NULLSWAPIFNOT2
Description: Pushes two nulls under the topmost Integerx, but only if x=0.
Equivalent to NULLSWAPIFNOTNULLSWAPIFNOT.
Category: tuple Tuple
Fift: NULLROTRIF2
Description: Pushes two nulls under the second stack entry from the top, but only if the topmost Integery is non-zero.
Equivalent to NULLROTRIFNULLROTRIF.
Category: tuple Tuple
Fift: NULLROTRIFNOT2
Description: Pushes two nulls under the second stack entry from the top, but only if the topmost Integery is zero.
Equivalent to NULLROTRIFNOTNULLROTRIFNOT.
Category: tuple Tuple
Fift: BITSIZE
Description: Computes smallest c >= 0 such that x fits into a c-bit signed integer (-2^(c-1) <= c < 2^(c-1)).
Category: arithm_logical Arithm Logical
Fift: UBITSIZE
Description: Computes smallest c >= 0 such that x fits into a c-bit unsigned integer (0 <= x < 2^c), or throws a range check exception.
Category: arithm_logical Arithm Logical
Fift: MINMAX
INTSORT2
Description: Sorts two integers. Quiet version of this operation returns two NaNs if any of the arguments are NaNs.
Category: arithm_logical Arithm Logical
Fift: [cc+1] QFITS
Description: Replaces x with a NaN if x is not a cc+1-bit signed integer, leaves it intact otherwise.
Category: arithm_quiet Arithm Quiet
Fift: [cc+1] QUFITS
Description: Replaces x with a NaN if x is not a cc+1-bit unsigned integer, leaves it intact otherwise.
Category: arithm_quiet Arithm Quiet
Fift: SEMPTY
Description: Checks whether a Slices is empty (i.e., contains no bits of data and no cell references).
Category: compare_other Compare Other
Fift: SDLEXCMP
Description: Compares the data of s lexicographically with the data of s', returning -1, 0, or 1 depending on the result.
Category: compare_other Compare Other
Fift: STIXQ
Description: A quiet version of STIX. If there is no space in b, sets b'=b and f=-1.
If x does not fit into l bits, sets b'=b and f=1.
If the operation succeeds, b' is the new Builder and f=0.
However, 0 <= l <= 257, with a range check exception if this is not so.
Category: cell_build Cell Build
Fift: ENDXC
Description: If x!=0, creates a special or exotic cell from Builderb.
The type of the exotic cell must be stored in the first 8 bits of b.
If x=0, it is equivalent to ENDC. Otherwise some validity checks on the data and references of b are performed before creating the exotic cell.
Category: cell_build Cell Build
Fift: BDEPTH
Description: Returns the depth of Builderb. If no cell references are stored in b, then x=0; otherwise x is one plus the maximum of depths of cells referred to from b.
Category: cell_build Cell Build
Fift: BCHKBITS
Description: Checks whether x bits can be stored into b, 0 <= x <= 1023. If there is no space for x more bits in b, or if x is not within the range 0...1023, throws an exception.
Category: cell_build Cell Build
Fift: BCHKBITREFS
Description: Checks whether x bits and y references can be stored into b, 0 <= x <= 1023, 0 <= y <= 7.
Category: cell_build Cell Build
Fift: BCHKBITREFSQ
Description: Checks whether x bits and y references can be stored into b, 0 <= x <= 1023, 0 <= y <= 7.
Category: cell_build Cell Build
Fift: LDIX
Description: Loads a signed l-bit (0 <= l <= 257) integer x from Slices, and returns the remainder of s as s'.
Category: cell_parse Cell Parse
Fift: LDIXQ
Description: Quiet version of LDIX: loads a signed l-bit integer from s similarly to LDIX, but returns a success flag, equal to -1 on success or to 0 on failure (if s does not have l bits), instead of throwing a cell underflow exception.
Category: cell_parse Cell Parse
Fift: LDSLICEX
Description: Loads the first 0 <= l <= 1023 bits from Slices into a separate Slices'', returning the remainder of s as s'.
Category: cell_parse Cell Parse
Fift: SDSUBSTR
Description: Returns 0 <= l' <= 1023 bits of s starting from offset 0 <= l <= 1023, thus extracting a bit substring out of the data of s.
Category: cell_parse Cell Parse
Fift: SDBEGINSX
Description: Checks whether s begins with (the data bits of) s', and removes s' from s on success. On failure throws a cell deserialization exception. Primitive SDPFXREV can be considered a quiet version of SDBEGINSX.
Category: cell_parse Cell Parse
Fift: SUBSLICE
Description: Returns 0 <= l' <= 1023 bits and 0 <= r' <= 4 references from Slices, after skipping the first 0 <= l <= 1023 bits and first 0 <= r <= 4 references.
Category: cell_parse Cell Parse
Fift: SPLIT
Description: 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''.
Category: cell_parse Cell Parse
Fift: XCTOS
Description: 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.
Category: cell_parse Cell Parse
Fift: XLOAD
Description: 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.
Category: cell_parse Cell Parse
Fift: XLOADQ
Description: Loads an exotic cell c and returns an ordinary cell c'. If c is already ordinary, does nothing. If c cannot be loaded, returns 0.
Category: cell_parse Cell Parse
Fift: SCHKBITS
Description: Checks whether there are at least l data bits in Slices. If this is not the case, throws a cell deserialization (i.e., cell underflow) exception.
Category: cell_parse Cell Parse
Fift: LDSAME
Description: Returns the count n of leading bits equal to 0 <= x <= 1 in s, and removes these bits from s.
Category: cell_parse Cell Parse
Fift: SDEPTH
Description: Returns the depth of Slices. If s has no references, then x=0; otherwise x is one plus the maximum of depths of cells referred to from s.
Category: cell_parse Cell Parse
Fift: CDEPTH
Description: Returns the depth of Cellc. 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.
Category: cell_parse Cell Parse
Fift: RET
RETTRUE
Description: Returns to the continuation at c0. The remainder of the current continuation cc is discarded.
Approximately equivalent to c0 PUSHCTRJMPX.
Category: cont_basic Cont Basic
Fift: CALLCC
Description: Call with current continuation, transfers control to c, pushing the old value of cc into c’s stack (instead of discarding it or writing it into new c0).
Category: cont_basic Cont Basic
Fift: JMPXDATA
Description: 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.
Category: cont_basic Cont Basic
Fift: [p] [r] CALLCCARGS
Description: Similar to CALLXARGS, but pushes the old value of cc (along with the top 0 <= p <= 15 values from the original stack) into the stack of newly-invoked continuation c, setting cc.nargs to -1 <= r <= 14.
Category: cont_basic Cont Basic
Fift: CALLXVARARGS
Description: Similar to CALLXARGS, but takes -1 <= p,r <= 254 from the stack. The next three operations also take p and r from the stack, both in the range -1...254.
Category: cont_basic Cont Basic
Fift: RETDATA
Description: Equivalent to c0 PUSHCTRJMPXDATA. In this way, the remainder of the current continuation is converted into a Slice and returned to the caller.
Category: cont_basic Cont Basic
Fift: RUNVMX
Description: 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.
Category: cont_basic Cont Basic
Fift: [ref] IFREF
Description: Equivalent to PUSHREFCONTIF, with the optimization that the cell reference is not actually loaded into a Slice and then converted into an ordinary Continuation if f=0.
Gas consumption of this primitive depends on whether f=0 and whether the reference was loaded before.
Similar remarks apply other primitives that accept a continuation as a reference.
Category: cont_conditional Cont Conditional
Fift: CONDSEL
Description: If integer f is non-zero, returns x, otherwise returns y. Notice that no type checks are performed on x and y; as such, it is more like a conditional stack operation. Roughly equivalent to ROTISZEROINCROLLXNIP.
Category: cont_conditional Cont Conditional
Fift: [ref] IFREFELSE
Description: Equivalent to PUSHREFCONTSWAPIFELSE, 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.
Category: cont_conditional Cont Conditional
Fift: REPEATBRK
Description: Similar to REPEAT, but also sets c1 to the original cc after saving the old value of c1 into the savelist of the original cc. In this way RETALT could be used to break out of the loop body.
Category: cont_loops Cont Loops
Fift: REPEATENDBRK
Description: Similar to REPEATEND, but also sets c1 to the original c0 after saving the old value of c1 into the savelist of the original c0. Equivalent to SAMEALTSAVEREPEATEND.
Category: cont_loops Cont Loops
Fift: SETCONTVARARGS
Description: Similar to SETCONTARGS, but with 0 <= r <= 255 and -1 <= n <= 255 taken from the stack.
Category: cont_stack Cont Stack
Fift: SETNUMVARARGS
Description: -1 <= n <= 255
If n=-1, this operation does nothing (c'=c).
Otherwise its action is similar to [n] SETNUMARGS, but with n taken from the stack.
Category: cont_stack Cont Stack
Fift: BLESS
Description: Transforms a Slices into a simple ordinary continuation c, with c.code=s and an empty stack and savelist.
Category: cont_create Cont Create
Fift: PUSHCTRX
Description: Similar to c[i] PUSHCTR, but with i, 0 <= i <= 255, taken from the stack.
Notice that this primitive is one of the few ”exotic” primitives, which are not polymorphic like stack manipulation primitives, and at the same time do not have well-defined types of parameters and return values, because the type of x depends on i.
Category: cont_registers Cont Registers
Fift: COMPOS
BOOLAND
Description: Computes the composition compose0(c, c'), which has the meaning of ”perform c, and, if successful, perform c'” (if c is a boolean circuit) or simply ”perform c, then c'”. Equivalent to SWAPc0 SETCONT.
Category: cont_registers Cont Registers
Fift: COMPOSALT
BOOLOR
Description: 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 SWAPc1 SETCONT.
Category: cont_registers Cont Registers
Fift: COMPOSBOTH
Description: Computes composition compose1(compose0(c, c'), c'), which has the meaning of ”compute boolean circuit c, then compute c', regardless of the result of c”.
Category: cont_registers Cont Registers
Fift: ATEXIT
Description: Sets c0 to compose0(c, c0). In other words, c will be executed before exiting current subroutine.
Category: cont_registers Cont Registers
Fift: ATEXITALT
Description: Sets c1 to compose1(c, c1). In other words, c will be executed before exiting current subroutine by its alternative return path.
Category: cont_registers Cont Registers
Fift: SETEXITALT
Description: Sets c1 to compose1(compose0(c, c0), c1),
In this way, a subsequent RETALT will first execute c, then transfer control to the original c0. This can be used, for instance, to exit from nested loops.
Category: cont_registers Cont Registers
Fift: BOOLEVAL
Description: Performs cc:=compose1(compose0(c, compose0(-1 PUSHINT, cc)), compose0(0 PUSHINT, cc)). If c represents a boolean circuit, the net effect is to evaluate it and push either -1 or 0 into the stack before continuing.
Category: cont_registers Cont Registers
Fift: SAMEALTSAVE
Description: Sets c1 to c0, but first saves the old value of c1 into the savelist of c0.
Equivalent to c1 SAVESAMEALT.
Category: cont_registers Cont Registers
Fift: THROWANY
Description: Throws exception 0 <= n < 2^16 with parameter zero.
Approximately equivalent to ZEROSWAPTHROWARGANY.
Category: exceptions Exceptions
Fift: THROWARGANY
Description: Throws exception 0 <= n < 2^16 with parameter x, transferring control to the continuation in c2.
Approximately equivalent to c2 PUSHCTR2 JMPXARGS.
Category: exceptions Exceptions
Fift: TRY
Description: 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.
Category: exceptions Exceptions
Fift: STDICT
STOPTREF
Description: Stores dictionary D into Builderb, returning the resulting Builderb'.
In other words, if D is a cell, performs STONE and STREF; if D is Null, performs NIP and STZERO; otherwise throws a type checking exception.
Category: dict_serial Dict Serial
Fift: LDDICTS
Description: Loads (parses) a (Slice-represented) dictionary s' from Slices, and returns the remainder of s as s''.
This is a ”split function” for all HashmapE(n,X) dictionary types.
Category: dict_serial Dict Serial
Fift: PLDDICTS
Description: Preloads a (Slice-represented) dictionary s' from Slices.
Approximately equivalent to LDDICTSDROP.
Category: dict_serial Dict Serial
Fift: LDDICT
LDOPTREF
Description: Loads (parses) a dictionary D from Slices, and returns the remainder of s as s'. May be applied to dictionaries or to values of arbitrary (^Y)? types.
Category: dict_serial Dict Serial
Fift: DICTGET
Description: Looks up key k (represented by a Slice, the first 0 <= n <= 1023 data bits of which are used as a key) in dictionary D of type HashmapE(n,X) with n-bit keys.
On success, returns the value found as a Slicex.
Category: dict_get Dict Get
Fift: DICTGETREF
Description: Similar to DICTGET, but with a LDREFENDS applied to x on success.
This operation is useful for dictionaries of type HashmapE(n,^Y).
Category: dict_get Dict Get
Fift: DICTIGET
Description: Similar to DICTGET, but with a signed (big-endian) n-bit Integeri as a key. If i does not fit into n bits, returns 0. If i is a NaN, throws an integer overflow exception.
Category: dict_get Dict Get
Fift: DICTIGETREF
Description: Combines DICTIGET with DICTGETREF: it uses signed n-bit Integeri as a key and returns a Cell instead of a Slice on success.
Category: dict_get Dict Get
Fift: DICTSET
Description: 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'.
Category: dict_set Dict Set
Fift: DICTISET
Description: 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.
Category: dict_set Dict Set
Fift: DICTSETGET
Description: Combines DICTSET with DICTGET: it sets the value corresponding to key k to x, but also returns the old value y associated with the key in question, if present.
Category: dict_set Dict Set
Fift: DICTREPLACE
Description: A Replace operation, which is similar to DICTSET, but sets the value of key k in dictionary D to x only if the key k was already present in D.
Category: dict_set Dict Set
Fift: DICTREPLACEGET
Description: A Replace counterpart of DICTSETGET: on success, also returns the old value associated with the key in question.
Category: dict_set Dict Set
Fift: DICTADD
Description: An Add counterpart of DICTSET: sets the value associated with key k in dictionary D to x, but only if it is not already present in D.
Category: dict_set Dict Set
Fift: DICTADDGET
Description: An Add counterpart of DICTSETGET: sets the value associated with key k in dictionary D to x, but only if key k is not already present in D. Otherwise, just returns the old value y without changing the dictionary.
Category: dict_set Dict Set
Fift: DICTDEL
Description: Deletes n-bit key, represented by a Slicek, 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.
Category: dict_delete Dict Delete
Fift: DICTIDEL
Description: A version of DICTDEL with the key represented by a signed n-bit Integeri. If i does not fit into n bits, simply returns D0 (”key not found, dictionary unmodified”).
Category: dict_delete Dict Delete
Fift: DICTDELGET
Description: Deletes n-bit key, represented by a Slicek, 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.
Category: dict_delete Dict Delete
Fift: DICTDELGETREF
Description: Similar to DICTDELGET, but with LDREFENDS applied to x on success, so that the value returned c is a Cell.
Category: dict_delete Dict Delete
Fift: DICTGETOPTREF
Description: A variant of DICTGETREF that returns Null instead of the value c^? if the key k is absent from dictionary D.
Category: dict_mayberef Dict Mayberef
Fift: DICTIGETOPTREF
Description: DICTGETOPTREF, but with i a signed n-bit integer. If the key i is out of range, also returns Null.
Category: dict_mayberef Dict Mayberef
Fift: DICTUGETOPTREF
Description: DICTGETOPTREF, but with i an unsigned n-bit integer. If the key i is out of range, also returns Null.
Category: dict_mayberef Dict Mayberef
Fift: DICTSETGETOPTREF
Description: A variant of both DICTGETOPTREF and DICTSETGETREF that sets the value corresponding to key k in dictionary D to c^? (if c^? is Null, then the key is deleted instead), and returns the old value ~c^? (if the key k was absent before, returns Null instead).
Category: dict_mayberef Dict Mayberef
Fift: DICTISETGETOPTREF
Description: Similar to primitive DICTSETGETOPTREF, but using signed n-bit Integeri as a key. If i does not fit into n bits, throws a range checking exception.
Category: dict_mayberef Dict Mayberef
Fift: DICTUSETGETOPTREF
Description: Similar to primitive DICTSETGETOPTREF, but using unsigned n-bit Integeri as a key.
Category: dict_mayberef Dict Mayberef
Fift: DICTGETNEXT
Description: Computes the minimal key k' in dictionary D that is lexicographically greater than k, and returns k' (represented by a Slice) along with associated value x' (also represented by a Slice).
Category: dict_next Dict Next
Fift: DICTGETNEXTEQ
Description: Similar to DICTGETNEXT, but computes the minimal key k' that is lexicographically greater than or equal to k.
Category: dict_next Dict Next
Fift: DICTGETPREVEQ
Description: Similar to DICTGETPREV, but computes the maximal key k' lexicographically smaller than or equal to k.
Category: dict_next Dict Next
Fift: DICTIGETNEXT
Description: 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 Integeri (which does not necessarily fit into n bits).
Category: dict_next Dict Next
Fift: DICTUGETNEXT
Description: 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 Integeri (which does not necessarily fit into n bits, and is not necessarily non-negative).
Category: dict_next Dict Next
Fift: DICTMIN
Description: 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.
Category: dict_min Dict Min
Fift: DICTIMIN
Description: 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.
Category: dict_min Dict Min
Fift: DICTMAX
Description: 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.
Category: dict_min Dict Min
Fift: DICTIMAX
Description: Similar to DICTMAX, but computes the maximal 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 DICTMAX and DICTUMAX.
Category: dict_min Dict Min
Fift: DICTREMMIN
Description: Computes the minimal key k (represented by a Slice with n data bits) in dictionary D, removes k from the dictionary, and returns k along with the associated value x and the modified dictionary D'.
Category: dict_min Dict Min
Fift: DICTIREMMIN
Description: Similar to DICTREMMIN, 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 DICTREMMIN and DICTUREMMIN.
Category: dict_min Dict Min
Fift: DICTREMMAX
Description: Computes the maximal key k (represented by a Slice with n data bits) in dictionary D, removes k from the dictionary, and returns k along with the associated value x and the modified dictionary D'.
Category: dict_min Dict Min
Fift: DICTIREMMAX
Description: Similar to DICTREMMAX, 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 DICTREMMAX and DICTUREMMAX.
Category: dict_min Dict Min
Fift: DICTIGETJMP
Description: Similar to DICTIGET, but with xBLESSed into a continuation with a subsequent JMPX to it on success. On failure, does nothing. This is useful for implementing switch/case constructions.
Category: dict_special Dict Special
Fift: PFXDICTGETQ
Description: Looks up the unique prefix of Slices 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 Slices''. If no prefix of s is a key in prefix code dictionary D, returns the unchanged s and a zero flag to indicate failure.
Category: dict_special Dict Special
Fift: PFXDICTGET
Description: Similar to PFXDICTGET, but throws a cell deserialization failure exception on failure.
Category: dict_special Dict Special
Fift: PFXDICTGETJMP
Description: Similar to PFXDICTGETQ, but on success BLESSes the value x into a Continuation and transfers control to it as if by a JMPX. On failure, returns s unchanged and continues execution.
Category: dict_special Dict Special
Fift: PFXDICTGETEXEC
Description: Similar to PFXDICTGETJMP, but EXECutes the continuation found instead of jumping to it. On failure, throws a cell deserialization exception.
Category: dict_special Dict Special
Fift: SUBDICTGET
Description: Constructs a subdictionary consisting of all keys beginning with prefix k (represented by a Slice, the first 0 <= l <= n <= 1023 data bits of which are used as a key) of length l in dictionary D of type HashmapE(n,X) with n-bit keys. On success, returns the new subdictionary of the same type HashmapE(n,X) as a SliceD'.
Category: dict_sub Dict Sub
Fift: SUBDICTIGET
Description: Variant of SUBDICTGET with the prefix represented by a signed big-endian l-bit Integerx, where necessarily l <= 257.
Category: dict_sub Dict Sub
Fift: SUBDICTUGET
Description: Variant of SUBDICTGET with the prefix represented by an unsigned big-endian l-bit Integerx, where necessarily l <= 256.
Category: dict_sub Dict Sub
Fift: SUBDICTRPGET
Description: Similar to SUBDICTGET, but removes the common prefix k from all keys of the new dictionary D', which becomes of type HashmapE(n-l,X).
Category: dict_sub Dict Sub
Fift: SUBDICTIRPGET
Description: Variant of SUBDICTRPGET with the prefix represented by a signed big-endian l-bit Integerx, where necessarily l <= 257.
Category: dict_sub Dict Sub
Fift: SUBDICTURPGET
Description: Variant of SUBDICTRPGET with the prefix represented by an unsigned big-endian l-bit Integerx, where necessarily l <= 256.
Category: dict_sub Dict Sub
Fift: ACCEPT
Description: Sets current gas limit g_l to its maximal allowed value g_m, and resets the gas credit g_c to zero, decreasing the value of g_r by g_c in the process.
In other words, the current smart contract agrees to buy some gas to finish the current transaction. This action is required to process external messages, which bring no value (hence no gas) with themselves.
Category: app_gas App Gas
Fift: SETGASLIMIT
Description: 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.
Category: app_gas App Gas
Fift: COMMIT
Description: 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.
Category: app_gas App Gas
Fift: RANDU256
Description: Generates a new pseudo-random unsigned 256-bit Integerx. 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.
Category: app_rnd App Rnd
Fift: RAND
Description: Generates a new pseudo-random integer z in the range 0...y-1 (or y...-1, if y<0). More precisely, an unsigned random value x is generated as in RAND256U; then z:=floor(x*y/2^256) is computed.
Equivalent to RANDU256256 MULRSHIFT.
Category: app_rnd App Rnd
Fift: ADDRAND
RANDOMIZE
Description: Mixes unsigned 256-bit Integerx 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.
Category: app_rnd App Rnd
Fift: CONFIGDICT
Description: Returns the global configuration dictionary along with its key length (32).
Equivalent to CONFIGROOT32 PUSHINT.
Category: app_config App Config
Fift: CONFIGPARAM
Description: Returns the value of the global configuration parameter with integer index i as a Cellc, and a flag to indicate success.
Equivalent to CONFIGDICTDICTIGETREF.
Category: app_config App Config
Fift: CONFIGOPTPARAM
Description: Returns the value of the global configuration parameter with integer index i as a Maybe Cellc^?.
Equivalent to CONFIGDICTDICTIGETOPTREF.
Category: app_config App Config
Fift: GETORIGINALFWDFEE
Description: Calculate fwd_fee * 2^16 / first_frac. Can be used to get the original fwd_fee of the message.
Category: app_config App Config
Fift: GETFORWARDFEESIMPLE
Description: Same as GETFORWARDFEE, but without lump price (just (bits*bit_price + cells*cell_price) / 2^16).
Category: app_config App Config
Fift: GETGLOBVAR
Description: Returns the k-th global variable for 0 <= k < 255.
Equivalent to c7 PUSHCTRSWAPINDEXVARQ.
Category: app_global App Global
Fift: SETGLOBVAR
Description: Assigns x to the k-th global variable for 0 <= k < 255.
Equivalent to c7 PUSHCTRROTREVSETINDEXVARQc7 POPCTR.
Category: app_global App Global
Fift: HASHCU
Description: Computes the representation hash of a Cellc 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.
Category: app_crypto App Crypto
Fift: HASHSU
Description: Computes the hash of a Slices 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.
Category: app_crypto App Crypto
Fift: SHA256U
Description: Computes Sha of the data bits of Slices. 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.
Category: app_crypto App Crypto
Fift: CHKSIGNU
Description: Checks the Ed25519-signature s of a hash h (a 256-bit unsigned integer, usually computed as the hash of some data) using public key k (also represented by a 256-bit unsigned integer).
The signature s must be a Slice containing at least 512 data bits; only the first 512 bits are used. The result is -1 if the signature is valid, 0 otherwise.
Notice that CHKSIGNU is equivalent to ROTNEWC256 STUENDCROTREVCHKSIGNS, i.e., to CHKSIGNS with the first argument d set to 256-bit Slice containing h. Therefore, if h is computed as the hash of some data, these data are hashed twice, the second hashing occurring inside CHKSIGNS.
Category: app_crypto App Crypto
Fift: CHKSIGNS
Description: Checks whether s is a valid Ed25519-signature of the data portion of Sliced using public key k, similarly to CHKSIGNU. If the bit length of Sliced 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.
Category: app_crypto App Crypto
Fift: ECRECOVER
Description: 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.
Category: app_crypto App Crypto
Fift: P256_CHKSIGNU
Description: 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).
Category: app_crypto App Crypto
Fift: P256_CHKSIGNS
Description: Checks seck256r1-signature sig of data portion of slice d 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).
Category: app_crypto App Crypto
Fift: RIST255_FROMHASH
Description: Deterministically generates a valid point x from a 512-bit hash (given as two 256-bit integers).
Category: app_crypto App Crypto
Fift: RIST255_VALIDATE
Description: Checks that integer x is a valid representation of some curve point. Throws range_chk on error.
Category: app_crypto App Crypto
Fift: RIST255_PUSHL
Description: Pushes integer l=2^252+27742317777372353535851937790883648493, which is the order of the group.
Category: app_crypto App Crypto
Fift: CDATASIZEQ
Description: Recursively computes the count of distinct cells x, data bits y, and cell references z in the dag rooted at Cellc, 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 Integern; 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.
Category: app_misc App Misc
Fift: SDATASIZEQ
Description: Similar to CDATASIZEQ, but accepting a Slices instead of a Cell. The returned value of x does not take into account the cell that contains the slice s itself; however, the data bits and the cell references of s are accounted for in y and z.
Category: app_misc App Misc
Fift: LDGRAMS
LDVARUINT16
Description: Loads (deserializes) a Gram or VarUInteger 16 amount from Slices, and returns the amount as Integerx along with the remainder s' of s. The expected serialization of x consists of a 4-bit unsigned big-endian integer l, followed by an 8l-bit unsigned big-endian representation of x.
The net effect is approximately equivalent to 4 LDUSWAP3 LSHIFT#LDUX.
Category: app_currency App Currency
Fift: LDVARINT16
Description: Similar to LDVARUINT16, but loads a signedIntegerx.
Approximately equivalent to 4 LDUSWAP3 LSHIFT#LDIX.
Category: app_currency App Currency
Fift: STGRAMS
STVARUINT16
Description: Stores (serializes) an Integerx in the range 0...2^120-1 into Builderb, and returns the resulting Builderb'. 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.
Category: app_currency App Currency
Fift: STVARINT16
Description: Similar to STVARUINT16, but serializes a signedIntegerx in the range -2^119...2^119-1.
Category: app_currency App Currency
Fift: LDVARUINT32
Description: Loads (deserializes) a VarUInteger 32 amount from Slices, and returns the amount as Integerx along with the remainder s' of s. The expected serialization of x consists of a 5-bit unsigned big-endian integer l, followed by an 8l-bit unsigned big-endian representation of x.
The net effect is approximately equivalent to 4 LDUSWAP3 LSHIFT#LDUX.
Category: app_currency App Currency
Fift: LDVARINT32
Description: Similar to LDVARUINT32, but loads a signedIntegerx.
Approximately equivalent to 5 LDUSWAP3 LSHIFT#LDIX.
Category: app_currency App Currency
Fift: STVARUINT32
Description: Stores (serializes) an Integerx in the range 0...2^248-1 into Builderb, and returns the resulting Builderb'. The serialization of x consists of a 5-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.
Category: app_currency App Currency
Fift: STVARINT32
Description: Similar to STVARUINT32, but serializes a signedIntegerx in the range -2^247...2^247-1.
Category: app_currency App Currency
Fift: LDMSGADDR
Description: Loads from Slices the only prefix that is a valid MsgAddress, and returns both this prefix s' and the remainder s'' of s as slices.
Category: app_addr App Addr
Fift: LDMSGADDRQ
Description: A quiet version of LDMSGADDR: on success, pushes an extra -1; on failure, pushes the original s and a zero.
Category: app_addr App Addr
Fift: PARSEMSGADDR
Description: Decomposes Slices containing a valid MsgAddress into a Tuplet with separate fields of this MsgAddress. If s is not a valid MsgAddress, a cell deserialization exception is thrown.
Category: app_addr App Addr
Fift: PARSEMSGADDRQ
Description: A quiet version of PARSEMSGADDR: returns a zero on error instead of throwing an exception.
Category: app_addr App Addr
Fift: REWRITESTDADDR
Description: Parses Slices 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.
Category: app_addr App Addr
Fift: REWRITEVARADDR
Description: A variant of REWRITESTDADDR that returns the (rewritten) address as a Slices, even if it is not exactly 256 bit long (represented by a msg_addr_var).
Category: app_addr App Addr
Fift: SENDRAWMSG
Description: 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.
Category: app_actions App Actions
Fift: RAWRESERVE
Description: 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.
Category: app_actions App Actions
Fift: RAWRESERVEX
Description: Similar to RAWRESERVE, but also accepts a dictionary D (represented by a Cell or Null) with extra currencies. In this way currencies other than Grams can be reserved.
Category: app_actions App Actions
Fift: SETCODE
Description: Creates an output action that would change this smart contract code to that given by Cellc. Notice that this change will take effect only after the successful termination of the current run of the smart contract.
Category: app_actions App Actions
Fift: SETLIBCODE
Description: Creates an output action that would modify the collection of this smart contract libraries by adding or removing library with code given in Cellc. 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.
Category: app_actions App Actions
Fift: CHANGELIB
Description: Creates an output action similarly to SETLIBCODE, but instead of the library code accepts its hash as an unsigned 256-bit integer h. If x!=0 and the library with hash h is absent from the library collection of this smart contract, this output action will fail.
Category: app_actions App Actions
Fift: SENDMSG
Description: 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).
Category: app_actions App Actions
Fift: RIST255_QVALIDATE
Description: Checks that integer x is a valid representation of some curve point. Returns -1 on success and 0 on failure.
Category: app_crypto App Crypto
Fift: RIST255_QMUL
Description: Multiplies point x by a scalar n. Any n is valid, including negative. Returns -1 on success and 0 on failure.
Category: app_crypto App Crypto
Fift: RIST255_QMULBASE
Description: Multiplies the generator point g by a scalar n. Any n is valid, including negative.
Category: app_crypto App Crypto
Fift: HASHEXT_KECCAK256
Description: Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n.
Category: app_crypto App Crypto
Fift: HASHEXT_KECCAK512
Description: Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n.
Category: app_crypto App Crypto
Fift: HASHEXTR_BLAKE2B
Description: Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n.
Category: app_crypto App Crypto
Fift: HASHEXTR_KECCAK256
Description: Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n.
Category: app_crypto App Crypto
Fift: HASHEXTR_KECCAK512
Description: Calculates and returns hash of the concatenation of slices (or builders) s_1...s_n.
Category: app_crypto App Crypto
Fift: HASHEXTA_SHA256
Description: Calculates hash of the concatenation of slices (or builders) s_1...s_n. Appends the resulting hash to a builder b.
Category: app_crypto App Crypto
Fift: HASHEXTA_SHA512
Description: Calculates hash of the concatenation of slices (or builders) s_1...s_n. Appends the resulting hash to a builder b.
Category: app_crypto App Crypto
Fift: HASHEXTA_BLAKE2B
Description: Calculates hash of the concatenation of slices (or builders) s_1...s_n. Appends the resulting hash to a builder b.
Category: app_crypto App Crypto
Fift: HASHEXTA_KECCAK256
Description: Calculates hash of the concatenation of slices (or builders) s_1...s_n. Appends the resulting hash to a builder b.
Category: app_crypto App Crypto
Fift: HASHEXTA_KECCAK512
Description: Calculates hash of the concatenation of slices (or builders) s_1...s_n. Appends the resulting hash to a builder b.
Category: app_crypto App Crypto
Fift: HASHEXTAR_SHA256
Description: Calculates hash of the concatenation of slices (or builders) s_1...s_n. Appends the resulting hash to a builder b.
Category: app_crypto App Crypto
Fift: HASHEXTAR_SHA512
Description: Calculates hash of the concatenation of slices (or builders) s_1...s_n. Appends the resulting hash to a builder b.
Category: app_crypto App Crypto
Fift: HASHEXTAR_BLAKE2B
Description: Calculates hash of the concatenation of slices (or builders) s_1...s_n. Appends the resulting hash to a builder b.
Category: app_crypto App Crypto
Fift: HASHEXTAR_KECCAK256
Description: Calculates hash of the concatenation of slices (or builders) s_1...s_n. Appends the resulting hash to a builder b.
Category: app_crypto App Crypto
Fift: HASHEXTAR_KECCAK512
Description: Calculates hash of the concatenation of slices (or builders) s_1...s_n. Appends the resulting hash to a builder b.
Category: app_crypto App Crypto
Fift: BLS_AGGREGATE
Description: Aggregates signatures. n>0. Throw exception if n=0 or if some sig_i is not a valid signature.
Category: app_crypto App Crypto
Fift: BLS_G1_MULTIEXP
Description: 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.
Category: app_crypto App Crypto
Fift: BLS_G2_MULTIEXP
Description: Calculates x_1*s_1+...+x_n*s_n for G2 points x_i and scalars s_i. Returns zero point if n=0. Any s_i is valid, including negative.
Category: app_crypto App Crypto
Fift: BLS_PAIRING
Description: 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.
Category: app_crypto App Crypto
Fift: [ref] [n] DICTPUSHCONST
Description: 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.
Category: dict_special Dict Special
Fift: [n] IFBITJMP
Description: Checks whether bit 0 <= n <= 31 is set in integer x, and if so, performs JMPX to continuation c. Value x is left in the stack.
Category: cont_conditional Cont Conditional
Fift: [n] JMP
Description: Jumps to the continuation in c3, pushing integer 0 <= n < 2^14 as its argument.
Approximately equivalent to n PUSHINTc3 PUSHCTRJMPX.
Category: cont_dict Cont Dict
Fift: [n] PLDREFIDX
Description: Returns the n-th cell reference of Slices, where 0 <= n <= 3.
Category: cell_parse Cell Parse
Alias: PLDREF Preloads the first cell reference of a Slice.
Fift: [32(c+1)] PLDUZ
Description: Preloads the first 32(c+1) bits of Slices 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.
Category: cell_parse Cell Parse
Fift: [n] PREPARE
[n] PREPAREDICT
Description: Equivalent to n PUSHINTc3 PUSHCTR, for 0 <= n < 2^14.
In this way, [n] CALL is approximately equivalent to [n] PREPAREEXECUTE, and [n] JMP is approximately equivalent to [n] PREPAREJMPX.
One might use, for instance, CALLXARGS or CALLCC instead of EXECUTE here.
Category: cont_dict Cont Dict
Fift: [builder] PUSHCONT
[builder] CONT
Description: Pushes a continuation made from builder.
Details: Pushes the simple ordinary continuation cccc made from the first 0 <= r <= 3 references and the first 0 <= xx <= 127 bytes of cc.code.
Category: const_data Const Data
Fift: [slice] SDBEGINS
Description: 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.
Category: cell_parse Cell Parse
Fift: [k] SETGLOB
Description: Assigns x to the k-th global variable for 1 <= k <= 31.
Equivalent to c7 PUSHCTRSWAPk SETINDEXQc7 POPCTR.
Category: app_global App Global
Fift: [slice] STSLICECONST
Description: Stores a constant subslice sss.
Details:sss consists of 0 <= x <= 3 references and up to 8y+2 data bits, with 0 <= y <= 7. Completion bit is assumed.
Note that the assembler can replace STSLICECONST with PUSHSLICESTSLICER if the slice is too big.
Category: cell_build Cell Build
Alias: STZERO Stores one binary zero.
Alias: STONE Stores one binary one.
Fift: [n] THROWARG
Description: Throws exception 0 <= n < 2^11 with parameter x, by copying x and n into the stack of c2 and transferring control to c2.
Category: exceptions Exceptions
Fift: [n] THROW
Description: Throws exception 0 <= n <= 63 with parameter zero.
In other words, it transfers control to the continuation in c2, pushing 0 and n into its stack, and discarding the old stack altogether.
Category: exceptions Exceptions