Build on Asentum
Approved Libraries
Governance-curated VM extensions · Estimated read time: 5 minutes
TL;DR
Approved libraries are JavaScript modules whose source is stored on-chain and injected into every contract's SES Compartment. They are the only "standard library" contracts can import, and they can only be added by an on-chain governance hard proposal. No npm install. No arbitrary imports. No hidden dependencies.
How they work
When a contract is executed, the VM looks up the current approved-libraries index from the governance contract and, for each library, evaluates the source in a sub-Compartment with no host APIs, freezes the result with harden(), and adds the frozen object to the contract's endowments under its library name.
The contract sees the library as a regular global. It can't mutate it, can't reach outside it, and can't swap it out.
Using an approved library
function circleArea(r) {
return math.PI * r * r;
}
function sqrtN(n) {
return math.sqrt(n);
}No import, no require — approved libraries are always in scope.
What is approved today
The approved set starts small on purpose. Each library has been through a governance hard proposal:
- math — pure mathematical helpers. Constants (PI, E),
sqrt,pow, trig. - More libraries arrive as governance approves them.
The current authoritative list is retrievable at any time via asentum_getApprovedLibraries or the explorer.
Proposing a new library
Anyone with enough bonded stake can propose a new approved library. The process is:
- Write the library source. It must be pure JavaScript with no host APIs — if it imports anything, it won't pass.
- File a hard proposal with the library name and full source.
- Community reviews. Amendments are expected — the source on-chain must be exactly what's agreed on.
- 3-week voting window, 2/3 supermajority, 10% quorum.
- If it passes, the execution timelock elapses, then the library is added to the index. Every subsequent contract call has access.
Safety properties
- Frozen. Libraries are
harden()ed before contracts see them. No contract can mutate the library or add spy getters. - No host APIs. Libraries evaluate in sub-Compartments without
storage,emit, orE. They are pure code. - Deterministic. Like all contract code, libraries must be deterministic. No clocks, no randomness, no I/O.
- Versioned. A library at "math" is a specific BLAKE3 hash of a specific source. Upgrading it is a new governance proposal, not a silent swap.
Read next