NScript is a programming language built just for Nostr. Instead of wiring together libraries, you describe what you want to happen (publish a note, reply to a message, moderate a chat) and say up front what the program is allowed to do.
use nip01
use nip46
signer account = nip46()
relayset public = configured
permissions {
read Note
publish Note
sign Note with account
relay public
}
publish Note {
content: "Hello, Nostr"
} to public with account
This program says it may read and publish notes, and nothing else. It signs through a remote signer, so the script never handles your private key.
- Safe by default. Every program lists the permissions it needs. If it tries to do something it didn't declare, it is rejected before it runs.
- Your keys stay private. Signing goes through a signer you control. Scripts never see raw private keys.
- Built for Nostr. Notes, filters, relays and signers are part of the language, not add-ons.
- Nothing new on the wire. NScript works with the Nostr protocols that already exist.
- Write bots that reply, moderate, or react to events on Nostr.
- Publish notes, articles, reactions, lists, and other Nostr content.
- Publish, validate, or audit NIP-5D napplet manifests and shell handlers.
- Publish Nostr Community Convention documents, supporting documents,
successions, and endorsements from a repository with
nscript ncc, including release-tag versioning and CI checks. - Publish NIP-34 git repository announcements, state, patches, pull requests,
issues, statuses, and grasp lists with
nscript git. - Try programs safely in a simulator before connecting to real relays.
- Write and check programs in your browser with the NScript Studio editor in
studio/.
You will need Rust installed. From this folder:
# Check a program for mistakes
cargo run -p nscript-cli -- check conformance/valid/default-publish.ns
# Run it in the simulator (nothing is sent to the network)
cargo run -p nscript-cli -- run conformance/valid/hello-note.nsMore commands, and the technical details of how modules and hosts work, are in the compiler, runtime and module reference.
For MCP-compatible agents, build and configure the general-purpose NScript
authoring server described in docs/MCP.md. It provides static
checks, permission and effect inspection, and dry event simulation.
examples/layer3-bot.nsis a small bot that responds to events and publishes notes.examples/concord-stream-moderation-bot.nsis a moderation bot for encrypted group chat. Seedocs/CONCORD-BOT.mdfor what works today.examples/napplet-lens/is the read-only NScript Lens napplet: editable, checked NScript rules scope an outbox query and produce local hide/label/pin/flag decisions.examples/nip5d-manifest-audit.nsvalidates arriving NIP-5D manifests, andexamples/nip5d-release-bot.nspublishes a named manifest with a CI-supplied artifact hash.nscript napplet requirements <file.ns>derives the supported NAP domains, handler filters, and module hash;nscript napplet build <project-directory>writes the requirements and runs the project's Vite build. The reusable embedding API is innpm/nscript-napplet/.examples/service-operator-bot.nsshows several Nostr community conventions working together.
NScript is an early draft (version 0.1). The language, checker, simulator,
browser Studio and a real relay-and-signer workflow all work. Some operations
are still simulated when you deploy, and a few features are not finished yet.
The detailed status
explains exactly which, and ROADMAP.md lists what comes next.
ROADMAP.md: current priorities and release plans.spec/: the formal language and runtime specification.docs/: guides for deployment, Concord, signing and packaging.rfcs/: proposals, including package distribution.rfcs/0003-napplets.md: proposed napplet host adapter and reference applet roadmap.docs/NAPPLETS.md: the implemented lens profile, query scoping, decisions, and browser session ABI.docs/NCC.md: publishing all four NCC-00 event kinds from a repository withnscript ncc.docs/NGIT-MIRROR.md: one-way GitHub-to-ngit mirror workflow and setup requirements.docs/NCC-INTEGRATION-IDEAS.md: proposed architecture and feasibility for NScript with NCC, napplets, nsites, and Nostr application hosts.conformance/: example programs and tests that any implementation must pass.PLAN.md: the implementation history and original phase plan.crates/: the Rust source code (compiler, runtime, command-line tool, WebAssembly build and editor support).
- Nostr is the environment, not a library.
- Nostr values are nominally typed, even when their wire encodings coincide.
- Signing and other authority flow through explicit capabilities.
- Source programs declare permissions; the compiler infers effects.
- NScript lowers to existing Nostr protocols rather than inventing a new wire protocol.
Design changes should begin as an issue or RFC and include conformance examples. Normative terms such as MUST, SHOULD, and MAY follow RFC 2119 usage.
Run ./scripts/check-spec.sh before submitting a change. It validates the local
documentation links, JSON vectors, negative-fixture metadata, and whitespace.
NScript is available under the MIT License.