|
| 1 | +NIP-88 |
| 2 | +====== |
| 3 | + |
| 4 | +Discreet Log Contracts over nostr |
| 5 | +----------------- |
| 6 | + |
| 7 | +`draft` `optional` |
| 8 | + |
| 9 | +This NIP describes a way to use Discreet Log Contracts (DLCs) over Nostr. This comes in four main |
| 10 | +components: `kind:28_888` for sending DLC messages between wallets. `kind:88` for posting DLC offers to the global |
| 11 | +market. `kind:89` and `kind:90` for publishing DLC oracle announcements and attestations. And `kind:91` for a DLC |
| 12 | +"receipt" that can publish the result of a DLC for social interaction. |
| 13 | + |
| 14 | +## DLC Messages |
| 15 | + |
| 16 | +DLCs typically use [BOLT 8](https://github.com/lightning/bolts/blob/master/08-transport.md) for sending messages but |
| 17 | +this has various problems: it requires the ability to accept incoming connections and an always-on node. Nostr provides |
| 18 | +a unique opportunity to use a different transport layer for DLCs. This NIP proposes a new `kind:28_888` message that |
| 19 | +acts like a mailbox for DLC messages. The DLC messages are sent over nostr and available for the user the next time |
| 20 | +they open their wallet. This allows for a more mobile-friendly DLC experience. |
| 21 | + |
| 22 | +### `kind:28_888` |
| 23 | + |
| 24 | +// todo probably don't want an ephemeral event for this, but it's a good starting point |
| 25 | + |
| 26 | +Kind 28_888 is a simple message that contains a [NIP04](04.md) encrypted DLC message and it tagged with the recipient's |
| 27 | +public key with a `p` tag and if it is in reply to another event, that event should be tagged with an `e` tag. |
| 28 | + |
| 29 | +```json |
| 30 | +{ |
| 31 | + "kind": 28888, |
| 32 | + "content": "TJob1dQrf2ndsmdbeGU+05HT5GMnBSx3fx8QdDY/g3NvCa7klfzgaQCmRZuo1d3WQjHDOjzSY1+MgTK5WjewFFumCcOZniWtOMSga9tJk1ky00tLoUUzyLnb1v9x95h/iT/KpkICJyAwUZ+LoJBUzLrK52wNTMt8M5jSLvCkRx8C0BmEwA/00pjOp4eRndy19H4WUUehhjfV2/VV/k4hMAjJ7Bb5Hp9xdmzmCLX9+64+MyeIQQjQAHPj8dkSsRahP7KS3MgMpjaF8nL48Bg5suZMxJayXGVp3BLtgRZx5z5nOk9xyrYk+71e2tnP9IDvSMkiSe76BcMct+m7kGVrRcavDI4n62goNNh25IpghT+a1OjjkpXt9me5wmaL7fxffV1pchdm+A7KJKIUU3kLC7QbUifF22EucRA9xiEyxETusNludBXN24O3llTbOy4vYFsq35BeZl4v1Cse7n2htZicVkItMz3wjzj1q1I1VqbnorNXFgllkRZn4/YXfTG/RMnoK/bDogRapOV+XToZ+IvsN0BqwKSUDx+ydKpci6htDRF2WDRkU+VQMqwM0CoLzy2H6A2cqyMMMD9SLRRzBg==?iv=S3rFeFr1gsYqmQA7bNnNTQ==", |
| 33 | + "tags": [ |
| 34 | + [ |
| 35 | + "p", |
| 36 | + "04c915daefee38317fa734444acee390a8269fe5810b2241e5e6dd343dfbecc9" |
| 37 | + ], |
| 38 | + [ |
| 39 | + "e", |
| 40 | + "9ae37aa68f48645127299e9453eb5d908a0cbb6058ff340d528ed4d37c8994fb" |
| 41 | + ] |
| 42 | + ], |
| 43 | + "pubkey": "97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322", |
| 44 | + "created_at": 1679673265, |
| 45 | + "id": "30efed56a035b2549fcaeec0bf2c1595f9a9b3bb4b1a38abaf8ee9041c4b7d93", |
| 46 | + "sig": "f2cb581a84ed10e4dc84937bd98e27acac71ab057255f6aa8dfa561808c981fe8870f4a03c1e3666784d82a9c802d3704e174371aa13d63e2aeaf24ff5374d9d" |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +## DLC Offers |
| 51 | + |
| 52 | +DLCs are done between two parties and Nostr provides a unique opportunity to create a global market for DLCs. This |
| 53 | +market can be constructed with a simple list of DLC offers that can be filtered by the user's wallet. The user can then |
| 54 | +select an offer and send a message to the offerer to begin the DLC process. `kind:88` is an event that contains a DLC |
| 55 | +offer. |
| 56 | + |
| 57 | +### `kind:88` |
| 58 | + |
| 59 | +```jsonc |
| 60 | +{ |
| 61 | + "kind": 88, |
| 62 | + "content": "base64 contract details", |
| 63 | + "tags": [ |
| 64 | + [ |
| 65 | + "relays", |
| 66 | + "wss://nostr.mutinywallet.com", |
| 67 | + "wss://relay.damus.io" |
| 68 | + ], |
| 69 | + [ |
| 70 | + "expires", // todo this is a good way to do this? |
| 71 | + "1695327657" |
| 72 | + ] |
| 73 | + ], |
| 74 | + "pubkey": "97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322", |
| 75 | + "created_at": 1679673265, |
| 76 | + "id": "30efed56a035b2549fcaeec0bf2c1595f9a9b3bb4b1a38abaf8ee9041c4b7d93", |
| 77 | + "sig": "f2cb581a84ed10e4dc84937bd98e27acac71ab057255f6aa8dfa561808c981fe8870f4a03c1e3666784d82a9c802d3704e174371aa13d63e2aeaf24ff5374d9d" |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +## DLC Oracle Gossip |
| 82 | + |
| 83 | +DLCs require an oracle to attest to the outcome of real world events. This is done by the oracle signing a message |
| 84 | +containing the outcome of the event. Before they attest to the outcome, they must create an announcement where they |
| 85 | +publish the intent to sign the future event. This announcement is then used by the DLC participants to create the |
| 86 | +contract. Here we define two events, `kind:89` and `kind:90` that are used to publish the oracle's announcement and |
| 87 | +attestations respectively. |
| 88 | + |
| 89 | +### `kind:89` |
| 90 | + |
| 91 | +```jsonc |
| 92 | +{ |
| 93 | + "kind": 89, |
| 94 | + "content": "base64 oracle annoucement", |
| 95 | + "tags": [ |
| 96 | + [ |
| 97 | + "relays", // the relays the oracle will publish attestations to |
| 98 | + "wss://nostr.mutinywallet.com", |
| 99 | + "wss://relay.damus.io" |
| 100 | + ], |
| 101 | + ], |
| 102 | + "pubkey": "97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322", |
| 103 | + "created_at": 1679673265, |
| 104 | + "id": "30efed56a035b2549fcaeec0bf2c1595f9a9b3bb4b1a38abaf8ee9041c4b7d93", |
| 105 | + "sig": "f2cb581a84ed10e4dc84937bd98e27acac71ab057255f6aa8dfa561808c981fe8870f4a03c1e3666784d82a9c802d3704e174371aa13d63e2aeaf24ff5374d9d" |
| 106 | +} |
| 107 | +``` |
| 108 | + |
| 109 | +### `kind:90` |
| 110 | + |
| 111 | +```jsonc |
| 112 | +{ |
| 113 | + "kind": 89, |
| 114 | + "content": "base64 oracle attestation", |
| 115 | + "pubkey": "97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322", |
| 116 | + "created_at": 1679673265, |
| 117 | + "id": "30efed56a035b2549fcaeec0bf2c1595f9a9b3bb4b1a38abaf8ee9041c4b7d93", |
| 118 | + "sig": "f2cb581a84ed10e4dc84937bd98e27acac71ab057255f6aa8dfa561808c981fe8870f4a03c1e3666784d82a9c802d3704e174371aa13d63e2aeaf24ff5374d9d" |
| 119 | +} |
| 120 | +``` |
| 121 | + |
| 122 | +## DLC Receipts |
| 123 | + |
| 124 | +DLCs can be fun, social events. This NIP proposes a `kind:91` event that can be used to publish the result of a DLC |
| 125 | +contract. This event can be used to show off the result of a DLC to the user's followers, similar [Zaps](57.md) but for |
| 126 | +DLC bets. |
| 127 | + |
| 128 | +### `kind:91` |
| 129 | + |
| 130 | +todo I still need to think about this one |
0 commit comments