Event class
The only object type that exists is the event, which has the following format on the wire:
- "id": "32-bytes hex-encoded sha256 of the the serialized event data"
- "pubkey": "32-bytes hex-encoded public key of the event creator",
- "created_at": unix timestamp in seconds,
- "kind": integer,
- "tags": [
"e", "32-bytes hex of the id of another event", "recommended relay URL"
,"p", "32-bytes hex of the key", "recommended relay URL"
], - "content": "arbitrary string",
- "sig": "64-bytes signature of the sha256 hash of the serialized event data, which is the same as the 'id' field"
- Implementers
Constructors
-
Event.new(String id, String pubkey, int createdAt, int kind, List<
List< tags, String content, String sig, {String? subscriptionId, bool verify = true})String> > - Default constructor
- Event.deserialize(dynamic input, {bool verify = true})
-
Deserialize a nostr event message
factory
-
Event.from({int? createdAt, required int kind, List<
List< tags = const [], required String content, required String privkey, String? subscriptionId, bool verify = false})String> > -
Instantiate Event object from the minimum needed data
factory
-
Event.fromJson(Map<
String, dynamic> json, {bool verify = true}) -
Deserialize an event from a JSON
factory
- Event.partial({dynamic id = "", dynamic pubkey = "", dynamic createdAt = 0, dynamic kind = 1, dynamic tags = const <List<String>>[], dynamic content = "", dynamic sig = "", dynamic subscriptionId, bool verify = false})
-
Partial constructor, you have to fill the fields yourself
factory
Properties
- content ↔ String
-
arbitrary string
getter/setter pair
- createdAt ↔ int
-
unix timestamp in seconds
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- id ↔ String
-
32-bytes hex-encoded sha256 of the the serialized event data (hex)
getter/setter pair
- kind ↔ int
-
- 0: set_metadata: the content is set to a stringified JSON object {name:
- 1: text_note: the content is set to the text content of a note (anything the user wants to say). Non-plaintext notes should instead use kind 1000-10000 as described in NIP-16.
- 2: recommend_server: the content is set to the URL (e.g., wss://somerelay.com) of a relay the event creator wants to recommend to its followers.
getter/setter pair - pubkey ↔ String
-
32-bytes hex-encoded public key of the event creator (hex)
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sig ↔ String
-
64-bytes signature of the sha256 hash of the serialized event data, which is the same as the "id" field
getter/setter pair
- subscriptionId ↔ String?
-
subscription_id is a random string that should be used to represent a subscription.
getter/setter pair
-
The tags array can store a tag identifier as the first element of each subarray, plus arbitrary information afterward (always as strings).
getter/setter pair
Methods
-
getEventId(
) → String - To obtain the event.id, we sha256 the serialized event. The serialization is done over the UTF-8 JSON-serialized string (with no white space or line breaks) of the following structure:
-
getSignature(
String privateKey) → String - Each user has a keypair. Signatures, public key, and encodings are done according to the Schnorr signatures standard for the curve secp256k1 64-bytes signature of the sha256 hash of the serialized event data, which is the same as the "id" field
-
isValid(
) → bool - Verify if event checks such as id, signature, non-futuristic are valid Performances could be a reason to disable event checks
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
serialize(
) → String - Serialize to nostr event message
-
toJson(
) → Map< String, dynamic> - Serialize an event in JSON
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited