repostEvent
Share existing Nostr events to your network by creating reposts, enabling content distribution across the decentralized social protocol.
Instructions
Repost an event (kind 6)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| eventId | Yes | ID of the event to repost | |
| eventPubkey | Yes | Pubkey of the event author | |
| relayUrl | No | Relay URL where the original event lives | |
| privateKey | No | Private key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured. | |
| relays | No | Relays to publish to |
Implementation Reference
- src/tools/social-tools.ts:129-141 (handler)The handler implementation for reposting an event in Nostr (kind 6).
export async function repostEvent({ eventId, eventPubkey, relayUrl, privateKey, relays }: z.infer<typeof repostEventSchema>) { const eTag = relayUrl ? ['e', eventId, relayUrl] : ['e', eventId]; const template: EventTemplate = { kind: KINDS.REPOST, content: '', tags: [eTag, ['p', normalizePubkey(eventPubkey)]], created_at: Math.floor(Date.now() / 1000), }; const signed = await signTemplate(template, privateKey); const result = await publishEvent(signed, relays ?? DEFAULT_RELAYS); return { event: signed, published: result }; } - src/tools/social-tools.ts:29-35 (schema)Zod schema definition for input validation of the repostEvent tool.
export const repostEventSchema = z.object({ eventId: z.string().describe('ID of the event to repost'), eventPubkey: z.string().describe('Pubkey of the event author'), relayUrl: z.string().optional().describe('Relay URL where the original event lives'), privateKey: z.string().optional().describe(privateKeyDesc), relays: z.array(z.string()).optional().describe('Relays to publish to'), });