Nip01Event constructor

Nip01Event({
  1. required String pubKey,
  2. required int kind,
  3. required List<List<String>> tags,
  4. required String content,
  5. int createdAt = 0,
})

Creates a new Nostr event.

pubKey is the author's public key. kind is the event kind. tags is a JSON object of event tags. content is an arbitrary string.

Nostr event id and created_at fields are calculated automatically.

Implementation

Nip01Event({
  required this.pubKey,
  required this.kind,
  required this.tags,
  required this.content,
  int createdAt = 0,
}) {
  this.createdAt = (createdAt == 0)
      ? DateTime.now().millisecondsSinceEpoch ~/ 1000
      : createdAt;
  id = _calculateId(pubKey, this.createdAt, kind, tags, content);
}