Repository: https://github.com/UnityNodes/ai_travel_assistant
- An AI-powered intelligent contract on GenLayer that helps plan trips.
- Stores user preferences and on-chain travel history.
- Uses deterministic logic to ensure validator consensus.
- Request a trip with budget, destination, dates, and preferences.
- Deterministic recommendations to avoid NO_MAJORITY.
- Read views for history length and serialized history JSON.
- Contract: [travel_assistant.py]
- Deploy script: [deployScript.ts]
- Demo runner: [run.ts]
- Node.js 18+
- npm
- TypeScript and ts-node
- genlayer-js
- GenLayer Localnet or Studio access
npm install
npm i -D typescript ts-nodenpx genlayer up --numValidators 5
# If consensus issues occur:
npx genlayer up --reset-db --reset-validators --numValidators 5npx ts-node deploy/deployScript.ts
# Save the returned contract addressnpx ts-node deploy/run.ts 1500 "Paris" "2026-05-01 to 2026-05-07" "Cheap flights"Expected output:
- Transaction status: FINALIZED
- Sender address
- History length for the sender
- Profile (preferences) used for the request
- Storage:
- profiles: TreeMap[Address, str]
- histories: TreeMap[Address, DynArray[TravelOption]]
- Determinism:
_fetch_and_analyzereturns static recommendations to preserve consensus. - Views:
get_history_len(user: str) -> intget_history(user: str) -> str(JSON array string)
- Least Privilege: use temporary accounts with minimal permissions.
- Input Validation: sanitize destination/dates/preferences at the client/API layer.
- Deterministic Logic: avoid randomness and external I/O in the contract.
- Secrets: never commit private keys; use env vars or a secure vault.
- OWASP: use TLS for Studio; pin dependency versions; update regularly.
- Monitoring: log transaction hashes and statuses; avoid PII.
- Incident Response: reset validators, verify logic, redeploy on divergence.
- NO_MAJORITY: reset validators and ensure deterministic
_fetch_and_analyze. - “running contract failed”: ensure
get_historyreturns a JSON string. - Windows paths: use absolute paths and adequate Node.js permissions.
- Receipt delays: increase wait intervals and retry counts in the client.