|
| 1 | +--- |
| 2 | +cover: ../.gitbook/assets/Fabric bg (1).svg |
| 3 | +coverY: 0 |
| 4 | +layout: |
| 5 | + cover: |
| 6 | + visible: true |
| 7 | + size: full |
| 8 | + title: |
| 9 | + visible: true |
| 10 | + description: |
| 11 | + visible: true |
| 12 | + tableOfContents: |
| 13 | + visible: true |
| 14 | + outline: |
| 15 | + visible: true |
| 16 | + pagination: |
| 17 | + visible: true |
| 18 | +--- |
| 19 | + |
| 20 | +# Fabric DHT |
| 21 | + |
| 22 | +Fabric enables you to sign Nostr events, and DNS records with a Bitcoin sovereign handle (a `space`), or a public key (an `npub`), and publish them to the Fabric peer-to-peer network without adding any bloat to the Bitcoin blockchain! |
| 23 | + |
| 24 | +## Who can use it? |
| 25 | + |
| 26 | +* **Own a Space?** Publish forward records tied to your handle e.g., `@example`. To grab one, see [quick start](quickstart.md) or buy one from a [secondary marketplace](https://spaces.market). |
| 27 | +* **No Space? No Problem!** Use your `npub` to publish Nostr events (like NIP-65 relay lists) instead. |
| 28 | + |
| 29 | +``` |
| 30 | +npm install -g @spacesprotocol/fabric |
| 31 | +``` |
| 32 | + |
| 33 | +and verify installation |
| 34 | + |
| 35 | +``` |
| 36 | +fabric --version |
| 37 | +beam --version |
| 38 | +``` |
| 39 | + |
| 40 | +By default, the `beam` tool will try to load trust anchors from `http://127.0.0.1:7225/root-anchors.json` to verify space handles. If you don't have a spaces [spaces client](https://github.com/spacesprotocol/spaces), you can load the file from an external source that you trust e.g. |
| 41 | + |
| 42 | +``` |
| 43 | +export FABRIC_REMOTE_ANCHORS=https://bitpki.com/root-anchors.json |
| 44 | +``` |
| 45 | + |
| 46 | +Don't trust, verify! Run your own Bitcoin full node and spaces client.\ |
| 47 | + |
| 48 | + |
| 49 | +#### DNS Records |
| 50 | + |
| 51 | +``` |
| 52 | +beam <space> <record-type> |
| 53 | +``` |
| 54 | + |
| 55 | +For example: |
| 56 | + |
| 57 | +``` |
| 58 | +beam @buffrr TXT |
| 59 | +``` |
| 60 | + |
| 61 | +#### Nostr events |
| 62 | + |
| 63 | +``` |
| 64 | +beam <space-or-pubkey> <event-kind> <optional-d-tag> |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +## Publishing records by handle |
| 70 | + |
| 71 | +If you own a space, you can publish forward records resolvable by your handle e.g. `@example` |
| 72 | + |
| 73 | +### Publish DNS records |
| 74 | + |
| 75 | +{% hint style="info" %} |
| 76 | +Spaces use the DNS class code 2 (CLASS2) to further distinguish them from regular domains in the IN class. |
| 77 | +{% endhint %} |
| 78 | + |
| 79 | +1. **Create a zone file**: |
| 80 | + |
| 81 | +Add your records to a file and save it e.g. `myexample.zone` |
| 82 | + |
| 83 | +``` |
| 84 | +@example. 3600 CLASS2 TXT "Hello Fabric" |
| 85 | +@example. 3600 CLASS2 A 127.0.0.1 |
| 86 | +``` |
| 87 | + |
| 88 | +Remember to replace `@example`with your space name, and remember to put the `.`at the end. It's not a typo in DNS zone files! |
| 89 | + |
| 90 | +2. **Sign the file** |
| 91 | + |
| 92 | +``` |
| 93 | +space-cli signzone myexample.zone > signed.event.json |
| 94 | +``` |
| 95 | + |
| 96 | +The wallet will turn it into a signed Nostr event and bundles proof information to make it ready for publishing to Fabric. |
| 97 | + |
| 98 | +3. **Publish it with** `beam` |
| 99 | + |
| 100 | +``` |
| 101 | +beam publish signed.event.json |
| 102 | +``` |
| 103 | + |
| 104 | +### Publish Nostr Events |
| 105 | + |
| 106 | +To sign a forward event (lookup by a space handle), you could do the following: |
| 107 | + |
| 108 | +Note: there's no standard yet for using kind 0 for forward lookups yet but it's here as an example. |
| 109 | + |
| 110 | +``` |
| 111 | +{ |
| 112 | + "kind": 0, |
| 113 | + "created_at": 1679673265, |
| 114 | + "content": "{\"name\": \"Alice\", \"about\": \"A Nostr enthusiast\", \"picture\": \"https://example.com/avatar.jpg\"}", |
| 115 | + "tags": [] |
| 116 | +} |
| 117 | +``` |
| 118 | + |
| 119 | +``` |
| 120 | +space-cli signevent @example event.json --anchor > event.signed.json |
| 121 | +``` |
| 122 | + |
| 123 | +For lookups by handle, you should use the `--anchor`option to include trust path information and append the `space`tag to the event. |
| 124 | + |
| 125 | +``` |
| 126 | +beam publish event.signed.json |
| 127 | +``` |
| 128 | + |
| 129 | +## Publishing records by pubkey |
| 130 | + |
| 131 | +If you have an `npub`, you could publish events on Fabric. This is still experimental and no Nostr client supports lookups through Fabric yet. Here's an example publishing a NIP-65 relay list:  |
| 132 | + |
| 133 | +``` |
| 134 | +{ |
| 135 | + "kind": 10002, |
| 136 | + "created_at": 1679673265, |
| 137 | + "pubkey": "97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322", |
| 138 | + "tags": [ |
| 139 | + ["r", "wss://alicerelay.example.com"], |
| 140 | + ["r", "wss://brando-relay.com"], |
| 141 | + ["r", "wss://expensive-relay.example2.com", "write"], |
| 142 | + ["r", "wss://nostr-relay.example.com", "read"] |
| 143 | + ], |
| 144 | + "content": "", |
| 145 | + "sig": "<signature>" |
| 146 | +} |
| 147 | +``` |
| 148 | + |
| 149 | +Then publish it  |
| 150 | + |
| 151 | +``` |
| 152 | +beam publish event.signed.json |
| 153 | +``` |
| 154 | + |
| 155 | + |
| 156 | + |
0 commit comments