create-dig-app 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +217 -0
  3. package/bin/create-dig-app.js +17 -0
  4. package/lib/cli.js +438 -0
  5. package/lib/index.js +235 -0
  6. package/lib/nft-cli.js +265 -0
  7. package/lib/nft-metadata.js +515 -0
  8. package/lib/substitute.js +47 -0
  9. package/lib/templates.js +185 -0
  10. package/package.json +51 -0
  11. package/templates/dapp-window-chia/README.md +63 -0
  12. package/templates/dapp-window-chia/_env.example +7 -0
  13. package/templates/dapp-window-chia/_gitignore +10 -0
  14. package/templates/dapp-window-chia/dig.toml +17 -0
  15. package/templates/dapp-window-chia/index.html +12 -0
  16. package/templates/dapp-window-chia/package.json +24 -0
  17. package/templates/dapp-window-chia/src/App.jsx +91 -0
  18. package/templates/dapp-window-chia/src/main.jsx +10 -0
  19. package/templates/dapp-window-chia/src/styles.css +71 -0
  20. package/templates/dapp-window-chia/src/wallet.js +47 -0
  21. package/templates/dapp-window-chia/vite.config.js +14 -0
  22. package/templates/next-static/README.md +41 -0
  23. package/templates/next-static/_gitignore +6 -0
  24. package/templates/next-static/app/globals.css +49 -0
  25. package/templates/next-static/app/layout.jsx +14 -0
  26. package/templates/next-static/app/page.jsx +18 -0
  27. package/templates/next-static/dig.toml +17 -0
  28. package/templates/next-static/next.config.mjs +11 -0
  29. package/templates/next-static/package.json +16 -0
  30. package/templates/nft-collection/README.md +119 -0
  31. package/templates/nft-collection/_env.example +5 -0
  32. package/templates/nft-collection/_gitignore +9 -0
  33. package/templates/nft-collection/assets/banner.svg +11 -0
  34. package/templates/nft-collection/assets/icon.svg +10 -0
  35. package/templates/nft-collection/collection.json +14 -0
  36. package/templates/nft-collection/dig.toml +23 -0
  37. package/templates/nft-collection/images/sample-1.svg +5 -0
  38. package/templates/nft-collection/images/sample-2.svg +5 -0
  39. package/templates/nft-collection/licenses/.gitkeep +1 -0
  40. package/templates/nft-collection/metadata/.gitkeep +2 -0
  41. package/templates/nft-collection/package.json +18 -0
  42. package/templates/nft-collection/scripts/dig-nft.mjs +479 -0
  43. package/templates/nft-collection/src/mint.js +72 -0
  44. package/templates/nft-collection/src/styles.css +64 -0
  45. package/templates/nft-collection/traits.csv +3 -0
  46. package/templates/nft-drop/README.md +71 -0
  47. package/templates/nft-drop/_env.example +7 -0
  48. package/templates/nft-drop/_gitignore +10 -0
  49. package/templates/nft-drop/dig.toml +18 -0
  50. package/templates/nft-drop/index.html +12 -0
  51. package/templates/nft-drop/package.json +24 -0
  52. package/templates/nft-drop/src/App.jsx +91 -0
  53. package/templates/nft-drop/src/main.jsx +10 -0
  54. package/templates/nft-drop/src/mint.js +72 -0
  55. package/templates/nft-drop/src/styles.css +70 -0
  56. package/templates/nft-drop/vite.config.js +13 -0
  57. package/templates/static-site/README.md +41 -0
  58. package/templates/static-site/_gitignore +5 -0
  59. package/templates/static-site/dig.toml +19 -0
  60. package/templates/static-site/package.json +10 -0
  61. package/templates/static-site/scripts/build.mjs +14 -0
  62. package/templates/static-site/src/index.html +20 -0
  63. package/templates/static-site/src/styles.css +49 -0
  64. package/templates/vite-react/README.md +42 -0
  65. package/templates/vite-react/_gitignore +5 -0
  66. package/templates/vite-react/dig.toml +17 -0
  67. package/templates/vite-react/index.html +12 -0
  68. package/templates/vite-react/package.json +20 -0
  69. package/templates/vite-react/src/App.jsx +18 -0
  70. package/templates/vite-react/src/main.jsx +10 -0
  71. package/templates/vite-react/src/styles.css +49 -0
  72. package/templates/vite-react/vite.config.js +9 -0
  73. package/templates-ts/dapp-window-chia/README.md +67 -0
  74. package/templates-ts/dapp-window-chia/_env.example +7 -0
  75. package/templates-ts/dapp-window-chia/_gitignore +10 -0
  76. package/templates-ts/dapp-window-chia/dig.toml +17 -0
  77. package/templates-ts/dapp-window-chia/index.html +12 -0
  78. package/templates-ts/dapp-window-chia/package.json +28 -0
  79. package/templates-ts/dapp-window-chia/src/App.tsx +93 -0
  80. package/templates-ts/dapp-window-chia/src/main.tsx +13 -0
  81. package/templates-ts/dapp-window-chia/src/styles.css +71 -0
  82. package/templates-ts/dapp-window-chia/src/vite-env.d.ts +11 -0
  83. package/templates-ts/dapp-window-chia/src/wallet.ts +62 -0
  84. package/templates-ts/dapp-window-chia/tsconfig.json +20 -0
  85. package/templates-ts/dapp-window-chia/vite.config.ts +14 -0
  86. package/templates-ts/next-static/README.md +43 -0
  87. package/templates-ts/next-static/_gitignore +7 -0
  88. package/templates-ts/next-static/app/globals.css +49 -0
  89. package/templates-ts/next-static/app/layout.tsx +16 -0
  90. package/templates-ts/next-static/app/page.tsx +18 -0
  91. package/templates-ts/next-static/dig.toml +17 -0
  92. package/templates-ts/next-static/next-env.d.ts +5 -0
  93. package/templates-ts/next-static/next.config.mjs +11 -0
  94. package/templates-ts/next-static/package.json +23 -0
  95. package/templates-ts/next-static/tsconfig.json +21 -0
  96. package/templates-ts/nft-drop/README.md +74 -0
  97. package/templates-ts/nft-drop/_env.example +7 -0
  98. package/templates-ts/nft-drop/_gitignore +10 -0
  99. package/templates-ts/nft-drop/dig.toml +18 -0
  100. package/templates-ts/nft-drop/index.html +12 -0
  101. package/templates-ts/nft-drop/package.json +28 -0
  102. package/templates-ts/nft-drop/src/App.tsx +93 -0
  103. package/templates-ts/nft-drop/src/main.tsx +13 -0
  104. package/templates-ts/nft-drop/src/mint.ts +86 -0
  105. package/templates-ts/nft-drop/src/styles.css +70 -0
  106. package/templates-ts/nft-drop/src/vite-env.d.ts +11 -0
  107. package/templates-ts/nft-drop/tsconfig.json +20 -0
  108. package/templates-ts/nft-drop/vite.config.ts +13 -0
  109. package/templates-ts/vite-react/README.md +44 -0
  110. package/templates-ts/vite-react/_gitignore +5 -0
  111. package/templates-ts/vite-react/dig.toml +17 -0
  112. package/templates-ts/vite-react/index.html +12 -0
  113. package/templates-ts/vite-react/package.json +24 -0
  114. package/templates-ts/vite-react/src/App.tsx +18 -0
  115. package/templates-ts/vite-react/src/main.tsx +13 -0
  116. package/templates-ts/vite-react/src/styles.css +49 -0
  117. package/templates-ts/vite-react/src/vite-env.d.ts +1 -0
  118. package/templates-ts/vite-react/tsconfig.json +20 -0
  119. package/templates-ts/vite-react/vite.config.ts +9 -0
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "__APP_NAME__",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "description": "__DISPLAY_NAME__ — a React app on the DIG Network, built with Vite.",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "build": "vite build",
10
+ "preview": "vite preview"
11
+ },
12
+ "dependencies": {
13
+ "react": "^18.3.1",
14
+ "react-dom": "^18.3.1"
15
+ },
16
+ "devDependencies": {
17
+ "@vitejs/plugin-react": "^4.3.4",
18
+ "vite": "^5.4.11"
19
+ }
20
+ }
@@ -0,0 +1,18 @@
1
+ export default function App() {
2
+ return (
3
+ <main className="wrap">
4
+ <h1>__DISPLAY_NAME__</h1>
5
+ <p>
6
+ A React app on the <strong>DIG Network</strong> — served from a network no host can read,
7
+ change, or take down.
8
+ </p>
9
+ <p className="muted">
10
+ Build and preview for <strong>free</strong>. You only spend $DIG when you publish.
11
+ </p>
12
+ <pre>
13
+ <code>{`digstore dev # preview, free
14
+ digstore deploy # publish a capsule ($DIG)`}</code>
15
+ </pre>
16
+ </main>
17
+ );
18
+ }
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import App from "./App.jsx";
4
+ import "./styles.css";
5
+
6
+ createRoot(document.getElementById("root")).render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>,
10
+ );
@@ -0,0 +1,49 @@
1
+ :root {
2
+ color-scheme: light dark;
3
+ --fg: #0f172a;
4
+ --muted: #64748b;
5
+ --bg: #f8fafc;
6
+ --error: #dc2626;
7
+
8
+ /* DIG brand accent — violet -> magenta (SYSTEM.md visual theme; matches dig.net/hub/status). */
9
+ --dig-violet: #5800D6;
10
+ --dig-magenta: #FF00DE;
11
+ --accent: var(--dig-violet);
12
+ --grad-brand: linear-gradient(115deg, #5800D6 0%, #FF00DE 100%);
13
+
14
+ /* DIG brand fonts — named first, system stack as the offline/no-fetch fallback so a scaffolded
15
+ capsule never depends on an external font host (keeps the site self-contained + offline-safe). */
16
+ --dig-font: "Space Grotesk", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
17
+ --dig-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
18
+ }
19
+ @media (prefers-color-scheme: dark) {
20
+ :root { --fg: #e2e8f0; --muted: #94a3b8; --bg: #0b1120; }
21
+ }
22
+ * { box-sizing: border-box; }
23
+ body {
24
+ margin: 0;
25
+ min-height: 100vh;
26
+ display: grid;
27
+ place-items: center;
28
+ font: 16px/1.6 var(--dig-font);
29
+ color: var(--fg);
30
+ background: var(--bg);
31
+ }
32
+ .wrap { max-width: 40rem; padding: 2rem; }
33
+ h1 {
34
+ font-size: 2.25rem;
35
+ margin: 0 0 0.5rem;
36
+ font-weight: 700;
37
+ background: var(--grad-brand);
38
+ -webkit-background-clip: text;
39
+ background-clip: text;
40
+ color: transparent;
41
+ }
42
+ .muted { color: var(--muted); }
43
+ pre {
44
+ font-family: var(--dig-mono);
45
+ background: rgba(127, 127, 127, 0.12);
46
+ padding: 1rem;
47
+ border-radius: 0.5rem;
48
+ overflow-x: auto;
49
+ }
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from "vite";
2
+ import react from "@vitejs/plugin-react";
3
+
4
+ // Relative base so the built site works from any path on a *.on.dig.net subdomain (and chia://).
5
+ export default defineConfig({
6
+ base: "./",
7
+ plugins: [react()],
8
+ build: { outDir: "dist" },
9
+ });
@@ -0,0 +1,67 @@
1
+ # __DISPLAY_NAME__
2
+
3
+ A wallet-wired dapp for the **DIG Network**, in **TypeScript** — connects the injected Chia wallet
4
+ (`window.chia`) via `@dignetwork/dig-sdk`'s `ChiaProvider`, with a WalletConnect → Sage fallback.
5
+ The SDK ships its own types, so `ChiaProvider`/`ConnectOptions` are fully typed (no `@types/*`
6
+ package needed for the SDK).
7
+
8
+ Scaffolded with `npm create dig-app` (template: `dapp-window-chia`, language: TypeScript).
9
+
10
+ ## Free until publish
11
+
12
+ Scaffolding, building, previewing, and connecting a wallet cost **nothing**. There is **no mint, no
13
+ chain, and no spend** when you create or run this project — you only spend **$DIG** the
14
+ moment you publish a capsule with `digstore deploy`. *Iterate for free, publish when it's ready.*
15
+
16
+ ## How the wallet is wired
17
+
18
+ `src/wallet.ts` calls `ChiaProvider.connect({ mode: "auto" })`, which **prefers the injected DIG
19
+ Browser wallet** (`window.chia`) and **falls back to WalletConnect → Sage**. In `digstore dev` an
20
+ injected dev-shim `window.chia` is present, so the connect/read path runs locally — but the shim
21
+ never fakes a signature; open the dapp in the **DIG Browser** (or connect a real wallet) to sign for
22
+ real. See <https://github.com/DIG-Network/dig-sdk> for the full API.
23
+
24
+ ## Connect to Sage in a normal browser (WalletConnect)
25
+
26
+ Outside the DIG Browser there is no injected `window.chia`, so the dapp connects to **Sage** (the
27
+ main Chia wallet) over **WalletConnect**. This needs a free **project id**:
28
+
29
+ 1. Get one at **<https://cloud.reown.com>** (Reown, formerly WalletConnect Cloud).
30
+ 2. Copy `.env.example` to `.env` and set it:
31
+
32
+ ```sh
33
+ cp .env.example .env
34
+ # .env
35
+ VITE_WALLETCONNECT_PROJECT_ID=your_project_id_here
36
+ ```
37
+
38
+ `@walletconnect/sign-client` is already a dependency, so once `VITE_WALLETCONNECT_PROJECT_ID` is set,
39
+ **Connect wallet** shows a pairing link/QR to approve in Sage and then displays your connected
40
+ address. Leave it blank to support only the injected DIG Browser wallet. (Never commit `.env` — only
41
+ the placeholder `.env.example` is tracked. The env is typed in `src/vite-env.d.ts`.)
42
+
43
+ ## Develop
44
+
45
+ ```sh
46
+ npm install
47
+ npm run dev # Vite dev server at http://localhost:5173
48
+ npm run typecheck # tsc --noEmit (type-check without building)
49
+ npm run build # tsc --noEmit && vite build -> dist/ (your content root)
50
+ digstore dev # preview on the real chia:// read path + dev wallet shim — FREE, no spend
51
+ ```
52
+
53
+ ## Publish (this is the only step that spends $DIG)
54
+
55
+ ```sh
56
+ digstore deploy # build + publish a capsule ($DIG + a small XCH fee)
57
+ ```
58
+
59
+ ## Deploy from CI
60
+
61
+ Wire up push-to-deploy with the GitHub Action:
62
+ <https://docs.dig.net/docs/digstore/cli/deploy-from-github-actions>.
63
+
64
+ ## Config
65
+
66
+ `dig.toml` is the project manifest digstore reads (output dir, build command, default remote).
67
+ `tsconfig.json` configures TypeScript (strict mode, `bundler` resolution for Vite).
@@ -0,0 +1,7 @@
1
+ # WalletConnect Cloud / Reown project id — enables the WalletConnect → Sage fallback so this dapp
2
+ # connects to Sage (the main Chia wallet) in a normal browser, not just the DIG Browser.
3
+ #
4
+ # Get a free project id at https://cloud.reown.com (formerly WalletConnect Cloud). Copy this file to
5
+ # `.env` (or `.env.local`) and paste your id. Leave it blank to support ONLY the injected DIG Browser
6
+ # wallet (window.chia) — the app still builds and runs; the WC fallback is just disabled.
7
+ VITE_WALLETCONNECT_PROJECT_ID=
@@ -0,0 +1,10 @@
1
+ node_modules/
2
+ dist/
3
+ .dig/
4
+ .DS_Store
5
+ *.log
6
+
7
+ # Local env (e.g. your WalletConnect projectId) — never commit secrets; .env.example is committed.
8
+ .env
9
+ .env.local
10
+ .env.*.local
@@ -0,0 +1,17 @@
1
+ # dig.toml — the project manifest digstore (and the DIG SDK adapters) read.
2
+ # Keys are kebab-case (snake_case also accepted). See:
3
+ # https://docs.dig.net/docs/digstore/cli/deploy-from-github-actions
4
+ #
5
+ # Everything here is LOCAL config. Scaffolding, building, and `digstore dev` cost nothing —
6
+ # you only spend $DIG when you run `digstore deploy` to publish a capsule.
7
+
8
+ # Vite emits the production build to dist/ — the content root digstore publishes.
9
+ output-dir = "__OUTPUT_DIR__"
10
+
11
+ # The command digstore runs to build before publishing (used by `digstore deploy` / CI).
12
+ build-command = "__BUILD_COMMAND__"
13
+
14
+ # Default remote a `digstore deploy` pushes to (resolves to your store after your first publish).
15
+ remote = "origin"
16
+
17
+ # network = "mainnet"
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>__DISPLAY_NAME__</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "__APP_NAME__",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "description": "__DISPLAY_NAME__ — a wallet-wired dapp on the DIG Network (TypeScript; window.chia via ChiaProvider).",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "build": "tsc --noEmit && vite build",
10
+ "preview": "vite preview",
11
+ "typecheck": "tsc --noEmit"
12
+ },
13
+ "dependencies": {
14
+ "@dignetwork/dig-sdk": "__SDK_VERSION__",
15
+ "@walletconnect/sign-client": "^2.11.0",
16
+ "react": "^18.3.1",
17
+ "react-dom": "^18.3.1"
18
+ },
19
+ "devDependencies": {
20
+ "@types/react": "^18.3.12",
21
+ "@types/react-dom": "^18.3.1",
22
+ "@vitejs/plugin-react": "^4.3.4",
23
+ "typescript": "^5.6.3",
24
+ "vite": "^5.4.11",
25
+ "vite-plugin-top-level-await": "^1.4.4",
26
+ "vite-plugin-wasm": "^3.3.0"
27
+ }
28
+ }
@@ -0,0 +1,93 @@
1
+ import { useState } from "react";
2
+ import type { ChiaProvider } from "@dignetwork/dig-sdk";
3
+ import { connectWallet } from "./wallet.ts";
4
+
5
+ export default function App() {
6
+ const [provider, setProvider] = useState<ChiaProvider | null>(null);
7
+ const [address, setAddress] = useState<string>("");
8
+ const [error, setError] = useState<string>("");
9
+ const [busy, setBusy] = useState<boolean>(false);
10
+ // The WalletConnect pairing URI (only set during the WC → Sage fallback) — render it as a
11
+ // copy-link / QR / deep link so the user can approve in Sage.
12
+ const [wcUri, setWcUri] = useState<string>("");
13
+
14
+ async function onConnect() {
15
+ setError("");
16
+ setWcUri("");
17
+ setBusy(true);
18
+ try {
19
+ // Injected window.chia when present (DIG Browser / extension); otherwise WalletConnect → Sage.
20
+ // `onUri` fires only on the WC path, with the pairing URI to show.
21
+ const p = await connectWallet({ onUri: (uri) => setWcUri(uri) });
22
+ setProvider(p);
23
+ setAddress((await p.getAddress()) ?? "");
24
+ } catch (e) {
25
+ setError(e instanceof Error ? e.message : String(e));
26
+ } finally {
27
+ setBusy(false);
28
+ setWcUri(""); // pairing complete (or failed) — drop the URI
29
+ }
30
+ }
31
+
32
+ async function onSign() {
33
+ if (!provider) return;
34
+ setError("");
35
+ try {
36
+ // The dev-shim wallet (in `digstore dev`) does NOT sign — open in the DIG Browser or connect a
37
+ // real wallet to produce a real signature.
38
+ const { signature } = await provider.signMessage("Login to __DISPLAY_NAME__");
39
+ alert("Signature: " + (signature ?? "").slice(0, 24) + "…");
40
+ } catch (e) {
41
+ setError(e instanceof Error ? e.message : String(e));
42
+ }
43
+ }
44
+
45
+ return (
46
+ <main className="wrap">
47
+ <h1>__DISPLAY_NAME__</h1>
48
+ <p>
49
+ A wallet-wired dapp on the <strong>DIG Network</strong>. Your wallet is your account — no
50
+ email, no password.
51
+ </p>
52
+ <p className="muted">
53
+ Connecting and previewing are <strong>free</strong>. There is no mint, no chain, and no spend
54
+ here — you only spend $DIG when you publish with <code>digstore deploy</code>.
55
+ </p>
56
+
57
+ {address ? (
58
+ <div className="card">
59
+ <div className="row">
60
+ <span className="muted">Connected via</span>
61
+ <strong>{provider?.backend}</strong>
62
+ </div>
63
+ <div className="row">
64
+ <span className="muted">Address</span>
65
+ <code>{address}</code>
66
+ </div>
67
+ <button onClick={onSign}>Sign a login message</button>
68
+ </div>
69
+ ) : (
70
+ <button onClick={onConnect} disabled={busy}>
71
+ {busy ? "Connecting…" : "Connect wallet"}
72
+ </button>
73
+ )}
74
+
75
+ {wcUri && (
76
+ <div className="card">
77
+ <p className="muted">
78
+ Scan or open this in <strong>Sage</strong> to connect (WalletConnect):
79
+ </p>
80
+ <code>{wcUri}</code>
81
+ <button onClick={() => navigator.clipboard?.writeText(wcUri)}>Copy pairing link</button>
82
+ </div>
83
+ )}
84
+
85
+ {error && <p className="error">{error}</p>}
86
+
87
+ <pre>
88
+ <code>{`digstore dev # preview + dev wallet shim, free
89
+ digstore deploy # publish a capsule ($DIG)`}</code>
90
+ </pre>
91
+ </main>
92
+ );
93
+ }
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import App from "./App.tsx";
4
+ import "./styles.css";
5
+
6
+ const rootEl = document.getElementById("root");
7
+ if (!rootEl) throw new Error("Root element #root not found");
8
+
9
+ createRoot(rootEl).render(
10
+ <React.StrictMode>
11
+ <App />
12
+ </React.StrictMode>,
13
+ );
@@ -0,0 +1,71 @@
1
+ :root {
2
+ color-scheme: light dark;
3
+ --fg: #0f172a;
4
+ --muted: #64748b;
5
+ --bg: #f8fafc;
6
+ --error: #dc2626;
7
+
8
+ /* DIG brand accent — violet -> magenta (SYSTEM.md visual theme; matches dig.net/hub/status). */
9
+ --dig-violet: #5800D6;
10
+ --dig-magenta: #FF00DE;
11
+ --accent: var(--dig-violet);
12
+ --grad-brand: linear-gradient(115deg, #5800D6 0%, #FF00DE 100%);
13
+
14
+ /* DIG brand fonts — named first, system stack as the offline/no-fetch fallback so a scaffolded
15
+ capsule never depends on an external font host (keeps the site self-contained + offline-safe). */
16
+ --dig-font: "Space Grotesk", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
17
+ --dig-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
18
+ }
19
+ @media (prefers-color-scheme: dark) {
20
+ :root { --fg: #e2e8f0; --muted: #94a3b8; --bg: #0b1120; }
21
+ }
22
+ * { box-sizing: border-box; }
23
+ body {
24
+ margin: 0;
25
+ min-height: 100vh;
26
+ display: grid;
27
+ place-items: center;
28
+ font: 16px/1.6 var(--dig-font);
29
+ color: var(--fg);
30
+ background: var(--bg);
31
+ }
32
+ .wrap { max-width: 42rem; padding: 2rem; }
33
+ h1 {
34
+ font-size: 2.25rem;
35
+ margin: 0 0 0.5rem;
36
+ font-weight: 700;
37
+ background: var(--grad-brand);
38
+ -webkit-background-clip: text;
39
+ background-clip: text;
40
+ color: transparent;
41
+ }
42
+ .muted { color: var(--muted); }
43
+ .error { color: var(--error); }
44
+ button {
45
+ font: inherit;
46
+ padding: 0.6rem 1.1rem;
47
+ border: 0;
48
+ border-radius: 0.5rem;
49
+ background: var(--grad-brand);
50
+ color: white;
51
+ cursor: pointer;
52
+ }
53
+ button:disabled { opacity: 0.6; cursor: default; }
54
+ .card {
55
+ margin: 1rem 0;
56
+ padding: 1rem;
57
+ border-radius: 0.75rem;
58
+ background: rgba(127, 127, 127, 0.12);
59
+ display: grid;
60
+ gap: 0.5rem;
61
+ }
62
+ .row { display: flex; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; }
63
+ code { font-family: var(--dig-mono); word-break: break-all; }
64
+ pre {
65
+ font-family: var(--dig-mono);
66
+ margin-top: 1.5rem;
67
+ background: rgba(127, 127, 127, 0.12);
68
+ padding: 1rem;
69
+ border-radius: 0.5rem;
70
+ overflow-x: auto;
71
+ }
@@ -0,0 +1,11 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ // Type the WalletConnect projectId env so `import.meta.env.VITE_WALLETCONNECT_PROJECT_ID`
4
+ // typechecks. Set its value in `.env` / `.env.local` (see .env.example).
5
+ interface ImportMetaEnv {
6
+ readonly VITE_WALLETCONNECT_PROJECT_ID?: string;
7
+ }
8
+
9
+ interface ImportMeta {
10
+ readonly env: ImportMetaEnv;
11
+ }
@@ -0,0 +1,62 @@
1
+ // Wallet wiring via @dignetwork/dig-sdk (typed).
2
+ //
3
+ // ChiaProvider gives this dapp a Chia wallet for free: it PREFERS the injected DIG Browser wallet
4
+ // (window.chia) and falls back to WalletConnect → Sage (the main Chia wallet) so the dapp connects
5
+ // in a normal browser too. In `digstore dev` an injected dev-shim window.chia is present, so the
6
+ // connect/read path runs end-to-end locally (read methods only — the shim never fakes a signature).
7
+ // See https://github.com/DIG-Network/dig-sdk for the full API.
8
+ //
9
+ // @dignetwork/dig-sdk ships its own .d.ts types — ChiaProvider, ConnectOptions and
10
+ // WalletConnectOptions (the options the SDK's WalletConnectTransport consumes) are fully typed, so
11
+ // no `@types/*` package is needed for the SDK.
12
+
13
+ import {
14
+ ChiaProvider,
15
+ type ConnectOptions,
16
+ type WalletConnectOptions,
17
+ } from "@dignetwork/dig-sdk";
18
+
19
+ // WalletConnect Cloud / Reown project id, read from the build-time env (see .env.example) and typed
20
+ // via src/vite-env.d.ts. When set, it enables the WalletConnect → Sage fallback for browsers without
21
+ // the injected DIG wallet. Get a free project id at https://cloud.reown.com (formerly WalletConnect
22
+ // Cloud).
23
+ const WALLETCONNECT_PROJECT_ID = import.meta.env.VITE_WALLETCONNECT_PROJECT_ID ?? "";
24
+
25
+ /** Hooks for the connect flow (e.g. render the WalletConnect pairing URI as a QR / copy-link). */
26
+ export interface ConnectHooks {
27
+ onUri?: (uri: string) => void;
28
+ }
29
+
30
+ /**
31
+ * Connect a wallet. `mode: "auto"` prefers the injected DIG Browser wallet (window.chia) and falls
32
+ * back to WalletConnect → Sage when a project id is configured. The SDK drives its
33
+ * `WalletConnectTransport` under the hood (CHIP-0002 over the relay) — we never hand-roll WC.
34
+ */
35
+ export async function connectWallet(hooks: ConnectHooks = {}): Promise<ChiaProvider> {
36
+ // The typed WalletConnect options the SDK's WalletConnectTransport consumes (projectId + metadata
37
+ // + the pairing-URI hook + the Chia chain). Only built when a project id is configured.
38
+ const walletConnect: WalletConnectOptions | undefined = WALLETCONNECT_PROJECT_ID
39
+ ? {
40
+ projectId: WALLETCONNECT_PROJECT_ID,
41
+ metadata: {
42
+ name: "__DISPLAY_NAME__",
43
+ description: "Built with create-dig-app + @dignetwork/dig-sdk",
44
+ url: typeof window !== "undefined" ? window.location.origin : "https://example.on.dig.net",
45
+ icons: [],
46
+ },
47
+ onUri: hooks.onUri, // render this URI as a QR / copy-link for the Sage fallback
48
+ }
49
+ : undefined;
50
+
51
+ const options: ConnectOptions = {
52
+ mode: "auto", // prefer injected window.chia; fall back to WalletConnect → Sage if configured
53
+ chain: "chia:mainnet", // CAIP-2 chain the SDK expects (Chia mainnet)
54
+ walletConnect,
55
+ };
56
+ return ChiaProvider.connect(options);
57
+ }
58
+
59
+ /** True when the WalletConnect → Sage fallback is configured (a project id is set). */
60
+ export function isWalletConnectConfigured(): boolean {
61
+ return Boolean(WALLETCONNECT_PROJECT_ID);
62
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
13
+ "jsx": "react-jsx",
14
+ "strict": true,
15
+ "noUnusedLocals": true,
16
+ "noUnusedParameters": true,
17
+ "noFallthroughCasesInSwitch": true
18
+ },
19
+ "include": ["src", "vite.config.ts"]
20
+ }
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from "vite";
2
+ import react from "@vitejs/plugin-react";
3
+ import wasm from "vite-plugin-wasm";
4
+ import topLevelAwait from "vite-plugin-top-level-await";
5
+
6
+ // The SDK transitively loads the CHIP-0035 spend builder (@dignetwork/dig-sdk →
7
+ // chip35-dl-coin-wasm), a WebAssembly module with top-level await, so we enable the wasm +
8
+ // top-level-await plugins. Relative base so the built dapp works from any path on a
9
+ // *.on.dig.net subdomain (and chia://).
10
+ export default defineConfig({
11
+ base: "./",
12
+ plugins: [react(), wasm(), topLevelAwait()],
13
+ build: { outDir: "dist" },
14
+ });
@@ -0,0 +1,43 @@
1
+ # __DISPLAY_NAME__
2
+
3
+ A Next.js + **TypeScript** static-export site for the **DIG Network** — deployed to a network no
4
+ host can read, change, or take down.
5
+
6
+ Scaffolded with `npm create dig-app` (template: `next-static`, language: TypeScript).
7
+
8
+ > This template uses `output: 'export'` (`next.config.mjs`). A DIG capsule is a **blind static
9
+ > host** — there is no Next.js server at runtime, so use static-export-compatible features only.
10
+
11
+ ## Free until publish
12
+
13
+ Scaffolding, building, and previewing cost **nothing**. There is **no mint, no chain, and no spend**
14
+ when you create or run this project — you only spend **$DIG** the moment you publish a
15
+ capsule with `digstore deploy`. *Iterate for free, publish when it's ready.*
16
+
17
+ ## Develop
18
+
19
+ ```sh
20
+ npm install
21
+ npm run dev # Next dev server at http://localhost:3000
22
+ npm run typecheck # tsc --noEmit (type-check without building)
23
+ npm run build # static export -> out/ (your content root; type-checked by Next)
24
+ digstore dev # preview on the real chia:// read path — FREE, no chain, no spend
25
+ ```
26
+
27
+ ## Publish (this is the only step that spends $DIG)
28
+
29
+ ```sh
30
+ digstore deploy # build + publish a capsule ($DIG + a small XCH fee)
31
+ ```
32
+
33
+ Your site goes live at its `*.on.dig.net` address. Re-run `digstore deploy` to ship an update.
34
+
35
+ ## Deploy from CI
36
+
37
+ Wire up push-to-deploy with the GitHub Action:
38
+ <https://docs.dig.net/docs/digstore/cli/deploy-from-github-actions>.
39
+
40
+ ## Config
41
+
42
+ `dig.toml` is the project manifest digstore reads (output dir, build command, default remote).
43
+ `tsconfig.json` configures TypeScript; Next type-checks your code as part of `next build`.
@@ -0,0 +1,7 @@
1
+ node_modules/
2
+ .next/
3
+ out/
4
+ .dig/
5
+ .DS_Store
6
+ *.log
7
+ *.tsbuildinfo
@@ -0,0 +1,49 @@
1
+ :root {
2
+ color-scheme: light dark;
3
+ --fg: #0f172a;
4
+ --muted: #64748b;
5
+ --bg: #f8fafc;
6
+ --error: #dc2626;
7
+
8
+ /* DIG brand accent — violet -> magenta (SYSTEM.md visual theme; matches dig.net/hub/status). */
9
+ --dig-violet: #5800D6;
10
+ --dig-magenta: #FF00DE;
11
+ --accent: var(--dig-violet);
12
+ --grad-brand: linear-gradient(115deg, #5800D6 0%, #FF00DE 100%);
13
+
14
+ /* DIG brand fonts — named first, system stack as the offline/no-fetch fallback so a scaffolded
15
+ capsule never depends on an external font host (keeps the site self-contained + offline-safe). */
16
+ --dig-font: "Space Grotesk", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
17
+ --dig-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
18
+ }
19
+ @media (prefers-color-scheme: dark) {
20
+ :root { --fg: #e2e8f0; --muted: #94a3b8; --bg: #0b1120; }
21
+ }
22
+ * { box-sizing: border-box; }
23
+ body {
24
+ margin: 0;
25
+ min-height: 100vh;
26
+ display: grid;
27
+ place-items: center;
28
+ font: 16px/1.6 var(--dig-font);
29
+ color: var(--fg);
30
+ background: var(--bg);
31
+ }
32
+ .wrap { max-width: 40rem; padding: 2rem; }
33
+ h1 {
34
+ font-size: 2.25rem;
35
+ margin: 0 0 0.5rem;
36
+ font-weight: 700;
37
+ background: var(--grad-brand);
38
+ -webkit-background-clip: text;
39
+ background-clip: text;
40
+ color: transparent;
41
+ }
42
+ .muted { color: var(--muted); }
43
+ pre {
44
+ font-family: var(--dig-mono);
45
+ background: rgba(127, 127, 127, 0.12);
46
+ padding: 1rem;
47
+ border-radius: 0.5rem;
48
+ overflow-x: auto;
49
+ }
@@ -0,0 +1,16 @@
1
+ import "./globals.css";
2
+ import type { Metadata } from "next";
3
+ import type { ReactNode } from "react";
4
+
5
+ export const metadata: Metadata = {
6
+ title: "__DISPLAY_NAME__",
7
+ description: "A Next.js static site on the DIG Network.",
8
+ };
9
+
10
+ export default function RootLayout({ children }: { children: ReactNode }) {
11
+ return (
12
+ <html lang="en">
13
+ <body>{children}</body>
14
+ </html>
15
+ );
16
+ }