Example Deployment Guide
Complete guide for deploying example IFIF projects for development, testing, and demonstration purposes using our automated deployment scripts.
Overview
The example deployment system creates a comprehensive testing environment with multiple IFIF projects, investors, and various project lifecycle scenarios. This setup is essential for:
- Development Testing: Full workflow validation
- Frontend Development: Real data for UI components
- Integration Testing: Cross-contract functionality
- Demo Environments: Showcasing platform capabilities
Deployment Flow
The example deployment follows a specific sequence that mirrors production workflows:
1. Core Contracts (DeployAll)
Deploy the fundamental protocol infrastructure:
- Roles contract (access control system)
- Whitelist contract (Merkle tree whitelist management)
- IFIF Factory (project deployment system)
- Implementation contracts (IFIF and IFIFToken templates)
2. DEX Infrastructure (deployDex)
Deploy decentralized exchange components for token trading:
- WETH contract (wrapped ETH for trading)
- Pair Factory (liquidity pool creation)
- Router contract (trading interface)
- Factory integration (connects IFIF projects to DEX)
3. Example Projects (deployExamples)
Create comprehensive test scenarios with multiple projects:
- 5 different IFIF projects with varied configurations
- Multiple investor accounts with different investment patterns
- Complete project lifecycles (creation → investment → success/failure)
- Real EIP-712 signatures for governance operations
Prerequisites
Before starting the example deployment:
# 1. Install dependencies
pnpm install
# 2. Build contracts (optional - script will compile if needed)
pnpm contracts:build
# 3. Start local blockchain with proper configuration
pnpm anvil-arm -p 8544 # For ARM-based systems (M1/M2 Macs)
# or
pnpm anvil-amd -p 8544 # For AMD/Intel systemsImportant: Use the correct anvil command for your system architecture and specify port 8544 to match the deployment scripts' RPC configuration.
Step-by-Step Deployment
Step 1: Deploy Core Contracts
# Deploy the complete protocol infrastructure
pnpm contracts:script script/DeployAll.s.sol- Deploys Roles contract with admin setup
- Deploys upgradeable Whitelist contract
- Deploys IFIFFactory with implementation contracts
- Configures all contracts for integration
- Sets up basic permissions and roles
=== Core Protocol Deployment Complete ===
ROLES_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
WHITELIST_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
IFIF_FACTORY_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9Step 2: Deploy DEX Infrastructure
# Deploy DEX components and integrate with factory
pnpm contracts:deploy-dex- Deploys WETH contract for wrapped ETH trading
- Deploys Uniswap V2-compatible Pair Factory
- Deploys Router contract for token swaps
- Updates IFIF Factory with DEX router address
- Prepares infrastructure for token trading
✅ DEX deployment successful!
Contract addresses: {
wethAddress: '0x...',
pairFactoryAddress: '0x...',
routerAddress: '0x...',
factoryAddress: '0x...'
}Step 3: Deploy Example Projects
# Create comprehensive test projects and scenarios
pnpm contracts:deploy-examples- Creates 5 different IFIF projects with varied configurations
- Sets up investor accounts with USDC tokens
- Executes investment transactions across project stages
- Demonstrates complete project lifecycles
- Creates whitelist sections with real Merkle proofs
- Performs role management operations
- Simulates time progression for project stages
Project 1: "VIP Whitelist Project"
- Target: 100,000 USDC
- Private Sale: 20% bonus, 30 minutes
- Public Sale: 1 hour
- Status: Successful funding with DEX listing
Project 2: "Standard Project"
- Target: 50,000 USDC
- Private Sale: 15% bonus, 30 minutes
- Public Sale: 1 hour
- Status: Successful with token distribution
Project 3: "High Bonus Project"
- Target: 80,000 USDC
- Private Sale: 25% bonus, varied timing
- Public Sale: Extended duration
- Status: Successful with bonus demonstrations
Project 4: "Failure Test Project"
- Target: 120,000 USDC (high target for failure)
- Private Sale: Standard bonus
- Public Sale: Standard duration
- Status: Failed funding (demonstrates refund flow)
Project 5: "Config Update Test Project"
- Target: 150,000 USDC
- Private Sale: Configurable parameters
- Public Sale: Configurable duration
- Status: Demonstrates configuration updates and governance
Investment Scenarios
The deployment creates realistic investment patterns:
Investor Profiles:- Account 4: Aggressive early investor (90k USDC)
- Account 5: Balanced portfolio investor (70k USDC)
- Account 6: Conservative late investor (90k USDC)
- Account 7: Small retail investor (55k USDC)
- Account 8: Strategic investor (55k USDC)
- Private sale bonus calculations
- Public sale standard rates
- Partial investments across multiple projects
- Failed project refund scenarios
- NFT claiming and operations
One-Command Deployment
For development convenience, deploy everything in sequence:
# Complete example environment setup
# 1. Deploy core contracts
pnpm contracts:script script/DeployAll.s.sol
# 2. Deploy DEX infrastructure
pnpm contracts:deploy-dex
# 3. Deploy example projects
pnpm contracts:deploy-examples
echo "🎉 Complete example environment ready!"Generated Test Data
After successful deployment, you'll have:
Contracts
- All core protocol contracts deployed and configured
- DEX infrastructure ready for token trading
- 5 example projects in various states
Test Accounts
- Admin (Account 0): Protocol administrator
- Project Owner (Account 1): Manages project 1
- Distributor (Account 2): Asset distribution role
- Manager (Account 3): EIP-712 signing permissions
- Investors (Accounts 4-8): Various investment patterns
Blockchain State
- Realistic investment transactions
- Project stage progressions
- NFT allocations and operations
- Whitelist management activities
- Role assignment history
Financial Data
- USDC token distributions
- Investment bonus calculations
- Fee distributions
- Refund processing
- Token claim scenarios
Development Usage
Frontend Development
Use the deployed contracts for UI development:
// Contract addresses from deployment
const CONTRACT_ADDRESSES = {
ROLES: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
WHITELIST: '0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0',
FACTORY: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9',
// Example projects will have addresses starting from project ID 1
}
// Use with wagmi or viem for contract interactions
const factory = getContract({
address: CONTRACT_ADDRESSES.FACTORY,
abi: ififFactoryAbi,
client: publicClient
})Indexer Development
Start the indexer to process the generated events:
# Start indexer after example deployment
pnpm indexer:dev
# The indexer will process all generated events:
# - Project creations and stage transitions
# - Investment transactions and refunds
# - NFT operations and transfers
# - Role management activities
# - Whitelist updatesTesting Integration
Use the deployed state for integration testing:
// Test with real deployed contracts
describe('IFIF Integration Tests', () => {
it('should handle complete project lifecycle', async () => {
// Test against deployed project 1
const project = await factory.read.getProject([1])
expect(project.stage).toBe(ProjectStage.SUCCESS)
})
it('should process investor NFT operations', async () => {
// Test NFT functionality with real allocations
const nftBalance = await project.read.balanceOf([ACCOUNTS.ACCOUNT_4])
expect(nftBalance).toBeGreaterThan(0)
})
})Verification & Validation
Contract Verification
Verify deployed contracts are properly configured:
# Check core contract deployment
cast call $ROLES_ADDRESS "owner()" --rpc-url http://localhost:8544
# Verify factory configuration
cast call $FACTORY_ADDRESS "getImplementation()" --rpc-url http://localhost:8544
# Check project creation
cast call $FACTORY_ADDRESS "totalProjects()" --rpc-url http://localhost:8544Data Validation
Verify example data creation:
# Check investor balances
cast call $USDC_ADDRESS "balanceOf(address)" $INVESTOR_ADDRESS --rpc-url http://localhost:8544
# Verify project investments
cast call $PROJECT_ADDRESS "totalPurchase()" --rpc-url http://localhost:8544
# Check NFT allocations
cast call $PROJECT_ADDRESS "balanceOf(address)" $INVESTOR_ADDRESS --rpc-url http://localhost:8544Troubleshooting
Common Issues
Contract Address Mismatch
# Update CONTRACT_ADDRESSES in deployDex.ts and deployExamples.ts
# with actual deployed addresses from DeployAll outputAnvil State Issues
# Reset anvil state if needed
rm -rf anvil-state/ anvil-state-amd/
pnpm anvil-arm -p 8544 # or anvil-amd -p 8544Transaction Failures
# Check anvil logs for detailed error messages
# Ensure sufficient ETH in accounts for gas
# Verify contract addresses are correctNetwork Issues
RPC Connection
# Verify anvil is running on correct port
curl -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
http://localhost:8544Account Configuration
# Verify account addresses match between scripts
# Check private keys are correct for anvil accountsAdvanced Configuration
Custom Project Parameters
Modify project configurations in deployExamples.ts:
// Customize project settings
const customProjectConfig = {
fundToken: usdcAddress,
projectId: 6, // Next available ID
fundAmount: parseEther("25000"), // 25k USDC target
privateSaleTime: 5 * 24 * 60 * 60, // 5 days
privateBonusPercent: 15, // 15% bonus
publicSaleTime: 10 * 24 * 60 * 60, // 10 days
desiredEndEpoch: getCurrentTimestamp() + (30 * 24 * 60 * 60) // 30 days
}Investment Patterns
Create custom investment scenarios:
// Add custom investor behavior
const customInvestments = [
{ investor: 'ACCOUNT_4', amount: parseEther("5000"), stage: 'private' },
{ investor: 'ACCOUNT_5', amount: parseEther("3000"), stage: 'public' },
// Add more patterns as needed
]Time Simulation
Control project timeline progression:
// Advance time for specific testing scenarios
await advanceTimeAndTrack(testClient, 7 * 24 * 60 * 60) // 7 days
await setBlockTimestampAndTrack(testClient, futureTimestamp)Integration with Frontend
Use the deployed examples with the Next.js frontend:
# Start the frontend with deployed contracts
cd examples
pnpm dev
# The frontend will automatically detect:
# - Available projects from factory
# - User investment history
# - NFT allocations
# - Project analyticsThe frontend components will display real data from the deployed example projects, providing an immediate working demo of the complete IFIF ecosystem.
Production Considerations
While these scripts are designed for development/testing, the patterns demonstrate:
- Proper Contract Integration: How contracts work together
- EIP-712 Signature Usage: Real signature creation and verification
- Project Lifecycle Management: Complete workflow implementation
- Investment Pattern Handling: Various investor behaviors
- Error Handling: Graceful failure scenarios
These patterns can be adapted for production deployment with appropriate modifications for real-world security, governance, and operational requirements.