Hands-on¶
This is the chapter where you run IW3IP yourself to understand it. Basic establishes the overall picture, Feature Extensions covers safe sharing and tiered access, and Intelligence Integration covers AI that enriches data and interprets requests.
Finish Prerequisites (install tools) before moving on to this page. This page tells you when to run Quickstart (run the stack) in its order.
The pages in this section are step-by-step procedures with commands, expected output and checkpoints. The mechanisms and the reasons behind each feature's design are in the Design section, and what to do when a step does not work is in the Support section.
If this is your first time
If this is your first time, go in this order.
- Prerequisites (install tools)
- §1.1 Run the whole pipeline without hardware (HA Demo Simulator)
- Quickstart (run the stack)
- One of the three pages in §1.2
- Listing and purchase in §1.3
- §1.4 (optional)
Exception: if you pick Pull from Home Assistant (HA SSI Publisher) in §1.2, do §1.2 right after §1.1 without running Quickstart. The publisher on that page uses port 8080, the same port as the Quickstart IPFS. After §1.2, stop the publisher, run Quickstart, and go on to §1.3.
In groups where you pick one page, such as §1.2 and §2.1, the "Next" link at the bottom of the page can point to another option in the same group or to a page that is not the next step. Follow each page's Next steps section instead.
Go on to Part 2 and later only when you need them.
Basic vs Feature Extensions¶
The hands-on explains the marketplace stack in two layers: Basic (v1) and Feature Extensions (v2). They are additive lanes, not a replacement — Basic alone is enough to buy and sell data.
Basic (v1) — minimal setup¶
- List data on the marketplace and purchase via MetaMask to receive it. The seller side puts the data in the storage server (simple-storage), encrypts its location (URI) with the buyer's public key, and writes it to the chain. The buyer side decrypts it and fetches the data
- All you need is a PC and MetaMask
- Part 1 of the hands-on builds this v1 path
Feature Extensions (v2) — safe, conditional, tiered access¶
- After purchase a smartphone SSI wallet receives a VC
- The receiver presents that VC to fetch data. The contents shown vary by
purposeand trust level - Part 2 of the hands-on covers this v2 path plus the consent and tiered access that sit on top of it
flowchart TB
BUY["Purchase (shared by v1 and v2)"]
subgraph L1["v1 lane (covered in Part 1)"]
direction LR
A1["encrypted URI"] --> A2["decrypt"] --> A3["data from storage"]
end
subgraph L2["v2 lane (covered in Part 2)"]
direction LR
B1["bridge"] --> B2["PurchaseViewerVC"] --> B3["wallet"] --> B4["ViewerToken"] --> B5["/platform/data"]
end
BUY --> A1
BUY --> B1
Design detail: Marketplace VC Bridge — v1 / v2 Design Spec.
About $HOST_IP in commands¶
Hands-on pages where a phone connects to the PC use the PC's IP address on the LAN. Commands on each page write it as $HOST_IP; URLs that you type into a browser or phone write it as <HOST_IP>.
First find the PC's IP address.
| OS | Command |
|---|---|
| macOS | ipconfig getifaddr en0 (change to en1 etc. for wired LAN) |
| Linux | hostname -I (the first address shown) |
| Windows | Run ipconfig in PowerShell and read "IPv4 Address" |
In each terminal where you run commands, first run the following (replace 192.168.1.20 with your own IP).
export HOST_IP=192.168.1.20
After that, commands containing $HOST_IP can be pasted and run as they are. Replace <HOST_IP> in URLs with the same IP address. On Windows with WSL2, also set HOST_IP to the IP address shown by ipconfig on the Windows side.
Overall structure¶
Capture and share IoT data
Pull data off cameras and sensors, view it, and trade it on the marketplace.
HA Demo Simulator / HUSKYLENS2 / USB Webcam / HA Publisher / Mobile Viewer (optional)
Consent, conditional sharing, tiered access
Use VCs and a wallet to share according to purpose and trust level. You can stop partway.
2.1 Event sharing / 2.2 Consent (Consent VC) / 2.3 Split roles / 2.4 Marketplace × wallet / 2.5 Tiered access and provenance
Let an AI act on requests
An AI interprets free-form requests and uses data as material to plan and act. You can start it before finishing all of Part 2.
Enrich camera data with a local VLM / Protect camera images before handing them to AI / Regional Safety Assistant / LLM Planner
Paths by goal¶
| Goal | Scope | Time required |
|---|---|---|
| See it run first | §1.1 Run the whole pipeline without hardware (HA Demo Simulator) only | approx. 20 min |
| Cover all of Basic | Part 1 §1.1–§1.3 (pick one device in §1.2) | approx. 50–65 min (§1.1 and §1.2; §1.3 not included) |
| Also buy on a phone (optional) | Part 1 §1.4 | approx. 20 min |
| Reach safe / conditional sharing | Part 2 §2.1–§2.3 (pick one page in §2.1) | approx. 3–3.25 hours |
| Reach v2 marketplace integration | Part 2 §2.4 (Stages 5, 6, 7, A) | approx. 3 hours 45 min |
| Tiered access | Part 2 §2.5: the first Stage T page | approx. 60 min |
| Image/video delivery and semantic-level tiering | Part 2 §2.5: the next two Stage T pages | approx. 2.5–3 hours |
| Prove image provenance | Part 2 §2.5: Stage P, P0 | approx. 30–40 min |
| Connect provenance to the publisher and the chain | Part 2 §2.5: Stage P, P1 and P2 | approx. 40–60 min |
| Trace a VLM summary back to the image | Part 2 §2.5: Stage P, P3 | approx. 20–30 min (30 min to 1 hour more to try a real VLM) |
| Reach AI integration | Part 3 | approx. 4–5 hours |
Each time is the sum of the estimates at the top of the pages in that row. It does not include the rows above. §1.3 is a section of this page and gives no time estimate. If you do both §2.1 pages, §2.1 takes about 75 min. The times do not include Prerequisites (install tools) or Quickstart (run the stack) (approx. 15–30 min).
Each hands-on page opens with a "What you'll do / Prerequisites / Keep running / What you need / Time required" block. If you get stuck partway, see Troubleshooting.
How Part, Phase, and Stage relate¶
This site uses three kinds of numbering.
- Part 1–3: the learning order on this site (Basic, Feature Extensions, Intelligence Integration).
- Phase 1–3: the development stages of the platform. Phase 1 is data sharing, Phase 2 is event sharing, and Phase 3 is AI-based decision and control (see the Phase structure in Platform Overview).
- Stage 0–7, A, T, P: labels for the Part 2 hands-on pages that use VCs, plus their preparation (Stage 0) and image provenance signing (Stage P). A covers the phone app (PWA) from purchase to viewing, T covers tiers (tiered access by trust level), and P covers provenance (where an image came from). The numbers are a guide to the order. Which pages you must finish first is given by the "Prerequisites" line at the top of each page. For example, the first Stage P page (P0) uses neither the earlier Stages nor any VC and runs on its own with only the course repository and Python. The following P1–P3 pages connect to the publisher and the chain and use per-tier ViewerTokens (obtained with a PurchaseViewerVC).
There is no Stage 2. Stage 4 prep is the ServiceVC page that prepares for the stage where VCs authorize the LLM Planner's execution (planned as Stage 4). Stages 8 and 9 appear on some pages only as future work. They have no hands-on pages.
| Stage | Hands-on | VC |
|---|---|---|
| 0 | Share detections, not raw frames, Share disaster events | none (JSON registered at /consents) |
| 1 | Authenticate the data provider (Consent VC / Stage 1) | ConsentVC |
| 3 | Authenticate the viewer (Viewer VC / Stage 3) | ViewerVC |
| 4 prep | Authenticate machines (Service VC / Stage 4 prep) | ServiceVC |
| 5 | Hand a credential to the buyer's wallet (Bridge / Stage 5) | PurchaseViewerVC |
| 6 | Read ServiceVC-written data with a PurchaseViewerVC (Stage 6) | ServiceVC + PurchaseViewerVC (builds on the ConsentVC / ViewerVC flows of Stages 1 and 3) |
| 7 | Back the seller's identity (Seller VC / Stage 7) | SellerVC |
| A | Marketplace as a phone app (Stage A) | PurchaseViewerVC (phone only) |
| T | Tier the response by trust (DataUserVC / Stage T) | DataUserVC, PurchaseViewerVC (received and presented the same way as Steps 7–8 of Stage 5) |
| P | Prove where an image came from (C2PA / Stage P) | none (C2PA signing with X.509 certificates; no publisher or wallet needed) |
| P | Connect provenance to the publisher and the chain (C2PA / Stage P, P1 and P2) | PurchaseViewerVC (DataUserVC attributes decide the tier; used by a wallet inside the program, so no phone needed) |
| P | Trace a VLM summary back to the image (C2PA / Stage P, P3) | PurchaseViewerVC (DataUserVC attributes decide the tier; used by a wallet inside the program, so no phone needed) |
The mapping between VCs and tokens is summarized in VC architecture overview (Part 2 / Stages 0–7, T, A, P).
Tech stack at a glance¶
What each group in the left navigation uses. In Part 2, some groups use the blockchain and others do not.
| Group | publisher (Docker) | Blockchain (Hardhat) | MetaMask | SSI wallet (phone) | IPFS / storage (v1) | Image proc. / LLM |
|---|---|---|---|---|---|---|
| Part 1 / 1.1 HA Demo Simulator | ✓ | – | – | – | – | – |
| Part 1 / 1.2 Capture data from a device (pick one) | ✓ (HA path) | ✓ (camera path) | – | – | ✓ (camera path) | – |
| Part 1 / 1.3–1.4 Trade on the marketplace (1.3 is on the Hands-on page) | – | ✓ | ✓ | – | ✓ | – |
| Part 2 / 2.1 Event sharing (Stage 0, pick one) | ✓ | – | – | ✓ (appendix only) | – | – |
| Part 2 / 2.2–2.3 Consent and split roles (Stage 1, 3, 4 prep) | ✓ | – | – | ✓ | – | – |
| Part 2 / 2.4 Marketplace × wallet (v2) | ✓ | ✓ | ✓ | ✓ | – | – |
| Part 2 / 2.5 Tiered access and provenance (Stage T / P)* | ✓ | ✓ (for Tier 3 e2e) | ✓ (same) | ✓ | – | ✓ (OpenCV / VLM optional) |
| Part 3: Intelligence Integration — let an AI act on requests | ✓ | – | – | – | – | ✓ (VLM / LLM) |
* In this group, Prove where an image came from (C2PA / Stage P) runs with Python only and uses no publisher, blockchain, MetaMask, SSI wallet, or VC. The follow-ups, Connect provenance to the publisher and the chain (C2PA / Stage P, P1 and P2) and Trace a VLM summary back to the image (C2PA / Stage P, P3), use the publisher and Hardhat, and a wallet inside the program receives a PurchaseViewerVC to get a per-tier ViewerToken. They use no MetaMask or phone wallet.
VCs used¶
| Group | Consent | Viewer | Service | PurchaseViewer | Seller | DataUser |
|---|---|---|---|---|---|---|
| Part 2 / 2.1 Event sharing (Stage 0, pick one) | ✓ (appendix only) | – | – | – | – | – |
| Part 2 / 2.2–2.3 Consent and split roles (Stage 1, 3, 4 prep) | ✓ | ✓ | ✓ | – | – | – |
| Part 2 / 2.4 Marketplace × wallet (v2) | – | – | ✓ | ✓ | ✓ | – |
| Part 2 / 2.5 Tiered access and provenance (Stage T / P)* | – | – | – | ✓ | – | ✓ |
Reading the tables¶
- publisher: the hands-on server, started with
docker compose up. §1.3–§1.4 (trading on the marketplace, v1) do not use it. The v1 stack also starts IPFS, and IPFS and the publisher both use port 8080, so they cannot run at the same time. - Blockchain: a local Hardhat chain plus deployed contracts. Required when the marketplace purchase is the entry point.
- MetaMask: signs / sends transactions on the local chain.
- SSI wallet: iw3ip-wallet (a fork of Sphereon Wallet) on a phone — receives and presents VCs.
- IPFS / storage (v1): used in v1. After a purchase, the data is placed in the storage server (simple-storage), and its location (URI) is encrypted and written to the chain. IPFS and PostgreSQL hold video metadata and back the search screen. v2 adds a lane that uses VCs.
- Camera path / HA path: in Part 1, HUSKYLENS2 and the USB webcam hand event files to
mediator-owner, so they need the Quickstart (run the stack) stack (Hardhat, storage server, IPFS, and so on). HA SSI Publisher sends data to the publisher. - Image proc. / LLM: OpenCV (Tier 2 blur), Ollama (LLaVA / moondream for VLM), and the LLM planner in Part 3.
Part 1: Basic — the core data path¶
Goals¶
- See where data is generated and where it ends up
- Carry out listing → purchase → delivery on the v1 marketplace path
1.1 Run it first — check the whole flow without hardware¶
The Home Assistant simulator lets you run the entire walkthrough without any IoT device. A good place to begin.
1.2 Capture data from a device¶
Build a path that pulls data off a camera or sensor. HUSKYLENS2 and the USB webcam hand event files to mediator-owner; HA SSI Publisher sends data to the publisher. Choose one that matches your hardware:
- Detect a person on an AI camera (HUSKYLENS2) — purpose-built AI camera
- Detect with a USB webcam (OpenCV) — generic USB camera + OpenCV
- Pull from Home Assistant (HA SSI Publisher) — Home Assistant integration
1.3 Trade on the marketplace (v1 lane)¶
The list → buy → receive flow. On delivery, the location (URI) of the data placed in the storage server (simple-storage) is encrypted and passed through the chain. This is the completion point of Basic (v1).
-
List: run a sample from §1.2 (Detect a person on an AI camera (HUSKYLENS2) or Detect with a USB webcam (OpenCV); mock mode is enough). Event files are written to
mediator-owner/raw_data/output. If you chose HA SSI Publisher in §1.2, run the sample from Detect with a USB webcam (OpenCV) in mock mode to list an item.mediator-ownerdetects each event file, registers it as merchandise, and prints the item's address.Product deployed: 0x948b3c65b89df0b4894abe91e6d02fe579834f8f for file 301_huskylens_1791551565.txt -
Buy: open the merchandise page (
http://localhost:5173/merchandise/<the address shown>), connect MetaMask (Account #2) with "Connect your wallet!" at the top right, press "Purchase!", and confirm in MetaMask. The page you land on afterwards shows an error because no publisher is running in v1; the purchase itself went through. Check it in themediator-buyerlog below. -
Receive: the seller-side
mediator-ownerdetects the purchase, encrypts the location of the data with the buyer's public key, and writes it to the chain. The buyer-sidemediator-buyerdecrypts it, fetches the data, and verifies the content.mediator-ownerterminal:Your Product is bought by 0x0000…93bc File uploaded successfully: cf701007aad74177b6ecaa8e4a63c931 Upload event sent successfully Verification is successful Withdraw successfulmediator-buyerterminal:You bought a product of 0x0000…79c8 Downloading file... File downloaded successfully Verification result: trueThe purchased event file is saved under
mediator-buyer/downloads.Verification result: truemeans the hash of the delivered data matches the value registered with the item; the seller is then paid (Withdraw successful).
The 5 items registered by step 2 of Quickstart (deployment) were not listed by mediator-owner. They can be purchased, but no data is delivered.
Detailed bring-up: Quickstart (run the stack).
If you go on to §1.4 (optional) after §1.3, keep the Quickstart stack running. Before you go on to Part 2, stop the Quickstart IPFS (docker compose down in the ipfs directory), because the publisher that Part 2 pages start uses the same port 8080. Also stop the Quickstart frontend (terminal 3, port 5173) with Ctrl+C. Step 6 of Hand a credential to the buyer's wallet (Bridge / Stage 5) in §2.4 starts iot-market-ui again on port 5173.
1.4 Open the marketplace and buy on a phone¶
This section is optional. You try it with MetaMask Mobile on a phone. It is not part of the Part 1 "Done when…" list.
Open the §1.3 marketplace screen in a phone browser and walk through a purchase.
Done when…¶
- You confirmed that the §1.2 data arrived: on the HA path it appears in
curl http://localhost:8080/platform/ingest(step 6 of HA SSI Publisher), and on the camera path it appears asProduct deployedinmediator-owner - Listing → purchase → delivery on the marketplace worked, and the data was saved under
mediator-buyer/downloads
Part 2: Feature Extensions — consent, conditional sharing, tiered access¶
Goals¶
- Understand why conditional sharing is needed instead of "show everything"
- Implement that conditional sharing with VCs and a wallet
- Vary what is shown by trust level with tiered access (Tier 3 / 2 / 1)
2.1 Event sharing — share inferences, not raw frames (Stage 0)¶
Send "person detected: yes" / "littering: yes" events instead of the raw video.
2.2 Add consent (Consent VC) (Stage 1)¶
Issue and present a "I consent to sharing for this purpose" VC.
2.3 Split read vs write roles¶
Use VCs to separate "read-only viewer" from "write-only service".
2.4 Marketplace × wallet (v2 lane)¶
Deliver the data after purchase with PurchaseViewerVC + ViewerToken instead of the encrypted URI (v1).
- Hand a credential to the buyer's wallet (Bridge / Stage 5) — stand up the bridge
- Read ServiceVC-written data with a PurchaseViewerVC (Stage 6) — full buy-to-view path
- Back the seller's identity (Seller VC / Stage 7) — seller-side VC
- Marketplace as a phone app (Stage A) — dedicated mobile app
2.5 Tiered access and provenance (Stage T / P)¶
Change what the user sees in steps, based on the user's DataUserVC. The first two pages use three tiers: Tier 3 (event, image, video), Tier 2 (event, image), and Tier 1 (event only; the decision is denied). The third page turns on the VLM extension and uses four tiers: Tier 3, Tier 2 (event, blurred image, description), Tier 1 (event, summary text), and Tier 0 (event only; the decision is denied).
On the first page you receive and present a PurchaseViewerVC the same way as Steps 7–8 of Hand a credential to the buyer's wallet (Bridge / Stage 5) in §2.4.
The later pages also cover structured data that describes the image content (a semantic intermediate representation) and rendering that changes by trust level (trust-aware rendering).
- Tier the response by trust (DataUserVC / Stage T)
- Deliver images and video with tiered access (DataUserVC / Stage T) — continues with §8–§11
- Tier by semantic level (VLM and semantic representation / Stage T) — continues with §12–§13
- Design background: Tiered access design spec (in the Design section)
- Prove where an image came from (C2PA / Stage P) — P0. Sign the images delivered with tiered access with C2PA provenance (no publisher or wallet needed)
- Connect provenance to the publisher and the chain (C2PA / Stage P, P1 and P2) — verify provenance at the publisher, sign the Tier 2 image, record a token on chain, and check what provenance each tier sees
- Trace a VLM summary back to the image (C2PA / Stage P, P3) — the publisher signs a summary card with the VLM's summary, and someone who receives only the text traces it to the capture and the token
Done when…¶
- A Consent / DataUserVC / PurchaseViewerVC lands in your phone wallet
- Changing
purposeflips sharing (/simulate/publish) or presentation (/verifier/request) between allow / deny, and changing the trust level changes what/platform/datareturns - The audit log records who looked at what, when, and for what purpose
Part 3: Intelligence Integration — let an AI act on requests¶
You can start Part 3 before finishing all of Part 2. §3.1 and §3.2 run with Docker, Python, and a USB webcam (§3.2 also works with a JPEG image instead of a camera). They do not use the Quickstart stack. §3.3 uses a sample event file and assumes either page of §2.1 (finishing Share detections, not raw frames makes the possible_littering example easier to follow). §3.4 assumes §3.3.
Goals¶
- Use a local AI model to enrich camera frames and distribute the derivatives over the platform
- An AI breaks a free-form request ("show me recent anomalies") into a plan
- Explain, configuration by configuration, what leaves the PC before the data reaches the AI
- That plan executes against sample event data and returns a response
- Check the whole flow end to end, up to the frontend demo
3.1 Enrich camera data with a local VLM¶
Analyze laptop + USB-camera frames with a local model and distribute the semantic data over the platform. A step-by-step exercise: read the structure → fill in the template → add a feature from scratch.
3.2 Protect camera images before handing them to AI¶
Hand the same camera image to AI in four ways (raw to the cloud, on the PC only, faces blurred before the cloud, text only to the cloud) and compare what left the PC and what the descriptions say. The cloud is replaced by a mock server.
3.3 Regional Safety Assistant¶
Loads a sample event file recording "when / where / what happened" (examples/phase3_events_park_safety.json) and answers free-form requests.
3.4 LLM Planner¶
The "request → plan → execute → UI" decomposition pattern.
- Let an AI plan the steps (LLM Planner)
- Design background: LLM Planner replacement spec (in the Design section)
Done when…¶
- You can compare and explain what left the PC in each of the four ways of handing the image to AI
- A free-form request decomposes into plan steps that execute
- Results show up in the frontend demo
planner_diagnosticslets you trace the decision
When a term is unfamiliar¶
See the mini-glossary in Environment Setup. It explains almost every term you'll encounter in one line.