+
+Create `init.js` — this generates a publisher key, creates an empty note board, uploads it, sets up the feed, and saves the configuration:
+
+```js
+import { Bee, Topic, PrivateKey } from "@ethersphere/bee-js";
+import crypto from "crypto";
+import { writeFileSync } from "fs";
+import { config } from "dotenv";
+config();
+
+const bee = new Bee(process.env.BEE_URL);
+const batchId = process.env.BATCH_ID;
+
+// Generate publisher key
+const hex = "0x" + crypto.randomBytes(32).toString("hex");
+const pk = new PrivateKey(hex);
+const owner = pk.publicKey().address();
+const topic = Topic.fromString("noteboard");
+
+// Create initial empty note board
+const notes = [];
+writeFileSync("notes.json", JSON.stringify(notes, null, 2));
+
+const html = generateHTML(notes);
+const upload = await bee.uploadFile(batchId, html, "index.html", {
+ contentType: "text/html",
+});
+// Set up feed and manifest
+const writer = bee.makeFeedWriter(topic, pk);
+await writer.upload(batchId, upload.reference);
const manifest = await bee.createFeedManifest(batchId, topic, owner);
-console.log("JS Manifest:", manifest.toHex());
+
+// Save config
+const cfg = {
+ privateKey: pk.toHex(),
+ owner: owner.toHex(),
+ topic: "noteboard",
+ manifest: manifest.toHex(),
+};
+writeFileSync("config.json", JSON.stringify(cfg, null, 2));
+
+console.log("Note board initialized!");
+console.log("Feed manifest:", manifest.toHex());
+console.log("View your board:", `${process.env.BEE_URL}/bzz/${manifest.toHex()}/`);
+
+function generateHTML(notes) {
+ const noteItems = notes
+ .map(
+ (n) => `
+
+
${n.text}
+
${n.date}
+
`
+ )
+ .join("\n");
+
+ return `
+
+Note Board
+
+ Note Board
+ ${notes.length} note${notes.length !== 1 ? "s" : ""}
+ ${noteItems || "No notes yet.
"}
+
+`;
+}
```
-Stable URL:
+Run it once:
+```bash
+node init.js
```
-bzz:///
+
+Example output:
+
+```
+Note board initialized!
+Feed manifest: caa414d70028d14b0bdd9cbab18d1c1a0a3bab1b...
+View your board: http://localhost:1633/bzz/caa414d70028d14b.../
```
-This URL never changes, even when you replace the underlying file.
+
+