Basic Types
fi is a statically typed language, where a variable must be typed on declaration and that type cannot change. When you are setting a variable to a literal value, you must also ensure the type is declared.
During compilation, types are strictly checked and enforced. These types reflect the native Michelson types. All available basic types are defined below:
Boolean
bool - possible values being either true or false.
Integers & Natural Numbers
Integers and naturals are arbitrary-precision, meaning the only size limit is fuel. The only difference is that Natural Numbers are unsigned.
int - possible values being any integer value (negative and positive) nat - possible values being any positive integer value
Note: Some arithmetic functions will return a different type based on the input types. You can use to_* functions if you need to typecast a specific value.
Strings
Strings are used to hold a value in text form.
string - possible value being anything, but must be encompassed by double-quotes "text"
Mutez
Mutez is the native Michelson type for defining a variable to represent a mutez, the native currency of Tezos in its smallest denomination (e.g. 0.000001 tez).
Mutez are internally represented by a 64 bit signed integer. There are restrictions to prevent creating a negative amount of mutez. Operations are limited to prevent overflow and mixing them with other numerical types by mistake. They are also checked for under/overflows.
mutez - possible values being any positive integer value
Timestamp
Timestamps represent a date/time value.
timestamp - valid RFC 339 notation, encompassed by double-quotes, or alternatively number of seconds since Unix Epoch.
Address
Addresses are untyped native contract addresses stored on the Tezos blockchain.
address - must be a valid public address and must be provided in the base58-check encoded version encompassed by double quotes (e.g. "KT1...", "tz1...").
Public Key
Public keys are used for verifying a signed message using the verify function, or can be converted to a public key hash (pkh/key_hash) and used for on-chain operations (delegation, origination and transfer).
key - must be a valid public key, encompassed by double quotes, in the base58-check encoded format (e.g. "edpk...", "p2pk")
Public Key Hash
Public key hashes are the hashed form of a key, and can also be used to create an implicit contract (and therefore address using typecasting). This type can be declared as key_hash or via an alias, pkh.
key_hash|pkh - must be a valid public key hash, encompassed by double quotes, in the base58-check encoded format (e.g. "tz1...", "tz2...").
Signature
Signatures are base58-check encoded signatures (e.g. "edsig..."). These can be generated by the node-client to sign a message with a users private key. This can then be verified within fi using the verify function.
signature - must be a valid base58-check encoded signature, encompassed by double-quotes "..."
Bytes
Bytes are defined as hexadecimal, and can be used for multiple purposes.
bytes - must be valid hex, starting with 0x. This should not be wrapped in double quotes;
Last updated