257 lines
6.1 KiB
Markdown
257 lines
6.1 KiB
Markdown
# Solace Bank Group Treasury Management DApp
|
|
|
|
A comprehensive Treasury Management DApp with Smart Wallet capabilities, multisig support, sub-accounts, and advanced 3D UI.
|
|
|
|
## Architecture
|
|
|
|
- **Frontend**: Next.js 14+ with TypeScript, Tailwind CSS, GSAP, and Three.js
|
|
- **Smart Contracts**: Solidity contracts using Hardhat
|
|
- **Backend**: TypeScript with Drizzle ORM and PostgreSQL
|
|
- **Blockchain**: Chain 138 (Custom Besu Network), Ethereum (mainnet and Sepolia testnet)
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
solace-bg-dubai/
|
|
├── contracts/ # Smart contracts
|
|
├── frontend/ # Next.js application
|
|
├── backend/ # Backend API and indexer
|
|
└── shared/ # Shared types and utilities
|
|
```
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Node.js >= 18
|
|
- PostgreSQL database
|
|
- Ethereum RPC endpoint (Alchemy/Infura)
|
|
|
|
### Installation
|
|
|
|
1. Install pnpm (if not already installed):
|
|
```bash
|
|
npm install -g pnpm
|
|
```
|
|
|
|
2. Install dependencies:
|
|
```bash
|
|
pnpm install
|
|
```
|
|
|
|
3. Set up environment variables:
|
|
- Copy `.env.example` files in each workspace
|
|
- Configure database, RPC URLs, and contract addresses
|
|
|
|
4. Set up database:
|
|
```bash
|
|
cd backend
|
|
pnpm run db:generate
|
|
pnpm run db:migrate
|
|
```
|
|
|
|
5. Deploy contracts:
|
|
```bash
|
|
cd contracts
|
|
pnpm run compile
|
|
pnpm run deploy:sepolia # or deploy:local
|
|
pnpm run deploy:chain138 # Deploy to Chain 138
|
|
```
|
|
|
|
6. Start development servers:
|
|
```bash
|
|
# Root directory
|
|
pnpm run dev
|
|
|
|
# Or individually:
|
|
cd frontend && pnpm run dev
|
|
cd backend && pnpm run dev
|
|
cd backend && pnpm run indexer:start
|
|
```
|
|
|
|
## Features
|
|
|
|
### Smart Wallet
|
|
- Multisig support (N-of-M threshold)
|
|
- Owner management
|
|
- Transaction proposals and approvals
|
|
- ERC-20 and native token transfers
|
|
|
|
### Sub-Accounts
|
|
- Create sub-wallets under main treasury
|
|
- Deterministic address generation
|
|
- Inherited signer configuration
|
|
|
|
### Banking Functions
|
|
- Receive deposits (with QR code)
|
|
- Send payments
|
|
- Internal transfers between accounts
|
|
- Approval management
|
|
|
|
### UI/UX
|
|
- 3D visualizations with Three.js
|
|
- Smooth animations with GSAP
|
|
- Parallax effects
|
|
- Responsive design
|
|
|
|
## Development
|
|
|
|
### Smart Contracts
|
|
```bash
|
|
cd contracts
|
|
pnpm run compile # Compile contracts
|
|
pnpm run test # Run tests
|
|
pnpm run coverage # Generate coverage report
|
|
```
|
|
|
|
### Frontend
|
|
```bash
|
|
cd frontend
|
|
pnpm run dev # Start dev server
|
|
pnpm run build # Build for production
|
|
pnpm run lint # Run linter
|
|
```
|
|
|
|
### Backend
|
|
```bash
|
|
cd backend
|
|
pnpm run dev # Start API server
|
|
pnpm run indexer:start # Start event indexer
|
|
pnpm run db:migrate # Run database migrations
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
### Frontend
|
|
- `NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID` - WalletConnect project ID
|
|
- `NEXT_PUBLIC_SEPOLIA_RPC_URL` - Sepolia RPC endpoint
|
|
- `NEXT_PUBLIC_TREASURY_WALLET_ADDRESS` - Deployed treasury wallet address
|
|
- `NEXT_PUBLIC_SUB_ACCOUNT_FACTORY_ADDRESS` - Deployed factory address
|
|
|
|
### Backend
|
|
- `DATABASE_URL` - PostgreSQL connection string
|
|
- `RPC_URL` - Ethereum RPC endpoint
|
|
- `CHAIN_ID` - Chain ID (1 for mainnet, 11155111 for Sepolia)
|
|
- `CONTRACT_ADDRESS` - Treasury wallet contract address
|
|
|
|
### Contracts
|
|
- `SEPOLIA_RPC_URL` - Sepolia RPC endpoint
|
|
- `MAINNET_RPC_URL` - Mainnet RPC endpoint
|
|
- `CHAIN138_RPC_URL` - Chain 138 RPC endpoint (default: http://192.168.11.250:8545)
|
|
- `PRIVATE_KEY` - Deployer private key
|
|
- `ETHERSCAN_API_KEY` - Etherscan API key for verification
|
|
|
|
## Chain 138 Deployment
|
|
|
|
This DApp is configured to work with Chain 138, a custom Besu blockchain network.
|
|
|
|
### Quick Setup
|
|
|
|
1. Configure Chain 138:
|
|
```bash
|
|
./scripts/setup-chain138.sh
|
|
```
|
|
|
|
2. Deploy contracts to Chain 138:
|
|
```bash
|
|
cd contracts
|
|
pnpm run deploy:chain138
|
|
```
|
|
|
|
3. Update environment files with deployed contract addresses
|
|
|
|
### Chain 138 Configuration
|
|
|
|
- **Chain ID**: 138
|
|
- **RPC Endpoints**:
|
|
- http://192.168.11.250:8545
|
|
- http://192.168.11.251:8545
|
|
- http://192.168.11.252:8545
|
|
- **WebSocket**: ws://192.168.11.250:8546
|
|
- **Network Type**: Custom Besu (QBFT consensus)
|
|
|
|
## Proxmox VE Deployment
|
|
|
|
The DApp can be deployed on Proxmox VE using LXC containers.
|
|
|
|
### Prerequisites
|
|
|
|
- Proxmox VE host with LXC support
|
|
- Ubuntu 22.04 LTS template available
|
|
- Network access to Chain 138 RPC nodes (192.168.11.250-252)
|
|
|
|
### Deployment Steps
|
|
|
|
1. **Configure deployment settings**:
|
|
```bash
|
|
cd deployment/proxmox
|
|
# Edit config/dapp.conf with your Proxmox settings
|
|
```
|
|
|
|
2. **Deploy all components**:
|
|
```bash
|
|
sudo ./deploy-dapp.sh
|
|
```
|
|
|
|
3. **Deploy individual components**:
|
|
```bash
|
|
sudo ./deploy-database.sh # PostgreSQL database
|
|
sudo ./deploy-backend.sh # Backend API
|
|
sudo ./deploy-indexer.sh # Event indexer
|
|
sudo ./deploy-frontend.sh # Frontend application
|
|
```
|
|
|
|
### Container Specifications
|
|
|
|
| Component | VMID | IP Address | Resources |
|
|
|-----------|------|------------|-----------|
|
|
| Frontend | 3000 | 192.168.11.60 | 2GB RAM, 2 CPU, 20GB disk |
|
|
| Backend | 3001 | 192.168.11.61 | 2GB RAM, 2 CPU, 20GB disk |
|
|
| Database | 3002 | 192.168.11.62 | 4GB RAM, 2 CPU, 50GB disk |
|
|
| Indexer | 3003 | 192.168.11.63 | 2GB RAM, 2 CPU, 30GB disk |
|
|
|
|
### Post-Deployment
|
|
|
|
1. **Deploy contracts to Chain 138** (if not already done)
|
|
2. **Copy environment files to containers**:
|
|
```bash
|
|
pct push 3000 frontend/.env.production /opt/solace-frontend/.env.production
|
|
pct push 3001 backend/.env /opt/solace-backend/.env
|
|
pct push 3003 backend/.env.indexer /opt/solace-indexer/.env.indexer
|
|
```
|
|
|
|
3. **Run database migrations**:
|
|
```bash
|
|
pct exec 3001 -- bash -c 'cd /opt/solace-backend && pnpm run db:migrate'
|
|
```
|
|
|
|
4. **Start services**:
|
|
```bash
|
|
pct exec 3001 -- systemctl start solace-backend
|
|
pct exec 3003 -- systemctl start solace-indexer
|
|
pct exec 3000 -- systemctl start solace-frontend
|
|
```
|
|
|
|
5. **Check service status**:
|
|
```bash
|
|
pct exec 3000 -- systemctl status solace-frontend
|
|
pct exec 3001 -- systemctl status solace-backend
|
|
pct exec 3003 -- systemctl status solace-indexer
|
|
```
|
|
|
|
### Nginx Reverse Proxy
|
|
|
|
For public access, set up Nginx as a reverse proxy. A template configuration is available at:
|
|
- `deployment/proxmox/templates/nginx.conf`
|
|
|
|
### Documentation
|
|
|
|
For detailed deployment instructions, see:
|
|
- `deployment/proxmox/README.md` (if created)
|
|
- `scripts/setup-chain138.sh` - Chain 138 configuration helper
|
|
|
|
## License
|
|
|
|
Private - Solace Bank Group PLC (Dubai)
|
|
|