Minimal GenLayer demo app for AI-powered DAO proposal risk analysis with a Python intelligent contract, an Express API, and a simple frontend.
Open the deployed app here:
https://genlayer-ai-dao-risk-analyzer.vercel.app/
This project shows how a GenLayer intelligent contract can analyze DAO governance proposals and return an AI-generated risk assessment.
- The frontend provides a textarea for a DAO proposal and an Analyze Risk button.
- The Express backend receives the proposal text and calls a deployed GenLayer intelligent contract.
- The Python contract uses an LLM through
gl.nondet.exec_prompt(...)to classify the proposal asLow,Medium, orHighrisk and returns a short explanation.
.
|-- contracts/
| `-- dao_risk_analyzer.py
|-- public/
| |-- app.js
| |-- index.html
| `-- styles.css
|-- scripts/
| `-- deploy-contract.js
|-- server/
| |-- genlayerService.js
| `-- index.js
|-- .env.example
|-- package.json
`-- README.md
- Node.js 18+
- A running GenLayer environment such as
localnetorstudionet - A deployed copy of the Python contract
-
Install dependencies:
npm install
-
Copy the environment file and fill in the values:
copy .env.example .env
-
Set these variables in
.env:
GENLAYER_MOCK_MODE: set totrueto use the built-in local demo analyzer instead of a live contractGENLAYER_NETWORK: for examplelocalnetGENLAYER_RPC_URL: for examplehttp://localhost:4000/apiGENLAYER_CONTRACT_ADDRESS: the deployed contract addressGENLAYER_PRIVATE_KEY: only required if you want to deploy from the script or enable auto-deploy
If you already deployed the contract elsewhere, just set GENLAYER_CONTRACT_ADDRESS in .env.
To deploy this contract from the project:
npm run deploy:contractThe script prints the contract address. Copy that value into .env as GENLAYER_CONTRACT_ADDRESS.
npm startFor local development, open http://localhost:3000 in your browser.
If you start the app without any GenLayer credentials, it automatically falls back to a local demo analyzer so the UI is still previewable.
This repo is Vercel-compatible:
- Files in
public/are served as the frontend api/health.jsandapi/analyze.jsare deployed as Node.js Vercel Functionsvercel.jsonincreases the analysis function timeout and includes the Python contract source when auto-deploy is enabled
Recommended Vercel environment variables:
GENLAYER_MOCK_MODE=truefor a UI-only demo deployment- or set
GENLAYER_RPC_URL,GENLAYER_CONTRACT_ADDRESS, and any other GenLayer variables for live contract calls
- The browser posts proposal text to
POST /api/analyze. - The Express server calls the deployed GenLayer contract method
analyze_proposal. - The intelligent contract prompts an LLM and returns JSON with
risk_levelandexplanation. - The backend reshapes the response into
{ riskLevel, explanation }. - The frontend renders the result.
Risk Level: Medium
Explanation:
Large treasury transfer without clear ROI.
- This demo keeps the UI intentionally simple.
- The contract is stateless, so each request returns an analysis directly instead of storing it on-chain.
GENLAYER_AUTO_DEPLOY=truecan be used with a private key if you want the server to deploy the contract automatically on first request.- When GenLayer is not configured, the backend returns a deterministic mock analysis so the preview works without a live node.