Skip to Content
dApps
Auf dieser Seite

signEvent

Methode

declare function signEvent(event: UnsignedEvent): Promise<Event>;

Parameter

  • event — erforderlich object
    • kind — erforderlich number
    • content— erforderlich string
    • tags — erforderlich Array<Array<string>>
    • created_at — erforderlich number Unix-Zeitstempel in Sekunden
export type UnsignedEvent = { kind: EventKind; content: string; tags: string[][]; created_at: number; }; export enum EventKind { Metadata = 0, Text = 1, RelayRec = 2, Contacts = 3, DM = 4, Deleted = 5, }

Antwort

akzeptiert ein Ereignisobjekt, fügt hinzu: id, pubkey und sig und gibt es zurück

Ergebnis

export type Event = { id: string; kind: EventKind; pubkey: string; content: string; tags: string[][]; created_at: number; sig: string; };

Beispiel

const event = { created_at: Math.floor(Date.now() / 1000), kind: 1, content: "OneKey 🚀", tags: [], }; const provider = (window.$onekey && window.$onekey.nostr) || window.nostr; const signedEvent = await provider.signEvent(event);

Demo

Beispiel öffnen 

Zuletzt aktualisiert am