Complete deployment and setup guide for the migrated Paramify dApp on Internet Computer Protocol.
# Using nvm (recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 18
nvm use 18
# Verify installation
node --version # Should show v18.x.x
npm --version # Should show 9.x.x or higher# Install Rust and Cargo
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
# Add WebAssembly target
rustup target add wasm32-unknown-unknown
# Verify installation
rustc --version # Should show 1.70.0 or higher
cargo --version# Install DFX
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
# Verify installation
dfx --version # Should show 0.16.1 or higher# Install candid-extractor for Rust canisters
cargo install candid-extractor
# Install ic-wasm for optimization
cargo install ic-wasm
# Install vessel for Motoko package management (optional)
npm install -g vessel# Clone the repository
git clone https://github.com/your-repo/paramify-icp.git
cd paramify-icp
# Checkout ICP migration branch
git checkout icp-migration
# Install npm dependencies
npm install
# Build Rust canisters
cd src/canisters/oracle
cargo build --target wasm32-unknown-unknown --release
cd ../../..# Make deployment script executable
chmod +x scripts/deploy-local.sh
# Run automated deployment (deploys all canisters and initializes them)
./scripts/deploy-local.sh
# The script will:
# 1. Start local ICP replica
# 2. Deploy ICRC-1 ledger
# 3. Deploy insurance canister
# 4. Deploy oracle canister
# 5. Deploy payments canister
# 6. Deploy frontend
# 7. Initialize all canisters with proper configuration
# 8. Output canister IDs and URLsAfter deployment, access the application at:
http://localhost:4943/?canisterId=<frontend-canister-id>
The deployment script will output the exact URL.
# Start the local Internet Computer replica
dfx start --clean
# In a new terminal, continue with the following steps# Create all canisters without deploying
dfx canister create --all# Deploy the ledger for payment tokens
dfx deploy icrc1_ledger --argument "(variant { Init = record {
token_symbol = \"USDC\";
token_name = \"USD Coin\";
minting_account = record { owner = principal \"$(dfx identity get-principal)\" };
transfer_fee = 10_000;
metadata = vec {};
initial_balances = vec {
record {
record { owner = principal \"$(dfx identity get-principal)\" };
1_000_000_000_000
}
};
archive_options = record {
num_blocks_to_archive = 1000;
trigger_threshold = 2000;
controller_id = principal \"$(dfx identity get-principal)\"
};
}})"# Build all canisters
dfx build
# For production build with optimization
dfx build --network ic# Deploy insurance canister
dfx deploy insurance
# Deploy oracle canister
dfx deploy oracle
# Deploy payments canister
dfx deploy payments# Get canister IDs
LEDGER_ID=$(dfx canister id icrc1_ledger)
ORACLE_ID=$(dfx canister id oracle)
PAYMENTS_ID=$(dfx canister id payments)
INSURANCE_ID=$(dfx canister id insurance)
# Initialize insurance canister
dfx canister call insurance initialize "(record {
oracle_principal = principal \"$ORACLE_ID\";
payments_principal = principal \"$PAYMENTS_ID\";
treasury_principal = principal \"$(dfx identity get-principal)\";
base_premium_rate = 1000;
max_coverage = 1000000;
min_coverage = 1000;
payout_period_days = 30
})"
# Initialize payments canister
dfx canister call payments initialize "(record {
ledger_principal = principal \"$LEDGER_ID\";
insurance_principal = principal \"$INSURANCE_ID\";
treasury_principal = principal \"$(dfx identity get-principal)\"
})"
# Initialize oracle canister
dfx canister call oracle initialize "{
\"insurance_principal\": \"$INSURANCE_ID\",
\"usgs_site_id\": \"01646500\",
\"update_interval_seconds\": 3600
}"# Build frontend
npm run build
# Deploy frontend canister
dfx deploy frontend
# Get frontend URL
echo "Frontend URL: http://localhost:4943/?canisterId=$(dfx canister id frontend)"# Run Motoko tests
npm run test:motoko
# Run Rust tests
cd src/canisters/oracle
cargo test
cd ../../..# Run integration tests
npm run test:integration
# Test specific canister functions
dfx canister call insurance get_all_policies
dfx canister call oracle get_latest_data
dfx canister call payments get_pool_balance-
Policy Purchase
dfx canister call insurance purchase_policy "(record { coverage_amount = 10000; location = \"Washington, DC\"; duration_days = 30; flood_threshold = 1500 })"
-
Oracle Data Update
dfx canister call oracle fetch_flood_data dfx canister call oracle get_latest_data
-
Payment Processing
dfx canister call payments get_pool_balance
-
Automatic Payout Check
dfx canister call insurance check_payouts
├── Insurance Canister (Motoko)
│ ├── Policy Management
│ ├── Payout Logic
│ └── Threshold Monitoring
│
├── Oracle Canister (Rust)
│ ├── USGS Data Fetching
│ ├── HTTPS Outcalls
│ └── Data Transformation
│
├── Payments Canister (Motoko)
│ ├── ICRC-1 Integration
│ ├── Pool Management
│ └── Escrow Services
│
└── Frontend Canister
├── React Application
├── Agent-js Integration
└── Internet Identity
- User purchases policy through frontend
- Insurance canister calculates premium
- Payments canister processes payment via ICRC-1
- Oracle canister monitors water levels
- Insurance canister triggers automatic payouts when thresholds exceeded
- Payments canister releases funds from pool
# Ensure DFX is in PATH
export PATH=$HOME/bin:$PATH
# Add to ~/.bashrc or ~/.zshrc for persistence# Stop any running replicas
dfx stop
# Start with clean state
dfx start --clean# Clear build cache
dfx build --clean
# Check Rust toolchain
rustup update
rustup target add wasm32-unknown-unknown# Install ic-wasm if missing
cargo install ic-wasm
# Manual optimization
ic-wasm target/wasm32-unknown-unknown/release/oracle.wasm -o oracle_optimized.wasm shrink# Rebuild frontend
npm run build
# Redeploy
dfx deploy frontend --mode reinstall
# Check console for errors
# Verify canister IDs in .env file# Check canister status
dfx canister status --all
# View canister logs
dfx canister logs insurance
# Get canister IDs
dfx canister id insurance
dfx canister id oracle
dfx canister id payments
# Check wallet balance
dfx wallet balance
# Top up canister cycles
dfx canister deposit-cycles 1000000000000 insurance
# Export candid interface
dfx canister metadata insurance candid:service
# Stop local replica
dfx stop# Configure mainnet identity
dfx identity use mainnet
# Deploy with cycles wallet
dfx deploy --network ic --with-cycles 1000000000000
# Verify deployment
dfx canister --network ic status --all# Check cycles balance
dfx canister --network ic status insurance
# View recent logs
dfx canister --network ic logs insurance
# Get canister metrics
dfx canister --network ic call insurance get_metrics- Access Control: All administrative functions use Principal-based authentication
- Input Validation: All user inputs are validated before processing
- Overflow Protection: Nat types and checked arithmetic prevent overflows
- Stable Storage: Critical data persists across upgrades
- Rate Limiting: Oracle updates limited to prevent abuse
- Secure Randomness: Uses IC's secure randomness for policy IDs
For issues or questions:
- Check the troubleshooting section
- Review architecture documentation
- Open an issue on GitHub
- Contact the development team
MIT License - See LICENSE file for details
Last Updated: September 2024 Version: 1.0.0 (ICP Migration) Status: Production Ready