NWC Relay
Last updated
Last updated
Relay servers route messages between client apps and wallets. NWC requires relay
as an URL of the relay where the wallet service is connected and will be listening for events.
There are four event kinds:
NIP-47 info event
: 13194
NIP-47 request
: 23194
NIP-47 response
: 23195
NIP-47 notification
: 23197 (and 23196: legacy NIP-04 notifications)
The info event should be a replaceable event that is published by the wallet service on the relay to indicate which commands it supports. The content should be a plaintext string with the supported commands, space-separated, eg. pay_invoice
get_balance
.
Both the request and response events SHOULD contain one p
tag, containing the public key of the wallet service if this is a request, and the public key of the user if this is a response. The response event SHOULD contain an e
tag with the id of the request event it is responding to.
The content of requests and responses is encrypted with , and is a JSON-RPCish object with a semi-fixed structure:
Request:
Response:
The result_type
field MUST contain the name of the method that this event is responding to. The error
field MUST contain a message
field with a human readable error message and a code
field with the error code if the command was not successful. If the command was successful, the error
field must be null.
NWC does not specify any requirements on the type of a -compatible relay. However, it makes sense to use a dedicated relay to prevent metadata leaks and improve reliability. Wallets can set up their own relay or leverage existing infrastructure listed .