Paso 1 de 5
El código es el content
Pon el fragmento en el content tal como está escrito. Los clientes conservan los espacios y la indentación y ofrecen copiarlo con un clic.
NIP-C0
BorradorEventos
Comparte código como eventos kind 1337: el content es el código, y los tags indican el lenguaje, el nombre de archivo, la licencia, las dependencias y el repositorio de origen.
Edita el formulario o el JSON: ambos se mantienen sincronizados, la insignia indica si el resultado es válido y, al tocar cualquier campo, se explica qué hace.
Aún sin firmar · Solo claves de demo. Las claves secretas de estos personajes son públicas a propósito.
Selecciona cualquier campo del formulario o del JSON para ver qué hace.
Paso 1 de 5
Pon el fragmento en el content tal como está escrito. Los clientes conservan los espacios y la indentación y ofrecen copiarlo con un clic.
Ningún capítulo del curso cubre este NIP todavía. El editor de arriba es la forma más rápida de empezar.
Un fragmento es un evento regular de NIP-01.
repo puede apuntar a un anuncio de repositorio NIP-34 (kind 30617).
El texto de las especificaciones se cita en inglés del repositorio nostr-protocol/nips. Nuestras explicaciones y la interfaz están traducidas. Código fuente en GitHub en el commit 0046368
This NIP defines a new event kind for sharing and storing code snippets. Unlike regular text notes (kind:1), code snippets have specialized metadata like language, extension, and other code-specific attributes that enhance discoverability, syntax highlighting, and improved user experience.
This NIP defines kind:1337 as a code snippet event.
The .content field contains the actual code snippet text.
l - Programming language name (lowercase). Examples: "javascript", "python", "rust"name - Name of the code snippet, commonly a filename. Examples: "hello-world.js", "quick-sort.py"extension - File extension (without the dot). Examples: "js", "py", "rs"description - Brief description of what the code doesruntime - Runtime or environment specification (e.g., "node v18.15.0", "python 3.11")license - License under which the code (along with any related data contained within the event, when available, such as the description) is shared. This MUST be a standard SPDX short identifier (e.g., "MIT", "GPL-3.0-or-later", "Apache-2.0") when available. An additional parameter containing a reference to the actual text of the license MAY be provided. This tag can be repeated, to indicate multi-licensing, allowing recipients to use the code under any license of choosing among the referenced onesdep - Dependency required for the code to run (can be repeated)repo - Reference to a repository where this code originates. This MUST be either a standard URL or, alternatively, the address of a NIP-34 Git repository announcement event in the form "30617:<32-bytes hex a pubkey>:<d tag value>". If a repository announcement is referenced, a recommended relay URL where to find the event should be provided as an additional parameter{
"id": "<32-bytes lowercase hex-encoded SHA-256 of the the serialized event data>",
"pubkey": "<32-bytes lowercase hex-encoded public key of the event creator>",
"created_at": <Unix timestamp in seconds>,
"kind": 1337,
"content": "function helloWorld() {\n console.log('Hello, Nostr!');\n}\n\nhelloWorld();",
"tags": [
["l", "javascript"],
["extension", "js"],
["name", "hello-world.js"],
["description", "A basic JavaScript function that prints 'Hello, Nostr!' to the console"],
["runtime", "node v18.15.0"],
["license", "MIT"],
["repo", "https://github.com/nostr-protocol/nostr"]
],
"sig": "<64-bytes signature of the id>"
}
Clients that support this NIP SHOULD:
Clients MAY provide additional functionality such as: