A Rust canister and Vite/React frontend deployed with the modern icp CLI.
One person signs in with Internet Identity and creates a proposal, which mints a shareable invite link. The other opens the link, signs in, and accepts. Both principals are recorded on-chain, in stable memory, and survive upgrades.
- Invite links. The proposer never needs to know the other person's
Principal ID — nobody knows their own. Codes are 10 Crockford base32
characters (50 bits from
raw_rand), single-use, and expire. Optionally pinned to one principal. - Many couples per canister. Keyed by an incrementing relationship id with index maps for active, outgoing and inbox lookups.
- Photos on-chain. A first photo plus an anniversary timeline, stored in stable memory, compressed client-side, chunked at 256 KiB, and hashed so the browser can verify what it reassembles.
- Anniversary countdown, in-app only. No timers, no outcalls, no push —
everything derives from
accepted_aton the client. - Soulbound keepsakes. Milestone photos can be minted as ICRC-7 tokens held by both partners. Transfers always fail; minting is irreversible and makes that one photo publicly servable.
Three decisions the code depends on, each documented at length in the module that implements it:
memory.rsowns a permanentMemoryIdtable. Renumbering an id after data exists silently reinterprets another map's bytes. There is deliberately nopre_upgrade.- Photos are served by authenticated query, not
http_request. The boundary node callshttp_requestanonymously, so it cannot authorise anyone. Only photos explicitly minted as keepsakes are reachable that way, and those are certified (serve.rs). - Stored records need a decode fallback when they gain a field. Candid
cannot read an old record into a struct with a new non-
optfield, and the config cell is decoded duringthread_localsetup — beforepost_upgradecould intervene. SeeConfigV1intypes.rs.
cargo test # backend unit tests
npm test --workspace Relationship-Smart-Contract-ICP-frontend
./scripts/did.sh --check # .did matches the wasmscripts/did.sh regenerates relationship_backend.did from the compiled wasm.
The .did is checked in because the frontend's bindgen plugin reads it, so it
can drift from export_candid!() — run the check in CI.
-
Node.js 22 or later
-
Rust with
wasm32-unknown-unknowninstalled -
icpCLI andic-wasm:npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm rustup target add wasm32-unknown-unknown
Install JavaScript dependencies, start this project's local network, then deploy:
npm ci
icp network start -d
icp deployThe deployed frontend is available at:
http://<frontend-canister-id>.localhost:8000
Use icp canister status relationship_frontend -i to print the local frontend canister ID. The icp network status --json command reports the active local gateway URL if the port is configured differently.
For frontend-only development, deploy the backend first, then run Vite:
icp deploy relationship_backend
npm startThe Vite configuration obtains the local network URL, root key, and backend canister ID from icp; it exposes them to the app through the same ic_env cookie used by the asset canister in deployed environments.
Deploy the full project to the configured local environment:
icp deployTo deploy the existing mainnet canisters, first select a funded named identity, then deploy to the ic environment:
icp identities list
icp identity default <identity-name>
icp deploy -e icThe mainnet canister mappings are tracked in .icp/data/mappings/ic.ids.json. Keep that file under version control.
icp deploy refuses when a returned Candid variant gains cases, which this
backend's Err type does as features land. The JS client handles unknown error
kinds with a generic message, so pass --yes once you have read the diff.
The canister deployed before this overhaul kept its state in the Wasm heap with
no pre_upgrade. No code in the new build can recover it — the hook that
would have to run lives in the old wasm, which doesn't have one. Read the
values off the live canister first:
icp canister call relationship_backend get_status --query -e ic
icp canister snapshot create relationship_backend -e icRecord accepted_time (nanoseconds) and accepted_by. The proposer was never
stored, so supply your own principal. Then deploy and re-seed:
icp deploy -e ic --yes
icp canister call relationship_backend admin_import_legacy \
'(record { proposer = principal "<you>"; recipient = principal "<them>"; \
accepted_at = <ns>; message = "..."; title = "..." })' -e icadmin_import_legacy is controller-only and runs once. Verify with
get_my_state from both principals, then delete the snapshot — snapshots cost
storage.
The deprecated get_status shim keeps the currently-deployed frontend build
working in the window between the backend and frontend deploys. Drop it once
the new asset build is live everywhere.
icp build
icp project show
icp canister status relationship_backend
icp network stop