Key differences
Fift is an interpreted language. With respect to TVM, its execution happens at compile-time — when the compiler builds the smart contract code as a BoC. That compiled code contains TVM assembly for execution at run-time on the TVM itself. Fift can appear in different forms:-
Built-in words, constants, and variables:
-
TVM instruction bitcode definitions, like in
Asm.fif: -
Intertwined macros and TVM opcodes, like in
wallet_v3_r2.fif:
Smart contract usage
(Fift) Including large BoCs in contracts
Include large BoCs withtoncli by:
-
Editing
project.yamlto includefift/blob.fif: -
Adding the BoC to
fift/blob.boc -
Including this code in
fift/blob.fif:
(TVM assembly) Converting integers to strings
Fift primitives cannot convert integers to strings at runtime because Fift operates at compile-time. For runtime conversion, use TVM assembly like in this solution from the 3rd TON Smart Challenge:(TVM assembly) Efficient modulo multiplication
Compare these implementations:x{A988} opcode implements an optimized division operation with built-in multiplication. This specialized instruction directly computes just the modulo remainder of the operation, skipping unnecessary computation steps. The s, suffix then handles the result storage - it takes the resulting slice from the stack’s top and efficiently writes it into the target builder. Together, this combination delivers substantial gas savings compared to conventional approaches.