# CLINK Demo Client A minimal web demo built with the [@shocknet/clink-sdk](https://www.npmjs.com/package/@shocknet/clink-sdk). It showcases the three core interactions defined by **CLINK** (Common Lightning Interface for Nostr Keys): 1. **Lightning-address discovery** – map an user@domain NIP-05 identifier to a clink_offer string. 2. **Offers (`noffer`)** – ask a remote node for a fresh BOLT-11 invoice over Nostr. 3. **Debits (`ndebit`)** – authorise a remote node to pay a BOLT-11 invoice from your wallet. Everything flows through Nostr – no HTTP callbacks, WebSockets or Tor-like onion-messages are required. --- ## Running locally ```bash # in the clink-demo directory npm install # first time only npm start # opens http://localhost:8787 ``` Build a static bundle: ```bash npm run build # output in dist/ ``` --- ## How to use ### 1. Address checker • Open the page (it defaults to index.html). • Enter a Lightning Address like bob@example.com. • Click **Check Address**. The demo fetches https://example.com/.well-known/nostr.json?name=bob and reports whether it contains a `clink_offer` entry. ### 2. Generate an invoice from an **Offer** • Still on index.html, paste a `noffer` string (or use the default). • Click **Decode Offer** → **Get Invoice**. The SDK signs and sends a `noffer_request` event with an ephemeral key cached in `localStorage`. Once the provider replies the BOLT-11 is displayed and rendered as a QR code. ### 3. Pay an invoice with a **Debit** • Navigate to debit.html. • Paste an `ndebit` string (generated by a CLINK-capable wallet like **ShockWallet**). • Paste a BOLT-11 to be paid. • Click **Pay Invoice**. The SDK builds an `ndebit_payment_request` event, signs it, and waits for the provider's reply. --- ## Project layout ``` clink-demo │ ├── src/ # TypeScript, HTML & CSS sources │ ├── index.ts # Address checker + Offer flow │ ├── debit.ts # Debit flow │ ├── utils.ts # localStorage-backed client key helper │ └── styles.css ├── dist/ # Compiled output (to verify demo) ├── webpack.config.js # Build pipeline └── tsconfig.json ``` --- ## Contributing PRs and issues welcome. Protocol discussions live in the main [CLINK repository](https://github.com/shocknet/clink). --- ## License MIT ## Links - [CLINK Specification](https://github.com/shocknet/clink) - [CLINK Enabled Node](https://github.com/shocknet/Lightning.Pub) - [CLINK Enabled Wallet](https://shockwallet.app)