Skip to main content

dostr_nip19 0.1.0 copy "dostr_nip19: ^0.1.0" to clipboard
dostr_nip19: ^0.1.0 copied to clipboard

NIP-19 bech32 encoding and decoding for Nostr (npub, nsec, note, nprofile, nevent and naddr).

example/dostr_nip19_example.dart

import 'package:dostr_nip19/dostr_nip19.dart';

void main() {
  final npub = Npub(
    '3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d',
  ).encode();
  print('$npub -> ${Npub.decode(npub).pubkey}');

  final nevent = Nevent(
    eventId: 'b9f5441e45ca39179320e0031cfb18e34078673dcc3d3e3a3b3a981760aa5696',
    relays: ['wss://relay.example.com'],
  ).encode();

  switch (Nip19Entity.decode('nostr:$nevent')) {
    case Nevent(:final eventId, :final relays):
      print('$nevent -> $eventId on $relays');
    case Npub(:final pubkey) || Nprofile(:final pubkey):
      print('profile $pubkey');
    case _:
      print('another entity');
  }
}
0
likes
160
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

NIP-19 bech32 encoding and decoding for Nostr (npub, nsec, note, nprofile, nevent and naddr).

Repository (GitHub)
View/report issues

Topics

#nostr #dostr #bech32

License

MIT (license)

Dependencies

dostr_nip01

More

Packages that depend on dostr_nip19