Nostr Utils icon

Nostr Utils

Nostr Utility

ConvertEvent

AI-generated

Summary

Convert a Nostr event JSON object into a Naddr or Nevent encoded identifier including relay hints.

Inputs

  • ConvertOutput (required) — Choose whether to convert the event to a 'Naddr' (Nostr address) or 'Nevent' (Nostr event identifier).
  • Event (required) — Provide the source event JSON object to be converted, either as JSON or stringified JSON.
  • Relay Hints — Optionally specify a comma-separated list of relay URLs to include as hints in the encoded output; defaults to a preset list of common relays.

Output shape

a list of JSON objects each containing either a 'naddr' or 'nevent' string property representing the encoded identifier.

For 'Naddr', the event must include a 'd' tag; otherwise, an error is thrown. Relay hints are split by commas and included in the encoded output. Output corresponds to the chosen ConvertOutput option.

Examples

Example 1: Convert a Nostr event into a Naddr encoded address

Set ConvertOutput to 'Naddr', input a valid event JSON with a 'd' tag, optionally provide relay hints or leave default.

Example 2: Convert a Nostr event into a Nevent encoded identifier

Set ConvertOutput to 'Nevent', input the valid event JSON, optionally provide relay hints or leave default.

Links

Discussion