Disclaimer: This is an MVP for educational/research purposes. Not intended for production use without proper security audits and compliance reviews.
AutoRWA is an innovative Real-World Asset (RWA) tokenization platform that combines blockchain technology with machine learning to enable dynamic vehicle valuation and real-time risk management. The protocol tokenizes vehicle assets as ERC-721 NFTs with AI-powered price updates via an Oracle bridge.
- π€ AI-Powered Valuation: Machine learning models provide real-time vehicle price predictions
- βοΈ Blockchain Integration: ERC-721 smart contracts with Oracle-based data updates
- π Risk Scoring: Automated risk assessment using Random Forest models
- π Oracle Bridge: Automated synchronization between ML predictions and blockchain state
- π RESTful API: FastAPI-based service for ML predictions and vehicle data
graph TB
subgraph "ML Engine"
VE[Valuation Model<br/>Linear Regression<br/>RΒ² = 0.9455]
RS[Risk Scoring<br/>Random Forest<br/>RΒ² = 0.9945]
FE[Feature Engineering<br/>Preprocessing Pipeline]
end
subgraph "API Layer"
API[FastAPI Gateway<br/>REST Endpoints<br/>/predict, /health]
end
subgraph "Oracle Bridge"
OB[Oracle Bridge Service<br/>Web3 Integration<br/>Transaction Signing]
end
subgraph "Blockchain Layer"
SC[VehicleAsset.sol<br/>ERC-721 Contract<br/>Access Control]
BC[(Ethereum/Polygon<br/>Blockchain)]
end
FE --> VE
FE --> RS
VE --> API
RS --> API
API -->|HTTP POST| OB
OB -->|updateAssetData()| SC
SC -->|Events| BC
BC -->|State Updates| OB
style VE fill:#8bc34a
style RS fill:#ffc107
style API fill:#ff9800
style OB fill:#2196f3
style SC fill:#4caf50
- ML Prediction: Vehicle data β Feature Engineering β ML Models β Price & Risk Score
- API Service: FastAPI serves predictions via REST endpoints
- Oracle Bridge: Monitors ML API and updates blockchain via signed transactions
- Smart Contract: Stores vehicle data on-chain with role-based access control
AutoRWA/
βββ contracts/ # Smart Contracts (Solidity)
β βββ src/
β β βββ VehicleAsset.sol # ERC-721 contract with Oracle integration
β βββ test/
β β βββ VehicleAsset.t.sol # Foundry test suite (20+ tests)
β βββ script/
β β βββ Deploy.s.sol # Deployment scripts
β βββ foundry.toml # Foundry configuration
β
βββ backend/ # Backend Services
β βββ main.py # FastAPI application (800+ lines)
β βββ bridge.py # Oracle Bridge service (700+ lines)
β βββ README.md # Backend documentation
β
βββ ml_models/ # Machine Learning Engine
β βββ valuation_engine.py # ML pipeline and training
β βββ trained_models/ # Serialized models (.joblib)
β βββ test_models.py # Model validation tests
β
βββ data/ # Datasets
β βββ simulation/ # Synthetic vehicle data
β
βββ scripts/ # Utility scripts
β βββ demo_full_system.py # End-to-end demonstration
β
βββ .env.example # Environment variables template
βββ requirements.txt # Python dependencies
βββ .gitignore # Git ignore rules
βββ README.md # This file
- Python 3.10+ (recommended: 3.11 or 3.12)
- Foundry (for smart contract development and testing)
- Node.js (optional, for Foundry installation)
-
Clone the repository
git clone https://github.com/yourusername/AutoRWA.git cd AutoRWA -
Install Foundry (if not already installed)
# Linux/macOS curl -L https://foundry.paradigm.xyz | bash foundryup # Windows (PowerShell as Administrator) # Install Rust first: https://rustup.rs/ # Then install Foundry via cargo cargo install foundry-cli foundryup foundryup
-
Install Python dependencies
pip install -r requirements.txt
-
Set up environment variables
cp .env.example .env # Edit .env and add your configuration: # - PRIVATE_KEY_ORACLE: Your Ethereum private key (for Oracle) # - RPC_URL: Blockchain RPC endpoint # - CONTRACT_ADDRESS: Deployed contract address (after deployment)
-
Install Foundry dependencies (for smart contracts)
cd contracts forge install
-
Start the ML API
cd backend python main.py # API will be available at http://localhost:8000
-
Deploy Smart Contract (local development)
# Start local blockchain (Anvil) anvil # In another terminal, deploy contract cd contracts forge script script/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast
-
Start Oracle Bridge
cd backend python bridge.py # Bridge will monitor ML API and update blockchain
Smart Contract Tests:
cd contracts
forge test -vvBackend/ML Tests:
# Ensure API is running first
pytest test_api.py -vCreate a .env file based on .env.example:
# Blockchain Configuration
RPC_URL="http://127.0.0.1:8545"
CHAIN_ID=31337
PRIVATE_KEY_ORACLE="" # Must be set - no default for security
CONTRACT_ADDRESS="" # Set after deployment
# ML API Configuration
ML_API_URL="http://localhost:8000"
# Oracle Configuration
UPDATE_INTERVAL_SECONDS=10
MAX_GAS_PRICE_GWEI=30
GAS_LIMIT=500000.env file. The .gitignore is configured to exclude it.
- Algorithm: Linear Regression
- Performance: RΒ² = 0.9455
- Features: Brand, Year, Kilometers, Accidents
- Output: Estimated price in USD
- Algorithm: Random Forest
- Performance: RΒ² = 0.9945
- Output: Risk score (0-100)
To train new models:
cd ml_models
python valuation_engine.pyModels will be saved to ml_models/trained_models/.
- β Access Control (OpenZeppelin)
- β ReentrancyGuard protection
- β Pausable emergency circuit breaker
- β Input validation and bounds checking
- β Environment variables for sensitive data
- β No hardcoded private keys
- β Input validation with Pydantic
- β Error handling and logging
- Smart Contracts: See
contracts/README.md - Backend API: See
backend/README.md - Oracle Bridge: See
backend/ORACLE_README.md
The project includes comprehensive test suites:
-
Smart Contracts: 20+ Foundry tests covering:
- Admin minting functionality
- Oracle update operations
- Access control and security
- Edge cases and validation
-
Backend: Integration tests for API endpoints and ML predictions
- Blockchain: Solidity 0.8.20, Foundry, OpenZeppelin
- Backend: Python 3.10+, FastAPI, Web3.py
- ML: Scikit-learn, Pandas, NumPy, Joblib
- Database: SQLite (MVP)
This project is licensed under the MIT License.
Contributions are welcome! Please read the contributing guidelines and code of conduct before submitting PRs.
This is an MVP for educational/research purposes.
- Not audited for production use
- Not intended for handling real funds without proper security reviews
- Models trained on synthetic data - not validated on real-world datasets
- Use at your own risk
For questions or support, please open an issue on GitHub.
Version: 1.0.0
Last Updated: January 2026