π― FINAL SOLUTION: SCRIPT-BASED DEPLOYMENT
π¨ THE PROBLEMβ
Even an ultra-minimal factory is >100KB because it embeds bytecode for 3 large contracts:
CreatorOVault(~30KB)CreatorOVaultWrapper(~25KB)CreatorShareOFT(~40KB)
Total embedded bytecode: ~95KB + factory code = >100KB
EVM limit: 24KB β
β THE SOLUTION: DEPLOYMENT SCRIPTSβ
Instead of a factory contract, use Foundry scripts for deployment:
How It Works:β
- No contract size limit (scripts run off-chain)
- Full CREATE2 support (deterministic addresses)
- More flexible (can deploy anything)
- Gas efficient (no factory overhead)
π IMPLEMENTATIONβ
Script: DeployCreatorVault.s.solβ
// Deploy vault infrastructure with CREATE2
function run() external {
address token = vm.envAddress("TOKEN");
address creator = vm.envAddress("CREATOR");
// Generate salt
bytes32 salt = keccak256(abi.encodePacked("CV1_", token));
// Deploy with CREATE2
vault = new CreatorOVault{salt: salt}(token, creator, ...);
wrapper = new CreatorOVaultWrapper{salt: salt}(token, vault, creator);
shareOFT = new CreatorShareOFT{salt: salt}(name, symbol, lz, creator);
// Configure
wrapper.setShareOFT(shareOFT);
shareOFT.setVault(vault);
shareOFT.setMinter(wrapper, true);
vault.setWhitelist(wrapper, true);
}
Frontend Integration:β
// Call script via backend API
async function deployVault(token: string, creator: string) {
const response = await fetch('/api/deploy-vault', {
method: 'POST',
body: JSON.stringify({ token, creator })
});
const { vault, wrapper, shareOFT } = await response.json();
return { vault, wrapper, shareOFT };
}
Backend API:β
// api/deploy-vault.ts
import { exec } from 'child_process';
export async function POST(req: Request) {
const { token, creator } = await req.json();
// Run forge script
const result = await exec(`
forge script script/DeployCreatorVault.s.sol \
--rpc-url base \
--private-key ${DEPLOYER_KEY} \
--broadcast \
-vvv
`);
// Parse output for addresses
const { vault, wrapper, shareOFT } = parseOutput(result);
return Response.json({ vault, wrapper, shareOFT });
}
π― BENEFITSβ
| Feature | Factory | Script |
|---|---|---|
| Size limit | β 24KB | β Unlimited |
| CREATE2 | β Yes | β Yes |
| Gas cost | Higher (factory call) | Lower (direct deploy) |
| Flexibility | Limited | β Full control |
| Frontend integration | Direct | Via API |
π‘ RECOMMENDED ARCHITECTUREβ
Frontend
β (Call API)
Backend API
β (Run script)
Forge Script
β (Deploy with CREATE2)
Vault + Wrapper + ShareOFT on Base
User Experience:
- User clicks "Create Vault"
- Frontend calls backend API
- Backend runs forge script
- Script deploys with CREATE2
- Returns addresses to frontend
- Same addresses on all chains! β
π WHAT YOU ALREADY HAVEβ
You already have the script approach ready to use:
- β
CreatorOVaultFactory.sol(onchain registry of deployments) - β CREATE2-based deployment flow (AA + deployers)
- β VaultActivationBatcher deployed
You just need:
- Use the existing AA deploy flow (
frontend/src/components/DeployVaultAA.tsx/script/deploy-with-aa.ts) - Or run Foundry scripts to deploy and then
registerDeployment(...)inCreatorOVaultFactory
π QUICK STARTβ
1. Create Scriptβ
# Prefer the AA deploy flow (one-signature) or the existing Foundry scripts in /script.
# See:
# - script/DeployInfrastructure.s.sol
# - script/deploy-with-aa.ts
2. Test Locallyβ
forge script script/DeployVaultWithCREATE2.s.sol --rpc-url base --broadcast
3. Integrate with Frontendβ
// Simple API call
const { vault, wrapper, shareOFT } = await deployVault(token, creator);
π ADVANTAGES OVER FACTORYβ
β No 24KB limit β Same CREATE2 benefits β Lower gas costs β More control β Easier to update
Want me to create the deployment script now? π
This is the BEST solution for your use case!