Command-line interface documentation for BlockScore scripts and tools.
Automated environment setup for BlockScore.
Location: scripts/setup_blockscore_env.sh
Usage:
./scripts/setup_blockscore_env.shWhat it does:
- Creates Python virtual environments (AI models + backend)
- Installs Python dependencies from requirements.txt
- Installs Node.js dependencies (backend + frontend)
- Sets up project structure
Requirements: Python 3.8+, Node.js 16+, npm
Start all BlockScore services.
Location: scripts/run_blockscore.sh
Usage:
./scripts/run_blockscore.shServices started:
- Backend API (Port 5000)
- Web Frontend (Port 3000)
- AI Model Server (if configured)
Deploy smart contracts to blockchain network.
Location: scripts/smart_contract_deploy.sh
Usage:
./scripts/smart_contract_deploy.sh [network]Arguments:
| Argument | Description | Example |
|---|---|---|
network |
Target blockchain network | development, testnet, mainnet |
Examples:
# Deploy to local Ganache
./scripts/smart_contract_deploy.sh development
# Deploy to Polygon Mumbai testnet
./scripts/smart_contract_deploy.sh testnet
# Deploy to Polygon mainnet
./scripts/smart_contract_deploy.sh mainnetRestart specific BlockScore components.
Location: scripts/component_restart.sh
Usage:
./scripts/component_restart.sh [component]Components:
| Component | Description |
|---|---|
backend |
Restart Flask backend API |
frontend |
Restart React frontend |
ai_model |
Restart AI model server |
all |
Restart all components |
Examples:
# Restart backend only
./scripts/component_restart.sh backend
# Restart all services
./scripts/component_restart.sh allRun linters on entire codebase.
Location: scripts/lint-all.sh
Usage:
./scripts/lint-all.sh [--fix]Flags:
--fix: Automatically fix linting issues
What it checks:
- Python: Black, Flake8, isort
- JavaScript/TypeScript: ESLint, Prettier
- Solidity: Solhint
Example:
# Check for issues
./scripts/lint-all.sh
# Auto-fix issues
./scripts/lint-all.sh --fixComprehensive code quality analysis.
Location: scripts/code_quality_check.sh
Usage:
./scripts/code_quality_check.shChecks performed:
- Linting (syntax, style)
- Static analysis
- Security vulnerabilities
- Code complexity
- Test coverage
Compile contracts (fully offline, via the local solc npm package):
cd code/blockchain
npm run compileRun tests:
cd code/blockchain
npm testDeploy contracts:
cd code/blockchain
# Local development (deploys all 5 contracts and wires up their roles)
npm run deploy:local
# equivalent to: npx hardhat run scripts/deploy.js --network development
# A real network - first add a matching entry to hardhat.config.js's
# networks block (RPC url + account key), then:
npx hardhat run scripts/deploy.js --network mumbai
npx hardhat run scripts/deploy.js --network polygonConsole:
cd code/blockchain
npx hardhat console --network development// In hardhat console
const CreditScore = await ethers.getContractFactory("CreditScore");
const creditScore = await CreditScore.attach("<deployed address>");
// Add credit record
await creditScore.addCreditRecord(
"0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
1000,
"loan",
5,
);
// Get credit profile
const profile = await CreditScore.getCreditProfile(
"0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
);
console.log(profile);Initialize database:
cd code/backend
source venv/bin/activate
python -c "from app import create_app, db; app = create_app(); app.app_context().push(); db.create_all()"Create migration:
cd code/backend
alembic revision --autogenerate -m "Description of changes"Apply migrations:
cd code/backend
alembic upgrade headRollback migration:
cd code/backend
alembic downgrade -1cd code/backend
source venv/bin/activate
python app.pycd code/backend
source venv/bin/activate
gunicorn -w 4 -b 0.0.0.0:5000 app:appcd code/backend
source venv/bin/activate
pytest
pytest --cov=. --cov-report=htmlStart development server:
cd web-frontend
npm startBuild for production:
cd web-frontend
npm run buildRun tests:
cd web-frontend
npm testStart Metro bundler:
cd mobile-frontend
npm startRun on iOS:
cd mobile-frontend
npm run iosRun on Android:
cd mobile-frontend
npm run androidcd code/ai_models/training_scripts
source venv_ai/bin/activate
python train_model.pycd code/ai_models
source venv_ai/bin/activate
python api.py| Command | Arguments | Description | Example |
|---|---|---|---|
setup_blockscore_env.sh |
None | Setup development environment | ./scripts/setup_blockscore_env.sh |
run_blockscore.sh |
None | Start all services | ./scripts/run_blockscore.sh |
smart_contract_deploy.sh |
-n [network] [-v] |
Deploy smart contracts | ./scripts/smart_contract_deploy.sh -n test |
component_restart.sh |
[component] |
Restart specific component | ./scripts/component_restart.sh backend |
lint-all.sh |
[--fix] |
Run code linters | ./scripts/lint-all.sh --fix |
code_quality_check.sh |
None | Run quality checks | ./scripts/code_quality_check.sh |
hardhat compile |
None | Compile Solidity contracts | cd code/blockchain && npm run compile |
hardhat test |
None | Run contract tests | cd code/blockchain && npm test |
hardhat run scripts/deploy.js |
--network [name] |
Deploy contracts (all 5, with roles wired) | npx hardhat run scripts/deploy.js --network mumbai |
python app.py |
None | Start Flask backend | cd code/backend && python app.py |
npm start |
None | Start React frontend | cd web-frontend && npm start |
pytest |
[options] |
Run backend tests | cd code/backend && pytest |
# Start local blockchain
ganache-cli -p 8545
# Start backend (development mode)
cd code/backend && FLASK_ENV=development python app.py
# Start frontend (development mode)
cd web-frontend && npm start# Start backend (production mode)
cd code/backend && gunicorn -w 4 -b 0.0.0.0:5000 app:app
# Serve frontend build
cd web-frontend && npm run build
# Then serve with nginx or similar# Check if backend is running
curl http://localhost:5000/api/health
# Check if frontend is accessible
curl http://localhost:3000
# Check blockchain connection
curl -X POST http://localhost:8545 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'# Backend logs
tail -f code/backend/logs/blockscore.log
# Frontend logs (development)
# Check terminal where npm start is running
# Smart contract deployment logs
cat code/blockchain/deployment.log- API Reference - Explore API endpoints
- Configuration - Configure services
- Troubleshooting - Common issues
Need Help? Check the Troubleshooting Guide or GitHub Issues.