nostr_dart 0.2.0 copy "nostr_dart: ^0.2.0" to clipboard
nostr_dart: ^0.2.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, recommend_server and contact_list events to connected relays.
  • Request events and subscribe to updates.

Supported Nostr Implementation Possibilities:

Getting started #

Add the following to your pubspec.yaml:

dependencies:
  nostr_dart: ^[version]

Usage #

Initialise nostr_dart:

import 'package:nostr_dart/nostr_dart.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]);

Publish a contact list:

final contacts = ContactList();
final contact = Contact.init(publicKey: [public key], url: [relay url], petname: [petname]);
contacts.add(contact);
final result = await nostr.sendContactList(contacts);

Remove an existing subscription:

nostr.unsubscribe([subscription id]);

Remove a connected relay:

nostr.removeRelay([relay url]);
1
likes
0
pub points
23%
popularity

Publisher

unverified uploader

A Nostr client library written in Dart

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

bip340, clock, crypto, hex, string_validator, web_socket_channel

More

Packages that depend on nostr_dart