nostr_dart 0.1.0 nostr_dart: ^0.1.0 copied to clipboard
A Nostr client library written in Dart
A Nostr client library written in Dart.
Features #
Use this library in your Dart/Flutter app to:
- Connect to Nostr relays.
- Publish
set_metadata
,text_note
andrecommend_server
events to connected relays. - Request events and subscribe to updates.
Currently implements NIP-01, NIP-13, NIP-15 and NIP-20
Getting started #
Add the following to your pubspec.yaml
:
dependencies:
nostr_dart: ^[version]
Usage #
Initialise nostr_dart
:
import 'package:nostr/nostr.dart';
final nostr = Nostr.init(privateKey: [private key], powDifficulty: [difficulty]);
Add a relay:
await nostr.addRelay([relay url]);
Retrieve events from connected relays and subscribe to updates:
final subId = await nostr.subscribe([filters], [subscription id])
Read retrieved events:
for (Event event in nostr.events) {
print('ID: ${event.id}. Content: ${event.content}');
}
Publish a text note:
final result = await nostr.sendTextNote([content], [tags]);
Publish metadata:
final result = await nostr.setMetaData(name: [name], about: [about], picture: [picture url]);
Publish server recommendation:
final result = await nostr.recommendServer([relay url]);
Remove an existing subscription:
nostr.unsubscribe([subscription id]);
Remove a connected relay:
nostr.removeRelay([relay url]);