-
Install Foundry (if not already installed):
curl -L https://foundry.paradigm.xyz | bash foundryup -
Set up environment variables:
TOKEN_ADDRESS: The ERC20 token address to use with the factoryTREASURY_ADDRESS: The treasury address where fees will be sentPRIVATE_KEY: Your private key for deployment (optional, can use --private-key flag)RPC_URL: The RPC URL for your target network
Set the required addresses as environment variables:
Windows (PowerShell):
$env:TOKEN_ADDRESS="0x..."
$env:TREASURY_ADDRESS="0x..."
$env:PRIVATE_KEY="your-private-key"
$env:RPC_URL="https://your-rpc-url"Linux/Mac:
export TOKEN_ADDRESS=0x...
export TREASURY_ADDRESS=0x...
export PRIVATE_KEY=your-private-key
export RPC_URL=https://your-rpc-urlThen deploy:
forge script script/DeployBaseSafeFactory.s.sol:DeployBaseSafeFactory \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--broadcast \
--verifyforge script script/DeployBaseSafeFactory.s.sol:DeployBaseSafeFactory \
--rpc-url https://your-rpc-url \
--private-key your-private-key \
--sig "run()" \
--broadcast \
--verify \
--via-irNote: You'll need to modify the script to accept constructor arguments if you want to pass them directly.
-
Start Anvil:
anvil
-
Deploy using the private key from Anvil:
forge script script/DeployBaseSafeFactory.s.sol:DeployBaseSafeFactory \ --rpc-url http://localhost:8545 \ --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \ --broadcast
After deployment, the script will output:
- The deployed contract address
- The token address used
- The treasury address used
- Sepolia Testnet:
--rpc-url https://sepolia.infura.io/v3/YOUR_API_KEY - Mainnet:
--rpc-url https://mainnet.infura.io/v3/YOUR_API_KEY - Local Anvil:
--rpc-url http://localhost:8545
- Security: Never commit your private key to version control
- Network: Ensure the TOKEN_ADDRESS exists on your target network
- Verification: Add
--verifyflag if you want to verify on block explorer - Gas: Ensure your deployer wallet has sufficient ETH for gas fees