AI-powered security layer for Cronos blockchain
Cronos Shield is a comprehensive security and monetization platform for AI agents operating on the Cronos blockchain. It provides real-time risk analysis, protected vaults, CEX-DEX price validation, and full observability of AI decision-making processes.
- Overview
- Features
- Architecture
- Quick Start
- Project Structure
- API Documentation
- Smart Contracts
- Development
- Contributing
- License
Cronos Shield addresses the critical need for security and transparency when AI agents interact with blockchain protocols. It provides:
- Risk Oracle: Real-time risk scoring for smart contracts with cryptographic proof
- Shielded Vaults: Protected vaults with programmable circuit breakers
- CEX-DEX Synergy: Price divergence detection between centralized and decentralized exchanges
- Observability Dashboard: Complete visibility into AI decision-making processes
All services are monetized using the x402 payment protocol, enabling native internet micropayments for AI services.
- Real-time risk scoring (0-100 scale)
- Cryptographic Proof of Risk signatures
- On-chain verification support
- Liquidity and contract safety analysis
- x402 payment-protected API
- Protected deposits with risk-based transaction blocking
- Programmable circuit breakers
- Integration with Risk Oracle
- Emergency withdrawal capabilities
- Real-time price divergence detection
- Arbitrage opportunity identification
- Risk-based transaction blocking
- Integration with Crypto.com Exchange and VVS Finance
- Real-time metrics and KPIs
- Decision log with human-readable translations
- Blocked transactions tracking
- Complete audit trail
cronos-shield/
βββ backend/ # Unified Express.js API
βββ frontend/ # React + Vite + Tailwind CSS
βββ contracts/ # Solidity smart contracts
βββ ai/ # ML/AI models (preview)
βββ clients/ # Test clients
βββ docs/ # Documentation
- Backend: Node.js, TypeScript, Express.js
- Frontend: React, TypeScript, Vite, Tailwind CSS
- Blockchain: Solidity, Hardhat, Ethers.js
- Payment: x402 Protocol, @crypto.com/facilitator-client
- Network: Cronos EVM (Testnet/Mainnet)
- Node.js 18+ and npm/pnpm
- MetaMask or compatible wallet
- Cronos Testnet configured in wallet
- devUSDC.e tokens for x402 payments
cd cronos-shield
pnpm installcd backend
cp .env.example .env
# Edit .env with your configuration
pnpm install
pnpm devcd frontend
cp .env.example .env
pnpm install
pnpm dev- Frontend: http://localhost:5173
- Backend API: http://localhost:3000
- Swagger Docs: http://localhost:3000/api-doc
- Redoc Docs: http://localhost:3000/docs
cronos-shield/
βββ backend/
β βββ src/
β β βββ controllers/ # Request handlers
β β βββ services/ # Business logic
β β β βββ risk/ # Risk Oracle service
β β β βββ divergence/ # CEX-DEX service
β β β βββ observability/ # Logging & metrics
β β βββ routes/ # API routes
β β βββ lib/
β β β βββ x402/ # x402 payment middleware
β β β βββ utils/ # Utilities
β β βββ types/ # TypeScript types
β βββ package.json
β
βββ frontend/
β βββ src/
β β βββ components/ # React components
β β β βββ dashboard/ # Observability components
β β β βββ risk/ # Risk Oracle UI
β β β βββ divergence/ # CEX-DEX UI
β β β βββ common/ # Shared components
β β βββ pages/ # Page components
β β βββ lib/ # Utilities (API, wallet)
β β βββ hooks/ # React hooks
β β βββ types/ # TypeScript types
β βββ package.json
β
βββ contracts/
β βββ contracts/ # Solidity contracts
β βββ scripts/ # Deployment scripts
β βββ test/ # Contract tests
β βββ hardhat.config.ts
β
βββ docs/ # Additional documentation
π Complete Developer Documentation
Includes:
- Quick start guide
- x402 payment flow
- Complete API reference
- SDK integration examples
- Error handling
- Best practices
Production: https://cronos-shield-backend-production.up.railway.app
Local: http://localhost:3000/api
- Swagger UI (Interactive Testing): http://localhost:3000/api-doc
- Redoc (Visual Documentation): http://localhost:3000/docs
- Postman Collection:
postman/Cronos-Shield-API.postman_collection.json
GET /risk/risk-analysis?contract=0x...- Analyze contract risk (x402)POST /risk/pay- Settle x402 payment
GET /divergence/divergence?token=CRO- Analyze price divergence (x402)POST /divergence/pay- Settle x402 payment
GET /observability/metrics- Get system metricsGET /observability/logs- Get decision logsPOST /observability/logs- Add log entryGET /observability/blocked-transactions- Get blocked transactions
Full API documentation is available at:
- Swagger UI: http://localhost:3000/api-doc
- Redoc: http://localhost:3000/docs
Stores and verifies risk analysis results on-chain.
Functions:
storeResult()- Store risk analysis resultverifyProof()- Verify Proof of Risk signaturegetResult()- Retrieve stored result
Protected vault with risk-based transaction blocking.
Functions:
deposit()- Deposit native tokenswithdraw()- Withdraw tokensexecuteWithRiskCheck()- Execute transaction with risk validation
cd backend
pnpm dev # Development server with hot reload
pnpm build # Build for production
pnpm start # Run production buildcd frontend
pnpm dev # Development server
pnpm build # Build for production
pnpm preview # Preview production buildcd contracts
pnpm compile # Compile contracts
pnpm test # Run tests
pnpm deploy # Deploy to networkNODE_ENV=development
PORT=3000
NETWORK=cronos-testnet
RPC_URL=https://evm-t3.cronos.org
CHAIN_ID=338
MERCHANT_ADDRESS=0x...
PRIVATE_KEY=0x...
PRICE_BASE_UNITS=1000000
RISK_ORACLE_CONTRACT_ADDRESS=0x...
DEX_ROUTER_ADDRESS=0x...
# CEX-DEX Integration (Optional - uses mock data if not set)
CRYPTO_COM_API_URL=https://api.crypto.com/v2
CRYPTO_COM_API_KEY=your_api_key_here
CRO_TOKEN_ADDRESS=0x... # Optional: override token addresses
USDC_TOKEN_ADDRESS=0x...
USDT_TOKEN_ADDRESS=0x...
FRONTEND_URL=http://localhost:5173Note: For production setup, see Production Guide
VITE_BACKEND_URL=http://localhost:3000
VITE_NETWORK=cronos-testnet
VITE_RPC_URL=https://evm-t3.cronos.org
VITE_CHAIN_ID=338cd backend
pnpm testcd frontend
pnpm testcd contracts
pnpm test- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
We follow Conventional Commits:
feat:New featurefix:Bug fixdocs:Documentation changesstyle:Code style changesrefactor:Code refactoringtest:Test changeschore:Build process or auxiliary tool changes
MIT License - see LICENSE file for details
Built for the Cronos x402 Paytech Hackathon
Note: This is a Proof of Concept (POC) implementation. For production use, additional security audits and optimizations are recommended.