Build on Asentum
Approved Libraries
Disabled · Estimated read time: 3 minutes
TL;DR
Library approval through governance is disabled. No library is approved, and from block 330,000 (node 0.6.79) the governance contract refuses library proposals and the node no longer injects libraries into contracts. Contracts have no importable modules: write the code you need inside your contract.
What it was
Governance v1 had a library proposal category. If one passed, its JavaScript source was stored on chain and the node added it as a global to every contract's SES Compartment. The idea was a small shared standard library that contracts could use without imports.
Why it is disabled
- It reached every contract. A library became a global in every contract, system contracts such as staking included. One approval changed the environment of all deployed code at once.
- Any name was allowed. A library could take a name contracts already depend on (for example
assert,JSONorstorage) and replace it. - It ran without gas. Library code was evaluated outside gas metering, so a heavy library would slow every contract call with no one paying for it.
- A simple majority was enough. The same bar as any other proposal, for a change that touches all contracts.
What this means today
- Proposing with the
librarycategory reverts. GET /governance/librarieson the node RPC always returns an empty list, and the contract'sgetApprovedLibraries()returns an empty list.- Contracts do not see any library globals. If your contract needs a helper such as a square root, include it in your contract source.
What it would take to return
Library approval could come back only with all of these in place. None of them exist yet, and there is no date:
- Reserved names. Built-in globals and host APIs cannot be taken by a library.
- Metered evaluation. Library code is charged gas like any other contract code.
- Pinned versions. A contract uses a specific version of a library and never gets new code without choosing to.
- A higher approval bar. More than a simple majority, with a longer window, for anything that affects every contract.
Read next