Global functions
Rell provides a collection of built-in global functions for common tasks. For complete API documentation, see the Standard Library reference.
Overview
Global functions are available without any namespace prefix and cover:
- Math operations –
abs,min,maxforinteger,big_integer, anddecimaltypes - Collection checks –
emptyandexistsfor nullable values, lists, sets, and maps - Output –
printandlogfor debugging - Cryptographic hashes –
sha256,keccak256 - Signature verification –
verify_signature - Ethereum operations –
eth_ecrecoverfor public key recovery - Error handling –
require,rell.error,try_call, andtry_call_catch, documented underrequireand error handling
Key functions
abs– Returns the absolute value of a numbermin,max– Returns the smaller/larger of two valuesempty– Checks if a value is null or an empty collectionexists– Checks if a value is non-null and non-emptyprint,log– Output to stdout or logsha256,keccak256– Cryptographic hash functionsverify_signature– Verifies a signature against a message and public keytry_call,try_call_catch– Catch exceptions; seerequireand error handling
Using empty and exists in at-expressions
Both empty() and exists() support nested at-expressions, enabling efficient SQL queries:
// Find users with no company in their city
user @* {
empty(company @* { .city == user.city })
}
// Find users with at least one company in their city
user @* {
exists(company @* { .city == user.city })
}
Use @* in nested at-expressions to execute as a single SQL query. Other cardinality operators (@+, @?, @) result
in separate queries.