Nostr
Description
Rust implementation of Nostr protocol.
You may be interested in:
nostr-sdkif you want to write a typical nostr client or botnostr-connect: Nostr Connect (NIP46) client and signernwc: Nostr Wallet Connect (NWC) client
Getting started
use NonZeroU8;
use *;
More examples can be found in the examples/ directory.
Crate Feature Flags
The following crate feature flags are available:
| Feature | Default | Description |
|---|---|---|
std |
Yes | Enable std library |
alloc |
No | Needed to use this library in no_std context |
rand |
No | Enables rand traits |
os-rng |
No | Enable OS Random Number Generator |
pow-multi-thread |
No | Enable event POW mining using multi-threads |
all-nips |
No | Enable all NIPs |
nip03 |
No | Enable NIP-03: OpenTimestamps Attestations for Events |
nip04 |
No | Enable NIP-04: Encrypted Direct Message |
nip06 |
No | Enable NIP-06: Basic key derivation from mnemonic seed phrase |
nip44 |
No | Enable NIP-44: Encrypted Payloads (Versioned) |
nip46 |
No | Enable NIP-46: Nostr Connect |
nip47 |
No | Enable NIP-47: Nostr Wallet Connect |
nip49 |
No | Enable NIP-49: Private Key Encryption |
nip59 |
No | Enable NIP-59: Gift Wrap |
nip60 |
No | Enable NIP-60: Cashu Wallets |
WASM
This crate supports the wasm32-unknown-unknown and wasm32-wasip2 targets.
The other WASM targets may be supported bur are not tested.
wasm32-wasip2
To compile for wasm32-wasip2 you need to:
- Download the WASI SDK from https://github.com/WebAssembly/wasi-sdk
- Extract it and set the
WASI_SDKenvironment variable - Set the
CC_wasm32_wasip2="$WASI_SDK/bin/clang",AR_wasm32_wasip2="$WASI_SDK/bin/llvm-ar"andCFLAGS_wasm32_wasip2="--sysroot=$WASI_SDK/share/wasi-sysroot"environment variables - Build!
Example (note, links and version may be outdated):
# 1. Download and extract the WASI SDK
# 2. Set the path variable (adjust if you extracted it somewhere else)
# 3. Export the environment variables that the 'cc' crate looks for
# This tells the build script specifically which compiler to use for this target
# 4. Now run your build command
wasm32-unknown-unknown
On macOS you need to install llvm:
brew install llvm
LLVM_PATH=$(brew --prefix llvm)
AR="${LLVM_PATH}/bin/llvm-ar" CC="${LLVM_PATH}/bin/clang" cargo build --target wasm32-unknown-unknown
The other platforms should work out of the box.
Embedded
This crate support no_std environments.
Check the example in the embedded/ directory.
Changelog
All notable changes to this library are documented in the CHANGELOG.md.
State
This library is in an ALPHA state, things that are implemented generally work but the API will change in breaking ways.
Donations
rust-nostr is free and open-source. This means we do not earn any revenue by selling it. Instead, we rely on your financial support. If you actively use any of the rust-nostr libs/software/services, then please donate.
License
This project is distributed under the MIT software license - see the LICENSE file for details