nostr_tools.generate_event

nostr_tools.generate_event(private_key, public_key, kind, tags, content, created_at=None, target_difficulty=None, timeout=20)[source]

Generate a signed Nostr event with optional proof-of-work.

This function creates a complete Nostr event with proper ID calculation, signature generation, and optional proof-of-work nonce mining.

Parameters:
  • private_key (str) – Private key in hex format (64 characters)

  • public_key (str) – Public key in hex format (64 characters)

  • kind (int) – Event kind (0-65535)

  • tags (List[List[str]]) – List of event tags

  • content (str) – Event content

  • created_at (Optional[int]) – Unix timestamp (defaults to current time)

  • target_difficulty (Optional[int]) – Proof of work difficulty target (leading zero bits)

  • timeout (int) – Timeout for proof of work mining in seconds (default: 20)

Returns:

Complete signed event dictionary with keys:

id, pubkey, created_at, kind, tags, content, sig

Return type:

Dict[str, Any]