Event constructor

Event(
  1. String pubKey,
  2. int kind,
  3. List tags,
  4. String content,
)

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.

An ArgumentError is thrown if pubKey is invalid.

Implementation

Event(this.pubKey, this.kind, this.tags, this.content) {
  if (!keyIsValid(pubKey)) {
    throw ArgumentError.value(pubKey, 'pubKey', 'Invalid key');
  }
  createdAt = _secondsSinceEpoch();
  id = _getId(pubKey, createdAt, kind, tags, content);
}