Skip to content

oness12/genlayer-ai-dao-risk-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenLayer AI DAO Risk Analyzer

Minimal GenLayer demo app for AI-powered DAO proposal risk analysis with a Python intelligent contract, an Express API, and a simple frontend.

GenLayer AI DAO Risk Analyzer preview

Live demo

Open the deployed app here:

https://genlayer-ai-dao-risk-analyzer.vercel.app/

Overview

This project shows how a GenLayer intelligent contract can analyze DAO governance proposals and return an AI-generated risk assessment.

What the app does

  • 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 as Low, Medium, or High risk and returns a short explanation.

Project structure

.
|-- 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

Prerequisites

  • Node.js 18+
  • A running GenLayer environment such as localnet or studionet
  • A deployed copy of the Python contract

Setup

  1. Install dependencies:

    npm install
  2. Copy the environment file and fill in the values:

    copy .env.example .env
  3. Set these variables in .env:

  • GENLAYER_MOCK_MODE: set to true to use the built-in local demo analyzer instead of a live contract
  • GENLAYER_NETWORK: for example localnet
  • GENLAYER_RPC_URL: for example http://localhost:4000/api
  • GENLAYER_CONTRACT_ADDRESS: the deployed contract address
  • GENLAYER_PRIVATE_KEY: only required if you want to deploy from the script or enable auto-deploy

Deploy the contract

If you already deployed the contract elsewhere, just set GENLAYER_CONTRACT_ADDRESS in .env.

To deploy this contract from the project:

npm run deploy:contract

The script prints the contract address. Copy that value into .env as GENLAYER_CONTRACT_ADDRESS.

Run locally

npm start

For 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.

Deploy on Vercel

This repo is Vercel-compatible:

  • Files in public/ are served as the frontend
  • api/health.js and api/analyze.js are deployed as Node.js Vercel Functions
  • vercel.json increases the analysis function timeout and includes the Python contract source when auto-deploy is enabled

Recommended Vercel environment variables:

  • GENLAYER_MOCK_MODE=true for a UI-only demo deployment
  • or set GENLAYER_RPC_URL, GENLAYER_CONTRACT_ADDRESS, and any other GenLayer variables for live contract calls

How the analysis flow works

  1. The browser posts proposal text to POST /api/analyze.
  2. The Express server calls the deployed GenLayer contract method analyze_proposal.
  3. The intelligent contract prompts an LLM and returns JSON with risk_level and explanation.
  4. The backend reshapes the response into { riskLevel, explanation }.
  5. The frontend renders the result.

Example response

Risk Level: Medium
Explanation:
Large treasury transfer without clear ROI.

Notes

  • 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=true can 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.

About

Minimal GenLayer demo app for AI-powered DAO proposal risk analysis using intelligent contracts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors