Native Functions
Reference for all 16 global functions available without imports.
In beta.13, most collection, string, math, and conversion functions moved to type methods.
For example, push(list, x) is now list.push(x), and abs(n) is now n.abs().
See Methods & Static Namespaces for the full reference.
Achronyme provides 16 global functions: 14 built into the VM core, plus 2 from the standard library (achronyme-std). All are available as globals — no imports needed. Some are also available in circuit mode.
Core
print(...values)
Prints all arguments separated by spaces, followed by a newline. Returns nil.
print("hello", 42, true) // hello 42 true
Mode: VM only
typeof(x)
Returns a string describing the type of the value: "Number", "String", "Bool", "Nil", "List", "Map", "Field", "BigInt256", "BigInt512", "Proof", "Function", "Native".
typeof(42) // "Number"
typeof("hi") // "String"
typeof(true) // "Bool"
Mode: VM only
assert(condition)
Asserts that the condition is true. Returns nil on success, raises AssertionFailed on failure.
assert(1 + 1 == 2) // ok
assert(false) // error: AssertionFailed
Mode: Both (in circuits, emits 2 constraints: boolean enforcement + enforce = 1)
time()
Returns the current time as milliseconds since the Unix epoch.
let t = time()
print(t) // 1740700800000
Mode: VM only
gc_stats()
Returns a map with garbage collector statistics. See GC Statistics for details.
let stats = gc_stats()
print(stats["collections"]) // number of GC cycles
print(stats["bytes_freed"]) // cumulative bytes reclaimed
print(stats["peak_bytes"]) // maximum heap size reached
print(stats["gc_time_ms"]) // cumulative ms spent in GC
print(stats["bytes_allocated"]) // current live heap size
Mode: VM only
Proof Inspection
These functions extract components from a ProofObject returned by prove {}.
proof_json(proof)
Returns the Groth16 proof as a JSON string.
let p = prove { ... }
print(proof_json(p)) // {"pi_a": [...], "pi_b": [...], ...}
Mode: VM only
proof_public(proof)
Returns the public inputs as a JSON string.
print(proof_public(p)) // ["21888...", "17159..."]
Mode: VM only
proof_vkey(proof)
Returns the verification key as a JSON string.
print(proof_vkey(p)) // {"protocol": "groth16", "curve": "bn128", ...}
Mode: VM only
Cryptographic
poseidon(left, right)
Computes the Poseidon 2-to-1 hash over BN254. Both arguments can be integers or field elements.
let h = poseidon(1, 2)
print(h) // field element
Mode: Both (in circuits, emits 361 constraints)
poseidon_many(a, b, ...)
Left-fold Poseidon hash: poseidon(poseidon(a, b), c) and so on. Requires at least 2 arguments.
let h = poseidon_many(1, 2, 3, 4)
// equivalent to: poseidon(poseidon(poseidon(1, 2), 3), 4)
Mode: Both (in circuits, emits 361 constraints per pair)
verify_proof(proof)
Verifies a Groth16 proof. Returns true if valid, false otherwise. Requires a verify handler to be configured in the VM.
let p = prove { ... }
let ok = verify_proof(p)
print(ok) // true
Mode: VM only
BigInt Constructors
bigint256(x)
Constructs a 256-bit unsigned integer from an integer (>= 0) or string. Strings can use 0x (hex), 0b (binary), or decimal format.
let a = bigint256(42)
let b = bigint256("0xFF")
let c = bigint256("12345")
Mode: VM only
bigint512(x)
Constructs a 512-bit unsigned integer. Same argument formats as bigint256.
let a = bigint512(42)
let b = bigint512("0xFF")
Mode: VM only
from_bits(bits, width)
Constructs a BigInt from a list of 0/1 integers (LSB-first). Width must be 256 or 512.
let val = from_bits(bigint256(42).to_bits(), 256)
assert(val == bigint256(42))
Mode: VM only
Standard Library
parse_int(str)
Parses a string as an integer. Errors if the string is not a valid number.
parse_int("42") // 42
parse_int("-7") // -7
join(list, separator)
Joins a list of strings with the given separator.
join(["a", "b", "c"], "-") // "a-b-c"
join(["hello"], " ") // "hello"
Summary Table
| # | Function | Arity | Mode | Returns |
|---|---|---|---|---|
| 0 | print(...) | variadic | VM | nil |
| 1 | typeof(x) | 1 | VM | string |
| 2 | assert(x) | 1 | Both | nil |
| 3 | time() | 0 | VM | int |
| 4 | gc_stats() | 0 | VM | map |
| 5 | proof_json(p) | 1 | VM | string |
| 6 | proof_public(p) | 1 | VM | string |
| 7 | proof_vkey(p) | 1 | VM | string |
| 8 | poseidon(a, b) | 2 | Both | field |
| 9 | poseidon_many(...) | variadic | Both | field |
| 10 | verify_proof(p) | 1 | VM | bool |
| 11 | bigint256(x) | 1 | VM | BigInt256 |
| 12 | bigint512(x) | 1 | VM | BigInt512 |
| 13 | from_bits(bits, width) | 2 | VM | BigInt |
| Standard Library | ||||
| 14 | parse_int(str) | 1 | VM | int |
| 15 | join(list, sep) | 2 | VM | string |