Skip to Content
dApps
Sur cette page

signEvent

Méthode

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

Paramètres

  • event — obligatoire object
    • kind — obligatoire number
    • content— obligatoire string
    • tags — obligatoire Array<Array<string>>
    • created_at — obligatoire number Horodatage Unix en secondes
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, }

Réponse

Accepte un objet événement, ajoute id, pubkey et sig, puis le renvoie.

Résultat

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

Exemple

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);

Démonstration

Ouvrir l’exemple 

Dernière mise à jour le