386 lines
8.1 KiB
Markdown
386 lines
8.1 KiB
Markdown
|
|
# Comprehensive Deployment Guide
|
||
|
|
|
||
|
|
**Date**: 2025-12-24
|
||
|
|
**Status**: Complete deployment guide for all contracts
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Overview
|
||
|
|
|
||
|
|
This guide provides step-by-step instructions for deploying all contracts in the system, including:
|
||
|
|
- Legal compliance contracts
|
||
|
|
- Token contracts
|
||
|
|
- Utility contracts
|
||
|
|
- CCIP contracts
|
||
|
|
- Cross-network deployments
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Prerequisites
|
||
|
|
|
||
|
|
### 1. Environment Setup
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cd /home/intlc/projects/proxmox/smom-dbis-138
|
||
|
|
|
||
|
|
# Load environment variables
|
||
|
|
source .env
|
||
|
|
|
||
|
|
# Verify required variables
|
||
|
|
echo $PRIVATE_KEY
|
||
|
|
echo $RPC_URL
|
||
|
|
```
|
||
|
|
|
||
|
|
### 2. Required Environment Variables
|
||
|
|
|
||
|
|
**Core Variables**:
|
||
|
|
- `PRIVATE_KEY`: Deployer private key
|
||
|
|
- `RPC_URL`: RPC endpoint URL (or `RPC_URL_138` for ChainID 138)
|
||
|
|
|
||
|
|
**Contract Addresses** (for dependencies):
|
||
|
|
- `CCIP_ROUTER_ADDRESS`: CCIP Router address
|
||
|
|
- `ORACLE_AGGREGATOR_ADDRESS`: Oracle Aggregator address
|
||
|
|
- `LINK_TOKEN_ADDRESS`: LINK token address
|
||
|
|
|
||
|
|
**Optional Variables**:
|
||
|
|
- `USDT_OWNER`: Owner for CompliantUSDT (defaults to deployer)
|
||
|
|
- `USDC_OWNER`: Owner for CompliantUSDC (defaults to deployer)
|
||
|
|
- `COMPLIANCE_ADMIN`: Admin for compliance contracts (defaults to deployer)
|
||
|
|
- `TOKEN_REGISTRY_OWNER`: Owner for TokenRegistry (defaults to deployer)
|
||
|
|
- `FEE_COLLECTOR_OWNER`: Owner for FeeCollector (defaults to deployer)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Phase 1: Legal Compliance Contracts
|
||
|
|
|
||
|
|
### 1.1 Deploy ComplianceRegistry
|
||
|
|
|
||
|
|
```bash
|
||
|
|
forge script script/DeployComplianceRegistry.s.sol:DeployComplianceRegistry \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 20000000000 \
|
||
|
|
--via-ir \
|
||
|
|
-vv
|
||
|
|
|
||
|
|
# Save the deployed address
|
||
|
|
export COMPLIANCE_REGISTRY_ADDRESS=<deployed_address>
|
||
|
|
```
|
||
|
|
|
||
|
|
### 1.2 Deploy CompliantUSDT
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Set optional variables
|
||
|
|
export USDT_OWNER=${USDT_OWNER:-$DEPLOYER}
|
||
|
|
export COMPLIANCE_ADMIN=${COMPLIANCE_ADMIN:-$DEPLOYER}
|
||
|
|
|
||
|
|
forge script script/DeployCompliantUSDT.s.sol:DeployCompliantUSDT \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 20000000000 \
|
||
|
|
--via-ir \
|
||
|
|
-vv
|
||
|
|
|
||
|
|
# Save the deployed address
|
||
|
|
export COMPLIANT_USDT_ADDRESS=<deployed_address>
|
||
|
|
```
|
||
|
|
|
||
|
|
### 1.3 Deploy CompliantUSDC
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Set optional variables
|
||
|
|
export USDC_OWNER=${USDC_OWNER:-$DEPLOYER}
|
||
|
|
export COMPLIANCE_ADMIN=${COMPLIANCE_ADMIN:-$DEPLOYER}
|
||
|
|
|
||
|
|
forge script script/DeployCompliantUSDC.s.sol:DeployCompliantUSDC \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 20000000000 \
|
||
|
|
--via-ir \
|
||
|
|
-vv
|
||
|
|
|
||
|
|
# Save the deployed address
|
||
|
|
export COMPLIANT_USDC_ADDRESS=<deployed_address>
|
||
|
|
```
|
||
|
|
|
||
|
|
### 1.4 Register Contracts in ComplianceRegistry
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Register CompliantUSDT
|
||
|
|
cast send $COMPLIANCE_REGISTRY_ADDRESS \
|
||
|
|
"registerContract(address)" \
|
||
|
|
$COMPLIANT_USDT_ADDRESS \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--private-key $PRIVATE_KEY
|
||
|
|
|
||
|
|
# Register CompliantUSDC
|
||
|
|
cast send $COMPLIANCE_REGISTRY_ADDRESS \
|
||
|
|
"registerContract(address)" \
|
||
|
|
$COMPLIANT_USDC_ADDRESS \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--private-key $PRIVATE_KEY
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Phase 2: Utility Contracts
|
||
|
|
|
||
|
|
### 2.1 Deploy TokenRegistry
|
||
|
|
|
||
|
|
```bash
|
||
|
|
export TOKEN_REGISTRY_OWNER=${TOKEN_REGISTRY_OWNER:-$DEPLOYER}
|
||
|
|
|
||
|
|
forge script script/DeployTokenRegistry.s.sol:DeployTokenRegistry \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 20000000000 \
|
||
|
|
-vv
|
||
|
|
|
||
|
|
# Save the deployed address
|
||
|
|
export TOKEN_REGISTRY_ADDRESS=<deployed_address>
|
||
|
|
```
|
||
|
|
|
||
|
|
### 2.2 Deploy FeeCollector
|
||
|
|
|
||
|
|
```bash
|
||
|
|
export FEE_COLLECTOR_OWNER=${FEE_COLLECTOR_OWNER:-$DEPLOYER}
|
||
|
|
|
||
|
|
forge script script/DeployFeeCollector.s.sol:DeployFeeCollector \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 20000000000 \
|
||
|
|
-vv
|
||
|
|
|
||
|
|
# Save the deployed address
|
||
|
|
export FEE_COLLECTOR_ADDRESS=<deployed_address>
|
||
|
|
```
|
||
|
|
|
||
|
|
### 2.3 Register Tokens in TokenRegistry
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Register CompliantUSDT
|
||
|
|
cast send $TOKEN_REGISTRY_ADDRESS \
|
||
|
|
"registerToken(address,string,string,uint8,bool,address)" \
|
||
|
|
$COMPLIANT_USDT_ADDRESS \
|
||
|
|
"Tether USD (Compliant)" \
|
||
|
|
"cUSDT" \
|
||
|
|
6 \
|
||
|
|
false \
|
||
|
|
0x0000000000000000000000000000000000000000 \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--private-key $PRIVATE_KEY
|
||
|
|
|
||
|
|
# Register CompliantUSDC
|
||
|
|
cast send $TOKEN_REGISTRY_ADDRESS \
|
||
|
|
"registerToken(address,string,string,uint8,bool,address)" \
|
||
|
|
$COMPLIANT_USDC_ADDRESS \
|
||
|
|
"USD Coin (Compliant)" \
|
||
|
|
"cUSDC" \
|
||
|
|
6 \
|
||
|
|
false \
|
||
|
|
0x0000000000000000000000000000000000000000 \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--private-key $PRIVATE_KEY
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Phase 3: CCIP Contracts (ChainID 138)
|
||
|
|
|
||
|
|
### 3.1 Deploy CCIPSender
|
||
|
|
|
||
|
|
```bash
|
||
|
|
forge script script/DeployCCIPSender.s.sol:DeployCCIPSender \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 20000000000 \
|
||
|
|
--via-ir \
|
||
|
|
-vv
|
||
|
|
|
||
|
|
# Save the deployed address
|
||
|
|
export CCIP_SENDER_ADDRESS=<deployed_address>
|
||
|
|
```
|
||
|
|
|
||
|
|
### 3.2 Deploy CCIPReceiver
|
||
|
|
|
||
|
|
```bash
|
||
|
|
forge script script/DeployCCIPReceiver.s.sol:DeployCCIPReceiver \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 20000000000 \
|
||
|
|
--via-ir \
|
||
|
|
-vv
|
||
|
|
|
||
|
|
# Save the deployed address
|
||
|
|
export CCIP_RECEIVER_ADDRESS=<deployed_address>
|
||
|
|
```
|
||
|
|
|
||
|
|
### 3.3 Deploy CCIP Bridges
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Deploy WETH9 Bridge
|
||
|
|
forge script script/DeployCCIPWETH9Bridge.s.sol:DeployCCIPWETH9Bridge \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 20000000000 \
|
||
|
|
--via-ir \
|
||
|
|
-vv
|
||
|
|
|
||
|
|
# Deploy WETH10 Bridge
|
||
|
|
forge script script/DeployCCIPWETH10Bridge.s.sol:DeployCCIPWETH10Bridge \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price 20000000000 \
|
||
|
|
--via-ir \
|
||
|
|
-vv
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Phase 4: Cross-Network Deployments
|
||
|
|
|
||
|
|
### 4.1 Ethereum Mainnet
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Set Mainnet RPC URL
|
||
|
|
export RPC_URL_MAINNET=<mainnet_rpc_url>
|
||
|
|
export PRIVATE_KEY_MAINNET=<mainnet_private_key>
|
||
|
|
|
||
|
|
# Deploy CCIPSender
|
||
|
|
forge script script/DeployCCIPSenderMainnet.s.sol:DeployCCIPSenderMainnet \
|
||
|
|
--rpc-url $RPC_URL_MAINNET \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price <mainnet_gas_price> \
|
||
|
|
--via-ir \
|
||
|
|
-vv
|
||
|
|
|
||
|
|
# Deploy CCIPReceiver
|
||
|
|
forge script script/DeployCCIPReceiverMainnet.s.sol:DeployCCIPReceiverMainnet \
|
||
|
|
--rpc-url $RPC_URL_MAINNET \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price <mainnet_gas_price> \
|
||
|
|
--via-ir \
|
||
|
|
-vv
|
||
|
|
|
||
|
|
# Deploy CCIPLogger
|
||
|
|
forge script script/DeployCCIPLoggerMainnet.s.sol:DeployCCIPLoggerMainnet \
|
||
|
|
--rpc-url $RPC_URL_MAINNET \
|
||
|
|
--broadcast \
|
||
|
|
--legacy \
|
||
|
|
--gas-price <mainnet_gas_price> \
|
||
|
|
--via-ir \
|
||
|
|
-vv
|
||
|
|
```
|
||
|
|
|
||
|
|
### 4.2 Other Networks
|
||
|
|
|
||
|
|
Similar deployment process for:
|
||
|
|
- BSC (ChainID 56)
|
||
|
|
- Polygon (ChainID 137)
|
||
|
|
- Avalanche (ChainID 43114)
|
||
|
|
- Base (ChainID 8453)
|
||
|
|
- Arbitrum (ChainID 42161)
|
||
|
|
- Optimism (ChainID 10)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Phase 5: Post-Deployment Configuration
|
||
|
|
|
||
|
|
### 5.1 Update .env Files
|
||
|
|
|
||
|
|
Add all deployed addresses to `.env`:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Legal Compliance
|
||
|
|
COMPLIANCE_REGISTRY_ADDRESS=<address>
|
||
|
|
COMPLIANT_USDT_ADDRESS=<address>
|
||
|
|
COMPLIANT_USDC_ADDRESS=<address>
|
||
|
|
|
||
|
|
# Utility Contracts
|
||
|
|
TOKEN_REGISTRY_ADDRESS=<address>
|
||
|
|
FEE_COLLECTOR_ADDRESS=<address>
|
||
|
|
|
||
|
|
# CCIP Contracts
|
||
|
|
CCIP_SENDER_ADDRESS=<address>
|
||
|
|
CCIP_RECEIVER_ADDRESS=<address>
|
||
|
|
CCIP_WETH9_BRIDGE_ADDRESS=<address>
|
||
|
|
CCIP_WETH10_BRIDGE_ADDRESS=<address>
|
||
|
|
```
|
||
|
|
|
||
|
|
### 5.2 Configure Fee Recipients
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Add fee recipient for ETH
|
||
|
|
cast send $FEE_COLLECTOR_ADDRESS \
|
||
|
|
"addFeeRecipient(address,address,uint256)" \
|
||
|
|
0x0000000000000000000000000000000000000000 \
|
||
|
|
<recipient_address> \
|
||
|
|
10000 \
|
||
|
|
--rpc-url $RPC_URL \
|
||
|
|
--private-key $PRIVATE_KEY
|
||
|
|
```
|
||
|
|
|
||
|
|
### 5.3 Verify Contracts
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Verify on block explorer
|
||
|
|
forge verify-contract <address> <contract_name> \
|
||
|
|
--chain-id 138 \
|
||
|
|
--etherscan-api-key <api_key>
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Verification Checklist
|
||
|
|
|
||
|
|
- [ ] All contracts deployed successfully
|
||
|
|
- [ ] All addresses saved to `.env`
|
||
|
|
- [ ] Contracts registered in ComplianceRegistry
|
||
|
|
- [ ] Tokens registered in TokenRegistry
|
||
|
|
- [ ] Fee recipients configured
|
||
|
|
- [ ] Contracts verified on block explorer
|
||
|
|
- [ ] Cross-network deployments completed
|
||
|
|
- [ ] All dependencies configured
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Troubleshooting
|
||
|
|
|
||
|
|
### Common Issues
|
||
|
|
|
||
|
|
1. **"Stack too deep" error**: Use `--via-ir` flag
|
||
|
|
2. **"Insufficient funds"**: Check deployer balance
|
||
|
|
3. **"Contract already deployed"**: Check if address already has code
|
||
|
|
4. **"Invalid constructor parameters"**: Verify environment variables
|
||
|
|
|
||
|
|
### Gas Issues
|
||
|
|
|
||
|
|
- Increase gas price: `--gas-price 20000000000`
|
||
|
|
- Increase gas limit: `--gas-limit 10000000`
|
||
|
|
- Use legacy transactions: `--legacy`
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Next Steps
|
||
|
|
|
||
|
|
1. Configure cross-chain connections
|
||
|
|
2. Set up monitoring and alerts
|
||
|
|
3. Deploy additional contracts as needed
|
||
|
|
4. Update service configurations
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
**Last Updated**: 2025-12-24
|
||
|
|
|