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,71 @@
|
|
|
1
|
+
# __DISPLAY_NAME__
|
|
2
|
+
|
|
3
|
+
A wallet-connected **NFT drop** for the **DIG Network** — 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).
|
|
6
|
+
|
|
7
|
+
Scaffolded with `npm create dig-app` (template: `nft-drop`).
|
|
8
|
+
|
|
9
|
+
## Free until publish — and nothing was minted
|
|
10
|
+
|
|
11
|
+
Scaffolding this template **did not mint anything, touch the chain, or spend funds.** Building and
|
|
12
|
+
previewing the mint page are **free**. Two distinct costs come later, both explicit:
|
|
13
|
+
|
|
14
|
+
- **Publishing the page** as a DIG capsule is one `digstore deploy` — **$DIG**.
|
|
15
|
+
- **Minting the NFTs** is a separate, wallet-signed on-chain action a visitor triggers (it spends
|
|
16
|
+
the visitor's funds). The spend is **built with the SDK** and signed by the wallet — never
|
|
17
|
+
hand-rolled.
|
|
18
|
+
|
|
19
|
+
## How minting is wired
|
|
20
|
+
|
|
21
|
+
`src/mint.js` connects a wallet with `ChiaProvider.connect({ mode: "auto" })` (prefers the injected
|
|
22
|
+
DIG Browser wallet, falls back to WalletConnect → Sage) and shows the shape of a real mint: build
|
|
23
|
+
coin spends with `@dignetwork/dig-sdk/spend`, then `provider.signCoinSpends(...)`. Wire your
|
|
24
|
+
collection in `src/mint.js` — see the spend builder and the "Build a dapp on Chia" tutorial:
|
|
25
|
+
<https://github.com/DIG-Network/dig-sdk> · <https://docs.dig.net/docs/build-a-dapp>.
|
|
26
|
+
|
|
27
|
+
The dev-shim wallet (in `digstore dev`) cannot sign — open the page in the **DIG Browser** (or
|
|
28
|
+
connect a real wallet) to mint for real.
|
|
29
|
+
|
|
30
|
+
## Connect to Sage in a normal browser (WalletConnect)
|
|
31
|
+
|
|
32
|
+
Outside the DIG Browser there is no injected `window.chia`, so a visitor connects **Sage** (the main
|
|
33
|
+
Chia wallet) over **WalletConnect**. This needs a free **project id**:
|
|
34
|
+
|
|
35
|
+
1. Get one at **<https://cloud.reown.com>** (Reown, formerly WalletConnect Cloud).
|
|
36
|
+
2. Copy `.env.example` to `.env` and set it:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
cp .env.example .env
|
|
40
|
+
# .env
|
|
41
|
+
VITE_WALLETCONNECT_PROJECT_ID=your_project_id_here
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`@walletconnect/sign-client` is already a dependency, so once `VITE_WALLETCONNECT_PROJECT_ID` is set,
|
|
45
|
+
**Connect wallet to mint** shows a pairing link/QR to approve in Sage and then displays the connected
|
|
46
|
+
address. Leave it blank to support only the injected DIG Browser wallet. (Never commit `.env` — only
|
|
47
|
+
the placeholder `.env.example` is tracked.)
|
|
48
|
+
|
|
49
|
+
## Develop
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
npm install
|
|
53
|
+
npm run dev # Vite dev server at http://localhost:5173
|
|
54
|
+
npm run build # production build -> dist/ (your content root)
|
|
55
|
+
digstore dev # preview on the real chia:// read path + dev wallet shim — FREE, no spend
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Publish the mint page (this is the only step that spends $DIG)
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
digstore deploy # build + publish a capsule ($DIG + a small XCH fee)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Deploy from CI
|
|
65
|
+
|
|
66
|
+
Wire up push-to-deploy with the GitHub Action:
|
|
67
|
+
<https://docs.dig.net/docs/digstore/cli/deploy-from-github-actions>.
|
|
68
|
+
|
|
69
|
+
## Config
|
|
70
|
+
|
|
71
|
+
`dig.toml` is the project manifest digstore reads (output dir, build command, default remote).
|
|
@@ -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.jsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
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.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "vite",
|
|
9
|
+
"build": "vite build",
|
|
10
|
+
"preview": "vite preview"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@dignetwork/dig-sdk": "__SDK_VERSION__",
|
|
14
|
+
"@walletconnect/sign-client": "^2.11.0",
|
|
15
|
+
"react": "^18.3.1",
|
|
16
|
+
"react-dom": "^18.3.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
20
|
+
"vite": "^5.4.11",
|
|
21
|
+
"vite-plugin-top-level-await": "^1.4.4",
|
|
22
|
+
"vite-plugin-wasm": "^3.3.0"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { connectWallet, mint } from "./mint.js";
|
|
3
|
+
|
|
4
|
+
export default function App() {
|
|
5
|
+
const [provider, setProvider] = useState(null);
|
|
6
|
+
const [address, setAddress] = useState("");
|
|
7
|
+
const [status, setStatus] = useState("");
|
|
8
|
+
const [error, setError] = useState("");
|
|
9
|
+
// The WalletConnect pairing URI (only set during the WC → Sage fallback) — show it as a copy-link
|
|
10
|
+
// / QR / deep link so the visitor can approve in Sage.
|
|
11
|
+
const [wcUri, setWcUri] = useState("");
|
|
12
|
+
|
|
13
|
+
async function onConnect() {
|
|
14
|
+
setError("");
|
|
15
|
+
setWcUri("");
|
|
16
|
+
try {
|
|
17
|
+
// Injected window.chia when present (DIG Browser / extension); otherwise WalletConnect → Sage.
|
|
18
|
+
// `onUri` fires only on the WC path, with the pairing URI to render.
|
|
19
|
+
const p = await connectWallet({ onUri: (uri) => setWcUri(uri) });
|
|
20
|
+
setProvider(p);
|
|
21
|
+
setAddress(await p.getAddress());
|
|
22
|
+
} catch (e) {
|
|
23
|
+
setError(e?.message ?? String(e));
|
|
24
|
+
} finally {
|
|
25
|
+
setWcUri(""); // pairing complete (or failed) — drop the URI
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function onMint() {
|
|
30
|
+
setError("");
|
|
31
|
+
setStatus("Building the mint spend…");
|
|
32
|
+
try {
|
|
33
|
+
// Minting spends real funds and is wallet-signed — never auto-invoked. Wire your collection in
|
|
34
|
+
// src/mint.js. The dev-shim wallet (in `digstore dev`) cannot sign; use the DIG Browser.
|
|
35
|
+
await mint(provider);
|
|
36
|
+
setStatus("Minted!");
|
|
37
|
+
} catch (e) {
|
|
38
|
+
setStatus("");
|
|
39
|
+
setError(e?.message ?? String(e));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<main className="wrap">
|
|
45
|
+
<h1>__DISPLAY_NAME__</h1>
|
|
46
|
+
<p>
|
|
47
|
+
An NFT drop on the <strong>DIG Network</strong> — mint NFTs whose media can live in a DIG
|
|
48
|
+
capsule, truly permanent on Chia.
|
|
49
|
+
</p>
|
|
50
|
+
<p className="muted">
|
|
51
|
+
Building and previewing this mint page are <strong>free</strong> — no mint, no chain, no spend
|
|
52
|
+
when you scaffold or run it. Publishing the page is one <code>digstore deploy</code> ($DIG).
|
|
53
|
+
Minting the NFTs is a separate, wallet-signed on-chain action a visitor triggers.
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
{address ? (
|
|
57
|
+
<div className="card">
|
|
58
|
+
<div className="row">
|
|
59
|
+
<span className="muted">Connected via</span>
|
|
60
|
+
<strong>{provider?.backend}</strong>
|
|
61
|
+
</div>
|
|
62
|
+
<div className="row">
|
|
63
|
+
<span className="muted">Address</span>
|
|
64
|
+
<code>{address}</code>
|
|
65
|
+
</div>
|
|
66
|
+
<button onClick={onMint}>Mint</button>
|
|
67
|
+
{status && <p className="muted">{status}</p>}
|
|
68
|
+
</div>
|
|
69
|
+
) : (
|
|
70
|
+
<button onClick={onConnect}>Connect wallet to mint</button>
|
|
71
|
+
)}
|
|
72
|
+
|
|
73
|
+
{wcUri && (
|
|
74
|
+
<div className="card">
|
|
75
|
+
<p className="muted">
|
|
76
|
+
Scan or open this in <strong>Sage</strong> to connect (WalletConnect):
|
|
77
|
+
</p>
|
|
78
|
+
<code>{wcUri}</code>
|
|
79
|
+
<button onClick={() => navigator.clipboard?.writeText(wcUri)}>Copy pairing link</button>
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
82
|
+
|
|
83
|
+
{error && <p className="error">{error}</p>}
|
|
84
|
+
|
|
85
|
+
<pre>
|
|
86
|
+
<code>{`digstore dev # preview the mint page, free
|
|
87
|
+
digstore deploy # publish the page as a capsule ($DIG)`}</code>
|
|
88
|
+
</pre>
|
|
89
|
+
</main>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// NFT mint wiring via @dignetwork/dig-sdk.
|
|
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
|
+
import { ChiaProvider } from "@dignetwork/dig-sdk";
|
|
9
|
+
|
|
10
|
+
// WalletConnect Cloud / Reown project id, read from the build-time env (see .env.example). When set,
|
|
11
|
+
// it enables the WalletConnect → Sage fallback so visitors without the injected DIG wallet can still
|
|
12
|
+
// connect Sage (the main Chia wallet) in a normal browser. Get a free id at https://cloud.reown.com.
|
|
13
|
+
const WALLETCONNECT_PROJECT_ID = import.meta.env.VITE_WALLETCONNECT_PROJECT_ID ?? "";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Connect a wallet for the drop. `mode: "auto"` prefers the injected DIG Browser wallet
|
|
17
|
+
* (window.chia) and falls back to WalletConnect → Sage when a project id is configured (the SDK
|
|
18
|
+
* drives its `WalletConnectTransport` under the hood — we never hand-roll WC).
|
|
19
|
+
*
|
|
20
|
+
* @param {{ onUri?: (uri: string) => void }} [hooks] `onUri` receives the WalletConnect pairing URI
|
|
21
|
+
* so the UI can show a QR / copy-link / deep link to Sage during the fallback.
|
|
22
|
+
* @returns {Promise<import("@dignetwork/dig-sdk").ChiaProvider>}
|
|
23
|
+
*/
|
|
24
|
+
export async function connectWallet(hooks = {}) {
|
|
25
|
+
return ChiaProvider.connect({
|
|
26
|
+
mode: "auto", // prefer injected window.chia; fall back to WalletConnect → Sage if configured
|
|
27
|
+
chain: "chia:mainnet", // CAIP-2 chain the SDK expects (Chia mainnet)
|
|
28
|
+
walletConnect: WALLETCONNECT_PROJECT_ID
|
|
29
|
+
? {
|
|
30
|
+
projectId: WALLETCONNECT_PROJECT_ID,
|
|
31
|
+
metadata: {
|
|
32
|
+
name: "__DISPLAY_NAME__",
|
|
33
|
+
description: "An NFT drop built with create-dig-app",
|
|
34
|
+
url: typeof window !== "undefined" ? window.location.origin : "https://example.on.dig.net",
|
|
35
|
+
icons: [],
|
|
36
|
+
},
|
|
37
|
+
onUri: hooks.onUri, // render this URI as a QR / copy-link for the Sage fallback
|
|
38
|
+
}
|
|
39
|
+
: undefined,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Build + sign a mint spend with the canonical CHIP-0035 builder, then sign it with the wallet.
|
|
45
|
+
*
|
|
46
|
+
* This is the shape of a real mint: build the coin spends with `@dignetwork/dig-sdk/spend`, then
|
|
47
|
+
* hand them to `provider.signCoinSpends(...)`. Filling in the concrete mint builder + funding coins
|
|
48
|
+
* is left to you — see the chip35 spend builder + the "Build a dapp on Chia" tutorial:
|
|
49
|
+
* https://github.com/DIG-Network/dig-sdk
|
|
50
|
+
* https://docs.dig.net/docs/build-a-dapp
|
|
51
|
+
*
|
|
52
|
+
* It is intentionally NOT called automatically — minting spends real funds.
|
|
53
|
+
*
|
|
54
|
+
* @param {import("@dignetwork/dig-sdk").ChiaProvider} provider A connected wallet.
|
|
55
|
+
*/
|
|
56
|
+
export async function mint(provider) {
|
|
57
|
+
// The spend module is the canonical CHIP-0035 builder (re-exported chip35-dl-coin-wasm). Lazily
|
|
58
|
+
// imported so the read/connect path stays light until a visitor actually mints.
|
|
59
|
+
const spend = await import("@dignetwork/dig-sdk/spend");
|
|
60
|
+
spend.init();
|
|
61
|
+
|
|
62
|
+
// TODO: build your mint coin spends here with the wasm builder (e.g. from a prepared collection),
|
|
63
|
+
// then sign them with the wallet. Never hand-roll a spend bundle — always build it via the SDK.
|
|
64
|
+
const coinSpends = []; // <- produced by the spend builder for your collection/item
|
|
65
|
+
if (coinSpends.length === 0) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
"No mint spend wired yet. Build your coin spends with @dignetwork/dig-sdk/spend, then sign them. " +
|
|
68
|
+
"See https://docs.dig.net/docs/build-a-dapp",
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return provider.signCoinSpends(coinSpends);
|
|
72
|
+
}
|
|
@@ -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,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,41 @@
|
|
|
1
|
+
# __DISPLAY_NAME__
|
|
2
|
+
|
|
3
|
+
A static site for the **DIG Network** — deployed to a network no host can read, change, or take down.
|
|
4
|
+
|
|
5
|
+
Scaffolded with `npm create dig-app` (template: `static-site`).
|
|
6
|
+
|
|
7
|
+
## Free until publish
|
|
8
|
+
|
|
9
|
+
Scaffolding, building, and previewing cost **nothing**. There is **no mint, no chain, and no spend**
|
|
10
|
+
when you create or run this project — you only spend **$DIG** the moment you publish a capsule with
|
|
11
|
+
`digstore deploy`. *Iterate for free, publish when it's ready.*
|
|
12
|
+
|
|
13
|
+
## Develop
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install
|
|
17
|
+
npm run build # copies src/ -> public/ (your content root)
|
|
18
|
+
digstore dev # preview on the real chia:// read path — FREE, no chain, no spend
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`digstore dev` serves your built site through the genuine DIG read path (encrypt → compile → verify
|
|
22
|
+
→ decrypt) with live reload, so what you see is exactly what visitors get.
|
|
23
|
+
|
|
24
|
+
## Publish (this is the only step that spends $DIG)
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
digstore deploy # build + publish a capsule (spends $DIG + a small XCH fee)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Your site goes live on **DIGHUb** (`hub.dig.net/stores/<id>`) and, if you register one, at its
|
|
31
|
+
optional `<your-name>.on.dig.net` address — immutable, encrypted, and impossible to take down.
|
|
32
|
+
Re-run `digstore deploy` to ship an update (each published update is a new capsule).
|
|
33
|
+
|
|
34
|
+
## Deploy from CI
|
|
35
|
+
|
|
36
|
+
Wire up push-to-deploy with the GitHub Action so every push to `main` publishes a new capsule:
|
|
37
|
+
<https://docs.dig.net/docs/digstore/cli/deploy-from-github-actions>.
|
|
38
|
+
|
|
39
|
+
## Config
|
|
40
|
+
|
|
41
|
+
`dig.toml` is the project manifest digstore reads (output dir, build command, default remote).
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
# The built output digstore publishes as your site. For this template the "build" just copies
|
|
9
|
+
# src/ into public/, so the content root is the build output.
|
|
10
|
+
output-dir = "__OUTPUT_DIR__"
|
|
11
|
+
|
|
12
|
+
# The command digstore runs to (re)build before publishing — used by `digstore deploy` / CI.
|
|
13
|
+
build-command = "__BUILD_COMMAND__"
|
|
14
|
+
|
|
15
|
+
# The default remote a `digstore deploy` pushes to. `origin` resolves to your store once it exists
|
|
16
|
+
# (after your first publish / `digstore init`). Until then, deploy/dev work locally with no chain.
|
|
17
|
+
remote = "origin"
|
|
18
|
+
|
|
19
|
+
# network = "mainnet" # the only network today; shown for completeness
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__APP_NAME__",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "__DISPLAY_NAME__ — a static site on the DIG Network.",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "node scripts/build.mjs",
|
|
8
|
+
"dev": "node scripts/build.mjs && echo \"Built to __OUTPUT_DIR__/ — run 'digstore dev' to preview on the real chia:// read path (free).\""
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Minimal "build" for the static template: copy src/ → public/ (the dig.toml output-dir).
|
|
2
|
+
// No bundler, no dependencies — the lightest possible path to a publishable content root.
|
|
3
|
+
import { cpSync, rmSync, mkdirSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const out = join(root, "public");
|
|
9
|
+
|
|
10
|
+
rmSync(out, { recursive: true, force: true });
|
|
11
|
+
mkdirSync(out, { recursive: true });
|
|
12
|
+
cpSync(join(root, "src"), out, { recursive: true });
|
|
13
|
+
|
|
14
|
+
console.log("Built src/ -> public/");
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
<link rel="stylesheet" href="./styles.css" />
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<main>
|
|
11
|
+
<h1>__DISPLAY_NAME__</h1>
|
|
12
|
+
<p>A static site on the <strong>DIG Network</strong> — no host can read it, change it, or take it down.</p>
|
|
13
|
+
<p class="muted">
|
|
14
|
+
Build and preview for <strong>free</strong>. You only spend $DIG when you publish.
|
|
15
|
+
</p>
|
|
16
|
+
<pre><code>digstore dev # preview, free
|
|
17
|
+
digstore deploy # publish a capsule ($DIG)</code></pre>
|
|
18
|
+
</main>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
@@ -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
|
+
main { 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,42 @@
|
|
|
1
|
+
# __DISPLAY_NAME__
|
|
2
|
+
|
|
3
|
+
A React app (Vite) for the **DIG Network** — deployed to a network no host can read, change, or
|
|
4
|
+
take down.
|
|
5
|
+
|
|
6
|
+
Scaffolded with `npm create dig-app` (template: `vite-react`).
|
|
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 build # production build -> dist/ (your content root)
|
|
20
|
+
digstore dev # preview on the real chia:// read path — FREE, no chain, no spend
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`digstore dev` serves your built site through the genuine DIG read path (encrypt → compile → verify
|
|
24
|
+
→ decrypt) with live reload and an injected `window.chia` dev shim, so what you see is exactly what
|
|
25
|
+
visitors get.
|
|
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 app 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).
|
|
@@ -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.jsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|