naddr property
String?
get
naddr
Encode this event as an naddr (NIP-19 addressable event coordinate)
Only works for coordinate-capable replaceable events. Requires a "d" tag to identify the event.
Returns a bech32-encoded naddr string or null if:
- Event is not addressable/replaceable
- Event doesn't have a "d" tag
Usage: final naddr = event.naddr;
Implementation
String? get naddr {
// NIP-19 coordinates are valid for parameterized replaceables and
// singleton replaceable kinds that use an empty d-tag.
if (!_supportsCoordinate(kind)) {
return null;
}
// Get the "d" tag identifier
final identifier = getDtag();
if (identifier == null) {
return null;
}
return Nip19.encodeNaddr(
identifier: identifier,
pubkey: pubKey,
kind: kind,
relays: sources.isEmpty ? null : sources,
);
}