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.
- package/LICENSE +21 -0
- package/README.md +217 -0
- package/bin/create-dig-app.js +17 -0
- package/lib/cli.js +438 -0
- package/lib/index.js +235 -0
- package/lib/nft-cli.js +265 -0
- package/lib/nft-metadata.js +515 -0
- package/lib/substitute.js +47 -0
- package/lib/templates.js +185 -0
- package/package.json +51 -0
- package/templates/dapp-window-chia/README.md +63 -0
- package/templates/dapp-window-chia/_env.example +7 -0
- package/templates/dapp-window-chia/_gitignore +10 -0
- package/templates/dapp-window-chia/dig.toml +17 -0
- package/templates/dapp-window-chia/index.html +12 -0
- package/templates/dapp-window-chia/package.json +24 -0
- package/templates/dapp-window-chia/src/App.jsx +91 -0
- package/templates/dapp-window-chia/src/main.jsx +10 -0
- package/templates/dapp-window-chia/src/styles.css +71 -0
- package/templates/dapp-window-chia/src/wallet.js +47 -0
- package/templates/dapp-window-chia/vite.config.js +14 -0
- package/templates/next-static/README.md +41 -0
- package/templates/next-static/_gitignore +6 -0
- package/templates/next-static/app/globals.css +49 -0
- package/templates/next-static/app/layout.jsx +14 -0
- package/templates/next-static/app/page.jsx +18 -0
- package/templates/next-static/dig.toml +17 -0
- package/templates/next-static/next.config.mjs +11 -0
- package/templates/next-static/package.json +16 -0
- package/templates/nft-collection/README.md +119 -0
- package/templates/nft-collection/_env.example +5 -0
- package/templates/nft-collection/_gitignore +9 -0
- package/templates/nft-collection/assets/banner.svg +11 -0
- package/templates/nft-collection/assets/icon.svg +10 -0
- package/templates/nft-collection/collection.json +14 -0
- package/templates/nft-collection/dig.toml +23 -0
- package/templates/nft-collection/images/sample-1.svg +5 -0
- package/templates/nft-collection/images/sample-2.svg +5 -0
- package/templates/nft-collection/licenses/.gitkeep +1 -0
- package/templates/nft-collection/metadata/.gitkeep +2 -0
- package/templates/nft-collection/package.json +18 -0
- package/templates/nft-collection/scripts/dig-nft.mjs +479 -0
- package/templates/nft-collection/src/mint.js +72 -0
- package/templates/nft-collection/src/styles.css +64 -0
- package/templates/nft-collection/traits.csv +3 -0
- package/templates/nft-drop/README.md +71 -0
- package/templates/nft-drop/_env.example +7 -0
- package/templates/nft-drop/_gitignore +10 -0
- package/templates/nft-drop/dig.toml +18 -0
- package/templates/nft-drop/index.html +12 -0
- package/templates/nft-drop/package.json +24 -0
- package/templates/nft-drop/src/App.jsx +91 -0
- package/templates/nft-drop/src/main.jsx +10 -0
- package/templates/nft-drop/src/mint.js +72 -0
- package/templates/nft-drop/src/styles.css +70 -0
- package/templates/nft-drop/vite.config.js +13 -0
- package/templates/static-site/README.md +41 -0
- package/templates/static-site/_gitignore +5 -0
- package/templates/static-site/dig.toml +19 -0
- package/templates/static-site/package.json +10 -0
- package/templates/static-site/scripts/build.mjs +14 -0
- package/templates/static-site/src/index.html +20 -0
- package/templates/static-site/src/styles.css +49 -0
- package/templates/vite-react/README.md +42 -0
- package/templates/vite-react/_gitignore +5 -0
- package/templates/vite-react/dig.toml +17 -0
- package/templates/vite-react/index.html +12 -0
- package/templates/vite-react/package.json +20 -0
- package/templates/vite-react/src/App.jsx +18 -0
- package/templates/vite-react/src/main.jsx +10 -0
- package/templates/vite-react/src/styles.css +49 -0
- package/templates/vite-react/vite.config.js +9 -0
- package/templates-ts/dapp-window-chia/README.md +67 -0
- package/templates-ts/dapp-window-chia/_env.example +7 -0
- package/templates-ts/dapp-window-chia/_gitignore +10 -0
- package/templates-ts/dapp-window-chia/dig.toml +17 -0
- package/templates-ts/dapp-window-chia/index.html +12 -0
- package/templates-ts/dapp-window-chia/package.json +28 -0
- package/templates-ts/dapp-window-chia/src/App.tsx +93 -0
- package/templates-ts/dapp-window-chia/src/main.tsx +13 -0
- package/templates-ts/dapp-window-chia/src/styles.css +71 -0
- package/templates-ts/dapp-window-chia/src/vite-env.d.ts +11 -0
- package/templates-ts/dapp-window-chia/src/wallet.ts +62 -0
- package/templates-ts/dapp-window-chia/tsconfig.json +20 -0
- package/templates-ts/dapp-window-chia/vite.config.ts +14 -0
- package/templates-ts/next-static/README.md +43 -0
- package/templates-ts/next-static/_gitignore +7 -0
- package/templates-ts/next-static/app/globals.css +49 -0
- package/templates-ts/next-static/app/layout.tsx +16 -0
- package/templates-ts/next-static/app/page.tsx +18 -0
- package/templates-ts/next-static/dig.toml +17 -0
- package/templates-ts/next-static/next-env.d.ts +5 -0
- package/templates-ts/next-static/next.config.mjs +11 -0
- package/templates-ts/next-static/package.json +23 -0
- package/templates-ts/next-static/tsconfig.json +21 -0
- package/templates-ts/nft-drop/README.md +74 -0
- package/templates-ts/nft-drop/_env.example +7 -0
- package/templates-ts/nft-drop/_gitignore +10 -0
- package/templates-ts/nft-drop/dig.toml +18 -0
- package/templates-ts/nft-drop/index.html +12 -0
- package/templates-ts/nft-drop/package.json +28 -0
- package/templates-ts/nft-drop/src/App.tsx +93 -0
- package/templates-ts/nft-drop/src/main.tsx +13 -0
- package/templates-ts/nft-drop/src/mint.ts +86 -0
- package/templates-ts/nft-drop/src/styles.css +70 -0
- package/templates-ts/nft-drop/src/vite-env.d.ts +11 -0
- package/templates-ts/nft-drop/tsconfig.json +20 -0
- package/templates-ts/nft-drop/vite.config.ts +13 -0
- package/templates-ts/vite-react/README.md +44 -0
- package/templates-ts/vite-react/_gitignore +5 -0
- package/templates-ts/vite-react/dig.toml +17 -0
- package/templates-ts/vite-react/index.html +12 -0
- package/templates-ts/vite-react/package.json +24 -0
- package/templates-ts/vite-react/src/App.tsx +18 -0
- package/templates-ts/vite-react/src/main.tsx +13 -0
- package/templates-ts/vite-react/src/styles.css +49 -0
- package/templates-ts/vite-react/src/vite-env.d.ts +1 -0
- package/templates-ts/vite-react/tsconfig.json +20 -0
- package/templates-ts/vite-react/vite.config.ts +9 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default function Home() {
|
|
2
|
+
return (
|
|
3
|
+
<main className="wrap">
|
|
4
|
+
<h1>__DISPLAY_NAME__</h1>
|
|
5
|
+
<p>
|
|
6
|
+
A Next.js static-export site on the <strong>DIG Network</strong> — served from a network no
|
|
7
|
+
host can read, 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,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
|
+
# Next.js with `output: 'export'` emits static files to out/ — that is the content root.
|
|
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,11 @@
|
|
|
1
|
+
/** @type {import('next').NextConfig} */
|
|
2
|
+
const nextConfig = {
|
|
3
|
+
// Static export — Next emits a folder of static files to out/, which digstore publishes as a
|
|
4
|
+
// capsule. A DIG capsule is a blind static host; there is no Next.js server at runtime.
|
|
5
|
+
output: "export",
|
|
6
|
+
// Relative-friendly asset paths so the build works under a *.on.dig.net subdomain and chia://.
|
|
7
|
+
images: { unoptimized: true },
|
|
8
|
+
trailingSlash: true,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default nextConfig;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__APP_NAME__",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "__DISPLAY_NAME__ — a Next.js + TypeScript static-export site on the DIG Network.",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "next dev",
|
|
8
|
+
"build": "next build",
|
|
9
|
+
"start": "next start",
|
|
10
|
+
"typecheck": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"next": "^14.2.15",
|
|
14
|
+
"react": "^18.3.1",
|
|
15
|
+
"react-dom": "^18.3.1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^20.16.11",
|
|
19
|
+
"@types/react": "^18.3.12",
|
|
20
|
+
"@types/react-dom": "^18.3.1",
|
|
21
|
+
"typescript": "^5.6.3"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "preserve",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [{ "name": "next" }],
|
|
17
|
+
"paths": { "@/*": ["./*"] }
|
|
18
|
+
},
|
|
19
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
20
|
+
"exclude": ["node_modules"]
|
|
21
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# __DISPLAY_NAME__
|
|
2
|
+
|
|
3
|
+
A wallet-connected **NFT drop** for the **DIG Network**, in **TypeScript** — a mint page wired to
|
|
4
|
+
`@dignetwork/dig-sdk` (`ChiaProvider` for the wallet, `@dignetwork/dig-sdk/spend` for the canonical
|
|
5
|
+
CHIP-0035 mint builder). The SDK ships its own types, so `ChiaProvider`/`ConnectOptions` are fully
|
|
6
|
+
typed — no `@types/*` package needed for the SDK.
|
|
7
|
+
|
|
8
|
+
Scaffolded with `npm create dig-app` (template: `nft-drop`, language: TypeScript).
|
|
9
|
+
|
|
10
|
+
## Free until publish — and nothing was minted
|
|
11
|
+
|
|
12
|
+
Scaffolding this template **did not mint anything, touch the chain, or spend funds.** Building and
|
|
13
|
+
previewing the mint page are **free**. Two distinct costs come later, both explicit:
|
|
14
|
+
|
|
15
|
+
- **Publishing the page** as a DIG capsule is one `digstore deploy` — **$DIG**.
|
|
16
|
+
- **Minting the NFTs** is a separate, wallet-signed on-chain action a visitor triggers (it spends
|
|
17
|
+
the visitor's funds). The spend is **built with the SDK** and signed by the wallet — never
|
|
18
|
+
hand-rolled.
|
|
19
|
+
|
|
20
|
+
## How minting is wired
|
|
21
|
+
|
|
22
|
+
`src/mint.ts` connects a wallet with `ChiaProvider.connect({ mode: "auto" })` (prefers the injected
|
|
23
|
+
DIG Browser wallet, falls back to WalletConnect → Sage) and shows the shape of a real mint: build
|
|
24
|
+
coin spends with `@dignetwork/dig-sdk/spend`, then `provider.signCoinSpends(...)`. Wire your
|
|
25
|
+
collection in `src/mint.ts` — see the spend builder and the "Build a dapp on Chia" tutorial:
|
|
26
|
+
<https://github.com/DIG-Network/dig-sdk> · <https://docs.dig.net/docs/build-a-dapp>.
|
|
27
|
+
|
|
28
|
+
The dev-shim wallet (in `digstore dev`) cannot sign — open the page in the **DIG Browser** (or
|
|
29
|
+
connect a real wallet) to mint for real.
|
|
30
|
+
|
|
31
|
+
## Connect to Sage in a normal browser (WalletConnect)
|
|
32
|
+
|
|
33
|
+
Outside the DIG Browser there is no injected `window.chia`, so a visitor connects **Sage** (the main
|
|
34
|
+
Chia wallet) over **WalletConnect**. This needs a free **project id**:
|
|
35
|
+
|
|
36
|
+
1. Get one at **<https://cloud.reown.com>** (Reown, formerly WalletConnect Cloud).
|
|
37
|
+
2. Copy `.env.example` to `.env` and set it:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
cp .env.example .env
|
|
41
|
+
# .env
|
|
42
|
+
VITE_WALLETCONNECT_PROJECT_ID=your_project_id_here
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`@walletconnect/sign-client` is already a dependency, so once `VITE_WALLETCONNECT_PROJECT_ID` is set,
|
|
46
|
+
**Connect wallet to mint** shows a pairing link/QR to approve in Sage and then displays the connected
|
|
47
|
+
address. Leave it blank to support only the injected DIG Browser wallet. (Never commit `.env` — only
|
|
48
|
+
the placeholder `.env.example` is tracked. The env is typed in `src/vite-env.d.ts`.)
|
|
49
|
+
|
|
50
|
+
## Develop
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
npm install
|
|
54
|
+
npm run dev # Vite dev server at http://localhost:5173
|
|
55
|
+
npm run typecheck # tsc --noEmit (type-check without building)
|
|
56
|
+
npm run build # tsc --noEmit && vite build -> dist/ (your content root)
|
|
57
|
+
digstore dev # preview on the real chia:// read path + dev wallet shim — FREE, no spend
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Publish the mint page (this is the only step that spends $DIG)
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
digstore deploy # build + publish a capsule ($DIG + a small XCH fee)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Deploy from CI
|
|
67
|
+
|
|
68
|
+
Wire up push-to-deploy with the GitHub Action:
|
|
69
|
+
<https://docs.dig.net/docs/digstore/cli/deploy-from-github-actions>.
|
|
70
|
+
|
|
71
|
+
## Config
|
|
72
|
+
|
|
73
|
+
`dig.toml` is the project manifest digstore reads (output dir, build command, default remote).
|
|
74
|
+
`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,18 @@
|
|
|
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 the mint PAGE as a
|
|
7
|
+
# capsule. (Minting the NFTs themselves is a separate, wallet-signed on-chain action — see README.)
|
|
8
|
+
|
|
9
|
+
# Vite emits the production build to dist/ — the content root digstore publishes.
|
|
10
|
+
output-dir = "__OUTPUT_DIR__"
|
|
11
|
+
|
|
12
|
+
# The command digstore runs to build before publishing (used by `digstore deploy` / CI).
|
|
13
|
+
build-command = "__BUILD_COMMAND__"
|
|
14
|
+
|
|
15
|
+
# Default remote a `digstore deploy` pushes to (resolves to your store after your first publish).
|
|
16
|
+
remote = "origin"
|
|
17
|
+
|
|
18
|
+
# 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-connected NFT drop on the DIG Network (TypeScript).",
|
|
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, mint } from "./mint.ts";
|
|
4
|
+
|
|
5
|
+
export default function App() {
|
|
6
|
+
const [provider, setProvider] = useState<ChiaProvider | null>(null);
|
|
7
|
+
const [address, setAddress] = useState<string>("");
|
|
8
|
+
const [status, setStatus] = useState<string>("");
|
|
9
|
+
const [error, setError] = useState<string>("");
|
|
10
|
+
// The WalletConnect pairing URI (only set during the WC → Sage fallback) — show it as a copy-link
|
|
11
|
+
// / QR / deep link so the visitor can approve in Sage.
|
|
12
|
+
const [wcUri, setWcUri] = useState<string>("");
|
|
13
|
+
|
|
14
|
+
async function onConnect() {
|
|
15
|
+
setError("");
|
|
16
|
+
setWcUri("");
|
|
17
|
+
try {
|
|
18
|
+
// Injected window.chia when present (DIG Browser / extension); otherwise WalletConnect → Sage.
|
|
19
|
+
// `onUri` fires only on the WC path, with the pairing URI to render.
|
|
20
|
+
const p = await connectWallet({ onUri: (uri) => setWcUri(uri) });
|
|
21
|
+
setProvider(p);
|
|
22
|
+
setAddress((await p.getAddress()) ?? "");
|
|
23
|
+
} catch (e) {
|
|
24
|
+
setError(e instanceof Error ? e.message : String(e));
|
|
25
|
+
} finally {
|
|
26
|
+
setWcUri(""); // pairing complete (or failed) — drop the URI
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function onMint() {
|
|
31
|
+
if (!provider) return;
|
|
32
|
+
setError("");
|
|
33
|
+
setStatus("Building the mint spend…");
|
|
34
|
+
try {
|
|
35
|
+
// Minting spends real funds and is wallet-signed — never auto-invoked. Wire your collection in
|
|
36
|
+
// src/mint.ts. The dev-shim wallet (in `digstore dev`) cannot sign; use the DIG Browser.
|
|
37
|
+
await mint(provider);
|
|
38
|
+
setStatus("Minted!");
|
|
39
|
+
} catch (e) {
|
|
40
|
+
setStatus("");
|
|
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
|
+
An NFT drop on the <strong>DIG Network</strong> — mint NFTs whose media can live in a DIG
|
|
50
|
+
capsule, truly permanent on Chia.
|
|
51
|
+
</p>
|
|
52
|
+
<p className="muted">
|
|
53
|
+
Building and previewing this mint page are <strong>free</strong> — no mint, no chain, no spend
|
|
54
|
+
when you scaffold or run it. Publishing the page is one <code>digstore deploy</code> ($DIG).
|
|
55
|
+
Minting the NFTs is a separate, wallet-signed on-chain action a visitor triggers.
|
|
56
|
+
</p>
|
|
57
|
+
|
|
58
|
+
{address ? (
|
|
59
|
+
<div className="card">
|
|
60
|
+
<div className="row">
|
|
61
|
+
<span className="muted">Connected via</span>
|
|
62
|
+
<strong>{provider?.backend}</strong>
|
|
63
|
+
</div>
|
|
64
|
+
<div className="row">
|
|
65
|
+
<span className="muted">Address</span>
|
|
66
|
+
<code>{address}</code>
|
|
67
|
+
</div>
|
|
68
|
+
<button onClick={onMint}>Mint</button>
|
|
69
|
+
{status && <p className="muted">{status}</p>}
|
|
70
|
+
</div>
|
|
71
|
+
) : (
|
|
72
|
+
<button onClick={onConnect}>Connect wallet to mint</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 the mint page, free
|
|
89
|
+
digstore deploy # publish the page as 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,86 @@
|
|
|
1
|
+
// NFT mint wiring via @dignetwork/dig-sdk (typed).
|
|
2
|
+
//
|
|
3
|
+
// IMPORTANT: scaffolding this template did NOT mint anything, touch the chain, or spend funds.
|
|
4
|
+
// Minting is an explicit, wallet-signed on-chain action the visitor triggers below — it requires a
|
|
5
|
+
// connected wallet and funds. The SDK is the canonical place to BUILD the spend; spends are never
|
|
6
|
+
// hand-rolled. The wallet signs the coin spends the builder produces.
|
|
7
|
+
//
|
|
8
|
+
// @dignetwork/dig-sdk ships its own .d.ts types, so ChiaProvider, ConnectOptions, and
|
|
9
|
+
// WalletConnectOptions are all fully typed — no `@types/*` package is needed for the SDK.
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
ChiaProvider,
|
|
13
|
+
type ConnectOptions,
|
|
14
|
+
type WalletConnectOptions,
|
|
15
|
+
} from "@dignetwork/dig-sdk";
|
|
16
|
+
|
|
17
|
+
// WalletConnect Cloud / Reown project id, read from the build-time env (see .env.example) and typed
|
|
18
|
+
// via src/vite-env.d.ts. When set, it enables the WalletConnect → Sage fallback so visitors without
|
|
19
|
+
// the injected DIG wallet can still connect Sage (the main Chia wallet) in a normal browser. Get a
|
|
20
|
+
// free id at https://cloud.reown.com (formerly WalletConnect Cloud).
|
|
21
|
+
const WALLETCONNECT_PROJECT_ID = import.meta.env.VITE_WALLETCONNECT_PROJECT_ID ?? "";
|
|
22
|
+
|
|
23
|
+
/** Hooks for the connect flow (e.g. render the WalletConnect pairing URI as a QR / copy-link). */
|
|
24
|
+
export interface ConnectHooks {
|
|
25
|
+
onUri?: (uri: string) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Connect a wallet for the drop. `mode: "auto"` prefers the injected DIG Browser wallet
|
|
30
|
+
* (window.chia) and falls back to WalletConnect → Sage when a project id is configured (the SDK
|
|
31
|
+
* drives its `WalletConnectTransport` under the hood — we never hand-roll WC).
|
|
32
|
+
*/
|
|
33
|
+
export async function connectWallet(hooks: ConnectHooks = {}): Promise<ChiaProvider> {
|
|
34
|
+
// The typed WalletConnect options the SDK's WalletConnectTransport consumes (projectId + metadata
|
|
35
|
+
// + the pairing-URI hook + the Chia chain). Only built when a project id is configured.
|
|
36
|
+
const walletConnect: WalletConnectOptions | undefined = WALLETCONNECT_PROJECT_ID
|
|
37
|
+
? {
|
|
38
|
+
projectId: WALLETCONNECT_PROJECT_ID,
|
|
39
|
+
metadata: {
|
|
40
|
+
name: "__DISPLAY_NAME__",
|
|
41
|
+
description: "An NFT drop built with create-dig-app",
|
|
42
|
+
url: typeof window !== "undefined" ? window.location.origin : "https://example.on.dig.net",
|
|
43
|
+
icons: [],
|
|
44
|
+
},
|
|
45
|
+
onUri: hooks.onUri, // render this URI as a QR / copy-link for the Sage fallback
|
|
46
|
+
}
|
|
47
|
+
: undefined;
|
|
48
|
+
|
|
49
|
+
const options: ConnectOptions = {
|
|
50
|
+
mode: "auto", // prefer injected window.chia; fall back to WalletConnect → Sage if configured
|
|
51
|
+
chain: "chia:mainnet", // CAIP-2 chain the SDK expects (Chia mainnet)
|
|
52
|
+
walletConnect,
|
|
53
|
+
};
|
|
54
|
+
return ChiaProvider.connect(options);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Build a mint spend with the canonical CHIP-0035 builder, then sign it with the wallet.
|
|
59
|
+
*
|
|
60
|
+
* This is the shape of a real mint: build the coin spends with `@dignetwork/dig-sdk/spend`, then
|
|
61
|
+
* hand them to `provider.signCoinSpends(...)`. Filling in the concrete mint builder + funding coins
|
|
62
|
+
* is left to you — see the chip35 spend builder + the "Build a dapp on Chia" tutorial:
|
|
63
|
+
* https://github.com/DIG-Network/dig-sdk
|
|
64
|
+
* https://docs.dig.net/docs/build-a-dapp
|
|
65
|
+
*
|
|
66
|
+
* It is intentionally NOT called automatically — minting spends real funds.
|
|
67
|
+
*
|
|
68
|
+
* @param provider A connected wallet (typed `ChiaProvider` from the SDK).
|
|
69
|
+
*/
|
|
70
|
+
export async function mint(provider: ChiaProvider): Promise<string> {
|
|
71
|
+
// The spend module is the canonical CHIP-0035 builder (re-exported chip35-dl-coin-wasm). Lazily
|
|
72
|
+
// imported so the read/connect path stays light until a visitor actually mints.
|
|
73
|
+
const spend = await import("@dignetwork/dig-sdk/spend");
|
|
74
|
+
spend.init();
|
|
75
|
+
|
|
76
|
+
// TODO: build your mint coin spends here with the wasm builder (e.g. from a prepared collection),
|
|
77
|
+
// then sign them with the wallet. Never hand-roll a spend bundle — always build it via the SDK.
|
|
78
|
+
const coinSpends: unknown[] = []; // <- produced by the spend builder for your collection/item
|
|
79
|
+
if (coinSpends.length === 0) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
"No mint spend wired yet. Build your coin spends with @dignetwork/dig-sdk/spend, then sign them. " +
|
|
82
|
+
"See https://docs.dig.net/docs/build-a-dapp",
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return provider.signCoinSpends(coinSpends);
|
|
86
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
.card {
|
|
54
|
+
margin: 1rem 0;
|
|
55
|
+
padding: 1rem;
|
|
56
|
+
border-radius: 0.75rem;
|
|
57
|
+
background: rgba(127, 127, 127, 0.12);
|
|
58
|
+
display: grid;
|
|
59
|
+
gap: 0.5rem;
|
|
60
|
+
}
|
|
61
|
+
.row { display: flex; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; }
|
|
62
|
+
code { font-family: var(--dig-mono); word-break: break-all; }
|
|
63
|
+
pre {
|
|
64
|
+
font-family: var(--dig-mono);
|
|
65
|
+
margin-top: 1.5rem;
|
|
66
|
+
background: rgba(127, 127, 127, 0.12);
|
|
67
|
+
padding: 1rem;
|
|
68
|
+
border-radius: 0.5rem;
|
|
69
|
+
overflow-x: auto;
|
|
70
|
+
}
|
|
@@ -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,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,13 @@
|
|
|
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 CHIP-0035 spend builder (@dignetwork/dig-sdk/spend → chip35-dl-coin-wasm) is a WebAssembly
|
|
7
|
+
// module loaded with top-level await, so we enable the wasm + top-level-await plugins. Relative base
|
|
8
|
+
// so the built mint page works from any path on a *.on.dig.net subdomain (and chia://).
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
base: "./",
|
|
11
|
+
plugins: [react(), wasm(), topLevelAwait()],
|
|
12
|
+
build: { outDir: "dist" },
|
|
13
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# __DISPLAY_NAME__
|
|
2
|
+
|
|
3
|
+
A React + **TypeScript** app (Vite) for the **DIG Network** — deployed to a network no host can
|
|
4
|
+
read, change, or take down.
|
|
5
|
+
|
|
6
|
+
Scaffolded with `npm create dig-app` (template: `vite-react`, language: TypeScript).
|
|
7
|
+
|
|
8
|
+
## Free until publish
|
|
9
|
+
|
|
10
|
+
Scaffolding, building, and previewing cost **nothing**. There is **no mint, no chain, and no spend**
|
|
11
|
+
when you create or run this project — you only spend **$DIG** the moment you publish a
|
|
12
|
+
capsule with `digstore deploy`. *Iterate for free, publish when it's ready.*
|
|
13
|
+
|
|
14
|
+
## Develop
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install
|
|
18
|
+
npm run dev # Vite dev server at http://localhost:5173
|
|
19
|
+
npm run typecheck # tsc --noEmit (type-check without building)
|
|
20
|
+
npm run build # tsc --noEmit && vite build -> dist/ (your content root)
|
|
21
|
+
digstore dev # preview on the real chia:// read path — FREE, no chain, no spend
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`digstore dev` serves your built site through the genuine DIG read path (encrypt → compile → verify
|
|
25
|
+
→ decrypt) with live reload and an injected `window.chia` dev shim, so what you see is exactly what
|
|
26
|
+
visitors get.
|
|
27
|
+
|
|
28
|
+
## Publish (this is the only step that spends $DIG)
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
digstore deploy # build + publish a capsule ($DIG + a small XCH fee)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Your app goes live at its `*.on.dig.net` address. Re-run `digstore deploy` to ship an update.
|
|
35
|
+
|
|
36
|
+
## Deploy from CI
|
|
37
|
+
|
|
38
|
+
Wire up push-to-deploy with the GitHub Action:
|
|
39
|
+
<https://docs.dig.net/docs/digstore/cli/deploy-from-github-actions>.
|
|
40
|
+
|
|
41
|
+
## Config
|
|
42
|
+
|
|
43
|
+
`dig.toml` is the project manifest digstore reads (output dir, build command, default remote).
|
|
44
|
+
`tsconfig.json` configures TypeScript (strict mode, `bundler` resolution for Vite).
|
|
@@ -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/ — that is 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>
|