Hardened JavaScript
What is SES?
Valdium's contract VM is built on Secure ECMAScript (SES) — a project originally built by Agoric to make JavaScript safe for running untrusted code in production.
SES does three things: it freezes all JavaScript primordials (Object.prototype, Array.prototype, etc.), strips every source of non-determinism (Date.now, Math.random, fetch, timers), and provides a Compartment class for evaluating code in complete isolation.
Why this matters
Two validators running the same contract on the same input will produce byte-identical output. The contract cannot reach the network or filesystem. It cannot mutate globals. It cannot learn the wall-clock time unless you explicitly pass it. This is determinism you can rely on.
The compartment model
import 'ses';
lockdown();
const compartment = new Compartment({
storage, msg, chain, emit, assert,
});
const contract = compartment.evaluate(contractSource);That's the entire VM. The injected globals (storage, msg, etc.) are the only way the contract can interact with the outside world. Everything else is sealed.
What is and isn't available
// Available
Array, Object, Map, Set, BigInt, JSON, Math (pure ops only)
Promise (for inter-contract calls), crypto (subtle, getRandomValues removed)
// NOT available — stripped by lockdown()
Date.now, Math.random, setTimeout, setInterval
fetch, XMLHttpRequest, WebSocket
process, require, import() (dynamic)
eval (outside the compartment boundary)Reentrancy: structurally impossible
When a contract calls another contract (await E(addr).method()), the current execution is suspended until the callee finishes completely. The callee runs in a separate invocation with already-committed state. The caller cannot receive control back while it is mid-update.
This isn't a guard you write. It's a property of the execution model. The entire class of reentrancy bugs — The DAO, every DeFi drain since — does not exist on Valdium.
V8 version pinning
Determinism requires that all validators run the same JS engine version. Valdium validators are required to run a pinned Node.js LTS version, published in the protocol spec. Deviating from the pinned version causes state divergence and automatic exclusion from the validator set.