A permissionless ledger on urd, where the database is datahike and the smart contracts are Datalog.
Skuld is the third Norn, sister to Urðr. The name means debt — from Old
Norse skulu, and sharing its root with English should. Urd decides what
has become; skuld is what is owed. Both meanings are the subject matter: a
ledger is obligations, and its contracts are invariants — statements of what
should hold.
Status — Skuld is an experimental, unaudited library. There is no public network. See known limitations.
Add the Clojars release to your application’s deps.edn:
{:deps {org.replikativ/skuld {:mvn/version "0.1.19"}}}
Start clojure -M in your application and create a signer:
(require '[skuld.client :as client])
(def identity-record (client/new-identity))
(def signer (client/signer identity-record))
(:ns signer) ; the account namespace
A sender signs a vector of Datahike entity maps and write operations.
{:chain :urd-net
:sender "<hex of your genesis hash>"
:nonce 7
:tx-data [{:db/id "note" :<your-namespace>/text "hello"}]
:public-key <32 bytes>
:signature "<base64url Ed25519>"}
Validators apply an ordinary signed write in this order.
bounded envelope → chain and input checks → authorised signing key → signature
→ nonce and funds → permitted operations → bounded transaction preparation
→ ownership and price → change guards → settlement and storage → commit
A single entity retraction can remove an entire component tree. Datahike accounts for rows visited during preparation, and Skuld checks ownership and guards against the resulting changes. The transaction specification lists the supported forms, limits, fees and refusal reasons. Ordinary signed writes
Your account namespace is the hash of a genesis record. That indirection is
what lets an operational key rotate without your identity moving — the
difference between this and the did:key / SSB model, where the key is the
name and rotation means becoming somebody else.
A hex namespace belongs to the key that owns it. Everything under db,
invariant, urd.account, urd.stake and rules is protocol state that no
sender may write. The one exception is urd.stake.intent, a request
channel: writing one moves nothing, and the protocol re-validates every intent
at the end of the block against state the sender does not control before any
value moves.
[{:db/id "intent"
:urd.stake.intent/op :delegate
:urd.stake.intent/validator "<validator namespace>"
:urd.stake.intent/amount 3000000}]
No second envelope kind, no separate signing scheme. Solana is the precedent: its Stake Program was a builtin inside the validator and is now an ordinary program, so the runtime reads staking state rather than owning it.
Rewards are F1 (O(1) in delegators), slashing is share-dilution, and validator set changes reach consensus at epoch boundaries — except jailing, which does not wait, because a jailed validator held in the set keeps taking proposer turns it will not answer.
skuld.conservation states five properties over the stake projection and
halts the node when one is false, the way Cosmos's crisis module does.
They run against the candidate final state before the ledger publishes the completed height. Recovery preserves the already settled envelope prefix.
Each corresponds to a bug this codebase actually shipped and fixed.
With the signer above and a funded account, read the next nonce from the finalized ledger before signing a guard.
;; After genesis funds this identity and installs the business attributes:
(def nonce (:next-nonce (client/account-state db (:ns signer))))
(def deployment (client/sign-guard signer chain nonce registration))
;; Submit deployment to the validator transport. Use :guard-digest from the
;; confirmed result as :replaces when signing a later guard revision.
The ticketing example funds two accounts, installs and replaces a guard, verifies acceptance and refusal, and transfers a shared row with the recipient’s countersignature.
The signer contains the operational key. Keep the identity's rotation key and revocation secret offline. The local devnet below demonstrates transport and certificate verification.
The ticket example uses the released library. Copy tickets.clj into your application's src directory and run:
clojure -M -m tickets
For development against a Skuld checkout, run clojure -M:dev -m tickets from examples/tickets. The :dev alias selects the repository sources.
Run bin/check-guard-devnet from the Skuld repository root. A client JVM creates a signing
identity, funds its account at local genesis, and submits a signed deployment,
two assertions, a retraction and a replay. Four Tendermint validators execute the batch on
independent databases. The client verifies the quorum certificate for every
height from genesis and replays the history to check the receipts and balance.
The drill uses a private temporary directory for client submission and
localhost WebSockets between validators. Contract syntax and semantics
The metered inventory experiment shows how to publish a signed Datalog invariant, limit its fuel, and replay the ledger using the pinned Datahike dependency.
clj -M:test
The suite exercises two integration scenarios:
Both are tagged ^:integration because they bind ports and assert progress
against a wall clock, but clj -M:test does not exclude them. A consensus
ledger whose socket path is optional in CI is one whose socket path rots.
| Urd algorithm | What Skuld exercises |
|---|---|
| Tendermint | Certified contract deployment and replay, four-validator transport, stake-driven committee changes, recovery drills |
| Round-robin | Stake updates and jailing in simulation |
| Raft | Decided log entries driving the Datahike ledger |
| Nakamoto | Real fork selection and reorganization of a Datahike ledger |
Tendermint is the proposed public-network profile. Switching the underlying algorithm changes what a client can accept as final and how membership and operator incentives work. Skuld has no live consensus-switch operation.
The validator-join workflow landed on main after the 0.1.19 release.
A new operator can fund a fresh identity, register its own consensus key, and
enter the Tendermint committee through stake. Run bin/check-validator-join
to see four incumbents admit a fifth validator whose vote is required for the
next commit. The joining node checks certified history from genesis against an
independent checkpoint. SDK and operator workflow
The four-validator socket demo uses a fixed committee. Each validator signs Tendermint votes as well as network envelopes, verifies the content ID and schema of every proposed demo transaction, and stores consensus history in a Konserve WAL beside its Datahike database. Datahike's committed vertex marks supply the delivery cursor on restart. The socket test takes a client offline, lets the other three commit new transactions, and reopens both stores. It checks the recovered commit certificate and compares the transaction order across all four databases.
Run clojure -M:test -n skuld.ledger.cluster-test to exercise the cluster.
The demo keeps validator keys and the roster in the running harness. Restarting the
whole deployment requires durable identity provisioning. Its one-fact schema
is for the demo; signed ledger admission, fees and staking are exercised in
separate Skuld tests. The Tendermint set-change simulation applies blocks to
independent Skuld databases, derives a jailed validator’s removal from stake,
then checks that the remaining validators activate the new powers and continue
committing. Compute each proposal’s content ID after attaching these updates.
For a stake-backed validator, install skuld.consensus/tendermint-options
with a getter for the local driver and the application's payload validator.
This requires Urd's :valid-at-height? callback. The validator compares the
updates with its own applied ledger at the consensus height, including during
catch-up. The stake projection stores the expected updates in the same
transaction as the block's final stake state, so reopening the driver preserves
an outstanding change. All validators must upgrade together because this adds
data to the application state. A non-genesis legacy stake database without a
recorded update boundary requires replay from verified history before voting.
Run bin/check-tendermint-restore to exercise offline state transfer. It
starts three fresh JVMs and uses temporary file stores and per-validator
Ed25519 identities. The returning peer stops at cursor 3. The surviving
quorum changes voting power and reaches cursor 12 with a three-height
decision window. After the donor stops, stage its database image and compare
the application digest and cursor with an independently trusted consensus
boundary (committee, powers, priorities, and last decided height). Retain
the returning peer's signing state and replay registers in its own WAL. The
drill checks stale/mismatched pairs before activating the staged copy, then
checks agreement and a fresh certificate through cursor 15. The copied
Datahike image retains its store ID; the donor stays offline in the final
phase. The drill pins its manifest in a trusted temporary directory. Production
distribution needs an authenticated manifest and an atomic, restartable
switch of the application and consensus stores.
Reopening a linear Datahike history scans its ordered vertex metadata and commit boundaries. Histories with merges, rewinds or nonstandard metadata use the historical recovery path. This bounds repeated enumeration on the normal path; the database still opens its historical commit objects.
Not "untested" — not built yet, and the chain would behave wrongly if used:
skuld.block/reconcile-supply.stake/handle-equivocation has no live block caller, so slashing
for a double-sign is state-level machinery with nothing driving it.There is more, with measurements, in the internal backlog.
src/skuld/ the chain: boundary, block, staking, invariant, conservation
src/skuld/ledger/ the substrate: accounts, authz, ownership, cost, stake
doc/interop/ a client in Python, sharing no code with skuld
Copyright © 2026 Christian Weilbach. Distributed under the Apache License, Version 2.0.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |