Skip to Content
dApps
En esta página

signEvent

Método

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

Parámetros

  • event — obligatorio object
    • kind — obligatorio number
    • content— obligatorio string
    • tags — obligatorio Array<Array<string>>
    • created_at — obligatorio number Marca de tiempo Unix en segundos
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, }

Respuesta

recibe un objeto de evento, añade id, pubkey y sig y lo devuelve

Resultado

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

Ejemplo

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

Demostración

Abrir ejemplo 

Última actualización el