# TokenFactory138 Compilation Test Guide **Date**: 2025-12-24 **Purpose**: Test and verify TokenFactory138 compilation before deployment --- ## Quick Test Run the compilation test script: ```bash cd /home/intlc/projects/proxmox/smom-dbis-138 ./scripts/compile-and-test-tokenfactory.sh ``` Or manually: ```bash cd /home/intlc/projects/proxmox/smom-dbis-138 # Test standard compilation forge build --contracts contracts/emoney/TokenFactory138.sol 2>&1 | tee /tmp/tf138-std.log # Test via-ir compilation (recommended for stack too deep) forge build --via-ir --contracts contracts/emoney/TokenFactory138.sol 2>&1 | tee /tmp/tf138-viair.log ``` --- ## Dependencies Check TokenFactory138 requires these contracts to exist: 1. ✅ `contracts/emoney/interfaces/ITokenFactory138.sol` 2. ✅ `contracts/emoney/interfaces/IeMoneyToken.sol` 3. ✅ `contracts/emoney/interfaces/IPolicyManager.sol` 4. ✅ `contracts/emoney/eMoneyToken.sol` 5. ✅ `contracts/emoney/errors/FactoryErrors.sol` 6. ✅ `contracts/emoney/errors/RegistryErrors.sol` 7. ✅ OpenZeppelin contracts (AccessControl, ERC1967Proxy) --- ## Known Issues ### 1. Stack Too Deep Error **Symptom**: `Error: Stack too deep. Try compiling with --via-ir` **Solution**: Use `--via-ir` flag: ```bash forge build --via-ir forge script ... --via-ir ``` ### 2. Missing Dependencies **Symptom**: `Source "..." not found` **Solution**: Ensure all dependency contracts are present and compile successfully. --- ## Deployment Requirements TokenFactory138 constructor requires: - `admin` - Admin address (DEFAULT_ADMIN_ROLE) - `implementation_` - eMoneyToken implementation address - `policyManager_` - PolicyManager contract address - `debtRegistry_` - DebtRegistry contract address - `complianceRegistry_` - ComplianceRegistry contract address **Deployment Order** (from DeployChain138.s.sol): 1. ComplianceRegistry 2. DebtRegistry 3. PolicyManager 4. eMoneyToken (implementation) 5. **TokenFactory138** (requires all above) --- ## Verification Commands After compilation, verify: ```bash # Check if bytecode was generated ls -lh out/TokenFactory138.sol/TokenFactory138.json # Check bytecode size cat out/TokenFactory138.sol/TokenFactory138.json | jq -r '.bytecode.object' | wc -c ``` Expected: > 1000 bytes for a factory contract. --- **Last Updated**: 2025-12-24