Documentation Index
Fetch the complete documentation index at: https://companyname-a7d5b98e-w5-api.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Number literals
FunC supports decimal and hexadecimal integer literals, including those with leading zeros. Examples of valid integer literals:0, 123, -17, 00987, and -0.
Examples of valid hexadecimal literals: 0xef, 0xEF, 0x0, -0xfFAb, 0x0001, and -0x0.
Identifiers
FunC allows a broad range of identifiers for functions and variable names. Any single-line string that meets the following conditions qualifies as a valid identifier:- It does not contain special symbols:
;,,,(,),[,], spaces including tabs,~, and.. - It does not start as a comment or a string literal (i.e., with
"at the beginning). - It is not a number literal.
- It is not an underscore
_. - It is not a reserved keyword.
- It is not the name of a built-in.
. or ~.
Examples of valid identifiers:
query,query',query''elem0,elem1,elem2CHECK_internal_valuemessage_found?get_pubkeys&signaturesdict::udict_set_builderfatal!
123validname2+2=2*2-alsovalidname0xefefefhahaha{hehehe}pa{--}in"`aaa`"
fun_a~fun_a?._how123
take(first)Entry- contains parentheses(and)"not_a_string- starts with a", like a string literalmsg.sender- includes a.send_message,then_terminate- contains a,_- just an underscore, which is not valid on its ownpa;;in"`aaa`"- contains;{-aaa-}- it is a commentaa(bb- contains an opening parenthesis123- a number literal_+_- it is a reserved builtin name
`. These identifiers can contain any characters except:
- Newline characters
\n - Backticks
`themselves, except the opening and closing ones.
`I'm a variable identifier too``any symbols ; ~ () are allowed here...`
Constants
FunC allows defining compile-time constants that are substituted and pre-computed during compilation. Syntax:optional-type(e.g.,intorslice) is optional but improves readability and ensures type correctness.value-or-expressioncan be a literal or an expression involving literals and previously defined constants.
const declaration by separating them with ,.
Example usage:
Compile-time built-ins
FunC has a special syntax for compile-time operations that compute slices and integer hashes out of ASCII strings. These compile-time operations are invoked by enclosing the ASCII string in double quotes", followed
by a suffix representing the compile-time operation to apply on the string, like:
u represents the compile-time operation to invoke on the ASCII string.
These built-ins are evaluated during compilation time, which means that the FunC compiler replaces the built-in call anywhere
it occurs with the result of the call. In particular, it is possible to use these compile-time built-ins while declaring constants:
String without suffix
If no suffix is provided, the compiler computes a slice from the ASCII string, such that the contents of the slice is the binary code of the ASCII string.String with suffix s
Suffix s interprets the string as an hexadecimal number and produces a slice having the binary representation of the hexadecimal number.
If the string is not an hexadecimal number, the compiler signals an error.
String with suffix a
Suffix a interprets the string as an address and creates a slice containing a MsgAddressInt structure from the address.
String with suffix u
Suffix u produces the decimal representation of the binary code of the ASCII string.
String with suffix h
Suffix h generates an integer from the first 32 bits of the string’s SHA-256 hash.
String with suffix H
Suffix H generates an integer from the full 256-bit SHA-256 hash of the string.
String with suffix c
Suffix c generates an integer from the crc32 value of the string.
String with multiple lines
Special characters like\n are not supported in strings, but you can create multi-line strings by writing the text across multiple lines,
all surrounded by triple quotes """. The triple quotes syntax also supports the previously described suffixes.
For example: