6.6 KiB
6.6 KiB
Chain 138 Contract Deployment Guide
Date: $(date)
Purpose: Complete guide for deploying smart contracts to Chain 138
📋 Prerequisites
1. Network Readiness
Verify Chain 138 network is ready:
# Check block production
cast block-number --rpc-url http://192.168.11.250:8545
# Check chain ID
cast chain-id --rpc-url http://192.168.11.250:8545
Expected Results:
- Block number > 0
- Chain ID = 138
2. Environment Setup
Create .env file in source project:
cd /home/intlc/projects/smom-dbis-138
cp .env.example .env # If exists
Required variables:
# Chain 138 RPC
RPC_URL_138=http://192.168.11.250:8545
# Deployer
PRIVATE_KEY=<your-deployer-private-key>
# Oracle Configuration (deploy Oracle first)
ORACLE_PRICE_FEED=<oracle-price-feed-address>
# Reserve Configuration
RESERVE_ADMIN=<admin-address>
TOKEN_FACTORY=<token-factory-address> # Optional
# Keeper Configuration
KEEPER_ADDRESS=<keeper-address> # Address that will execute upkeep
3. Required Tools
- Foundry (forge, cast)
- jq (for address extraction)
- Access to Proxmox (for service updates)
🚀 Deployment Methods
Method 1: Automated Deployment Script
Use the automated script:
cd /home/intlc/projects/proxmox
./scripts/deploy-contracts-chain138.sh
What it does:
- Verifies network readiness
- Deploys Oracle contract
- Deploys CCIP Router
- Deploys CCIP Sender
- Deploys Keeper (if Oracle Price Feed configured)
- Logs all deployments
Method 2: Manual Deployment
Deploy contracts individually:
1. Deploy Oracle
cd /home/intlc/projects/smom-dbis-138
forge script script/DeployOracle.s.sol:DeployOracle \
--rpc-url http://192.168.11.250:8545 \
--private-key $PRIVATE_KEY \
--broadcast --verify -vvvv
2. Deploy CCIP Router
forge script script/DeployCCIPRouter.s.sol:DeployCCIPRouter \
--rpc-url http://192.168.11.250:8545 \
--private-key $PRIVATE_KEY \
--broadcast --verify -vvvv
3. Deploy CCIP Sender
forge script script/DeployCCIPSender.s.sol:DeployCCIPSender \
--rpc-url http://192.168.11.250:8545 \
--private-key $PRIVATE_KEY \
--broadcast --verify -vvvv
4. Deploy Keeper
# Set Oracle Price Feed address first
export ORACLE_PRICE_FEED=<oracle-price-feed-address>
forge script script/reserve/DeployKeeper.s.sol:DeployKeeper \
--rpc-url http://192.168.11.250:8545 \
--private-key $PRIVATE_KEY \
--broadcast --verify -vvvv
5. Deploy Reserve System
# Set Token Factory address if using
export TOKEN_FACTORY=<token-factory-address>
forge script script/reserve/DeployReserveSystem.s.sol:DeployReserveSystem \
--rpc-url http://192.168.11.250:8545 \
--private-key $PRIVATE_KEY \
--broadcast --verify -vvvv
📝 Extract Contract Addresses
After deployment, extract addresses:
cd /home/intlc/projects/proxmox
./scripts/extract-contract-addresses.sh 138
This creates: /home/intlc/projects/smom-dbis-138/deployed-addresses-chain138.txt
Manual Extraction:
cd /home/intlc/projects/smom-dbis-138
LATEST_RUN=$(find broadcast -type d -path "*/138/run-*" | sort -V | tail -1)
# Extract Oracle address
jq -r '.transactions[] | select(.transactionType == "CREATE") | .contractAddress' \
"$LATEST_RUN/DeployOracle.s.sol/DeployOracle.json" | head -1
# Extract CCIP Router address
jq -r '.transactions[] | select(.transactionType == "CREATE") | .contractAddress' \
"$LATEST_RUN/DeployCCIPRouter.s.sol/DeployCCIPRouter.json" | head -1
⚙️ Update Service Configurations
After extracting addresses, update service configs:
cd /home/intlc/projects/proxmox
# Source addresses
source /home/intlc/projects/smom-dbis-138/deployed-addresses-chain138.txt
# Update all services
./scripts/update-service-configs.sh
Manual Update:
# Oracle Publisher (VMID 3500)
pct exec 3500 -- bash -c "cat >> /opt/oracle-publisher/.env <<EOF
ORACLE_CONTRACT_ADDRESS=<deployed-address>
EOF"
# CCIP Monitor (VMID 3501)
pct exec 3501 -- bash -c "cat >> /opt/ccip-monitor/.env <<EOF
CCIP_ROUTER_ADDRESS=<deployed-address>
CCIP_SENDER_ADDRESS=<deployed-address>
EOF"
# Keeper (VMID 3502)
pct exec 3502 -- bash -c "cat >> /opt/keeper/.env <<EOF
PRICE_FEED_KEEPER_ADDRESS=<deployed-address>
EOF"
✅ Verification
1. Verify Contracts on Chain
# Check contract code
cast code <contract-address> --rpc-url http://192.168.11.250:8545
# Check contract balance
cast balance <contract-address> --rpc-url http://192.168.11.250:8545
2. Verify Service Connections
# Test Oracle Publisher
pct exec 3500 -- curl -X POST http://localhost:8000/health
# Test CCIP Monitor
pct exec 3501 -- curl -X POST http://localhost:8000/health
# Test Keeper
pct exec 3502 -- curl -X POST http://localhost:3000/health
3. Check Service Logs
# Oracle Publisher
pct exec 3500 -- journalctl -u oracle-publisher -f
# CCIP Monitor
pct exec 3501 -- journalctl -u ccip-monitor -f
# Keeper
pct exec 3502 -- journalctl -u price-feed-keeper -f
📊 Deployment Checklist
- Network producing blocks (block number > 0)
- Chain ID verified (138)
- Deployer account has sufficient balance
.envfile configured with PRIVATE_KEY- Oracle contract deployed
- CCIP Router deployed
- CCIP Sender deployed
- Keeper deployed (if using)
- Reserve System deployed (if using)
- Contract addresses extracted
- Service .env files updated
- Services restarted
- Service health checks passing
🔧 Troubleshooting
Network Not Ready
Error: Network is not producing blocks yet
Solution:
- Wait for validators to initialize
- Check validator logs:
pct exec <vmid> -- journalctl -u besu -f - Verify network connectivity
Deployment Fails
Error: insufficient funds or nonce too low
Solution:
- Check deployer balance:
cast balance <deployer-address> --rpc-url http://192.168.11.250:8545 - Check nonce:
cast nonce <deployer-address> --rpc-url http://192.168.11.250:8545 - Ensure sufficient balance for gas
Contract Address Not Found
Error: Address extraction returns empty
Solution:
- Check broadcast files:
ls -la broadcast/*/138/run-*/ - Verify deployment succeeded (check logs)
- Manually extract from broadcast JSON files
📚 Related Documentation
- Source Project Contract Deployment Info
- Deployed Smart Contracts Inventory
- Smart Contract Connections & Next LXCs
Last Updated: $(date)