Where AI meets blockchain, and smart contracts get a conversational upgrade.
OpenPhron is a powerful backend platform that bridges the gap between AI oracles and smart contract creation. Think of it as your AI-powered assistant for building blockchain contracts, but with a marketplace twist where you can discover, subscribe to, and leverage various AI oracles.
Ever wished you could just talk to an AI and have it generate smart contracts for you? That's exactly what OpenPhron does. It's not just another blockchain toolβit's a complete ecosystem where:
- π€ AI Oracles live in a marketplace, ready to be discovered and subscribed to
- π¬ Conversational Contract Creation lets you build smart contracts through natural language
- π Blockchain Integration seamlessly connects with Arbitrum Sepolia
- π API Management gives you full control over your integrations
- π Token-Based Subscriptions power the oracle economy
- Browse and discover AI oracles created by the community
- Create your own custom oracles
- Subscribe to oracles with token-based access
- Manage questions and interactions with oracles
- Chat-based contract creation: Start with an idea, refine through conversation
- AI-powered code generation: Uses OpenAI and Google Gemini to generate contract code
- Workflow management: Organize and track your contract development process
- Contract sharing: Share your contracts publicly or with specific access tokens
- Deployment tracking: Keep tabs on your deployed contracts
- Real-time event listening from blockchain contracts
- Oracle marketplace contract integration
- Signature verification for secure transactions
- Support for Arbitrum Sepolia network
- API key generation and management
- Token-based subscription system
- Daily token limits and subscription periods
- Admin controls for platform management
Built with modern TypeScript and a solid architecture:
- Runtime: Node.js with Express
- Language: TypeScript (strict mode enabled)
- Database: MongoDB with Mongoose
- Blockchain: Ethers.js v5.7.2
- AI Integration:
- OpenAI API
- Google Gemini AI
- Other: CORS, crypto-js, node-cron, UUID
Getting started is straightforward:
# Clone the repository
git clone https://github.com/idealbridgex/openphron-backend
# Navigate to the project
cd openphron-backend
# Install dependencies
npm installCreate a .env file in the root directory with the following variables:
# Database
DBNAME=your-db-name
# AI Services
GEMINI_KEY=your-gemini-api-key
# Get your key at: https://ai.google.dev/gemini-api/docs/api-key
# Blockchain
RPC_URL=your-arbitrum-sepolia-rpc-url
# Server
PORT=9001
# Token System
TOKEN_LIMIT=your-daily-token-limit
DAY_LIMIT=subscription-period-in-days
# OpenPhron Integration
OPENPHRON_UPDATEDATA_URL=your-update-data-url
OPENPHRON_UPDATEFEEDS_URL=your-update-feeds-urlIf you need to use a proxy:
PROXY_ENABLE=true
PROXY_HOST=your-proxy-host
PROXY_PASS=your-proxy-password
PROXY_USER=your-proxy-usernamenpm run devThis starts the server with ts-node for hot reloading during development.
# Build TypeScript to JavaScript
npm run build
# Start the production server
npm startnpm testThe API is organized into several main sections:
GET /api/contract- Get user contractsPOST /api/contract- Create new contract (init message)POST /api/contract/message- Send message to contractPOST /api/contract/share- Share a contractGET /api/contract/shared/:access_token- Get shared contractPOST /api/contract/deployed- Add deployed contractGET /api/contract/deployed- Get deployed contractsDELETE /api/contract/:_id- Delete contract
GET /api/workflow- Get user workflowsGET /api/workflow/:id- Get workflow by ID
GET /api/oracle- List all oraclesGET /api/oracle/:id- Get oracle by IDPOST /api/oracle- Create new oraclePOST /api/oracle/rename- Rename oracleDELETE /api/oracle/:id- Delete oracle
GET /api/question- List questionsGET /api/question/:id- Get question by IDGET /api/question/oracle/:oracleId- Get questions for oraclePOST /api/question- Create questionPOST /api/question/update- Update question
POST /api/subscribe- Subscribe to oracleGET /api/subscription/user- Get user subscriptionsGET /api/subscription/oracle/:oracleId- Get subscriptions for oracle
GET /api/token- Get user tokensPOST /api/token/reduce- Reduce tokensPOST /api/token/subscribe- Subscribe tokens
GET /api/key- Get API keysPOST /api/key- Create API keyDELETE /api/key/:apiKey- Delete API key
/api/admin/*- Admin routes (requires admin verification)
- Signature Verification: Most endpoints require wallet signature verification via
verifySignatureMiddleware - Admin Protection: Admin routes are protected with
verifyAdminmiddleware - CORS: Configured to allow cross-origin requests (adjust in production)
src/
βββ AImarketplace/ # AI Oracle marketplace logic
β βββ blockchain/ # Blockchain contract integration
β βββ controllers/ # Oracle, question, subscription controllers
β βββ models/ # Database models
β βββ service/ # Business logic
β βββ utils/ # Event handling utilities
βββ api/ # API key management
βββ contract/ # Smart contract creation & workflow
β βββ config/ # Workflow and AI pattern configurations
β βββ controllers/ # Contract, workflow, cost controllers
β βββ data-access/ # Database access layer
β βββ models/ # Contract models
β βββ services/ # Contract generation services
β βββ utils/ # AI integration (OpenAI, Gemini)
βββ admin/ # Admin functionality
βββ dbConnect/ # MongoDB connection
βββ middleware/ # Auth and verification middleware
βββ routers/ # Route definitions
Contributions are welcome! This project is licensed under the Apache License 2.0. Feel free to:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Built with β€οΈ for the blockchain and AI community. Special thanks to all the open-source libraries that make this possible.
Note: This is a backend service. You'll need a frontend application to interact with it, or use the API endpoints directly. Make sure to configure all environment variables before running the server.
Questions? Issues? Feel free to open an issue on GitHub!