A Rust-based CLI tool for deploying smart contracts with TOML configuration files, making deployments consistent, reproducible, and secure across different networks.
- π§ TOML Configuration - Clean, readable configuration format
- π Multi-Network Support - Deploy to mainnet, testnets, or local networks
- π Secure Authentication - Keystore or private key support
- π¦ Repository Cloning - Deploy directly from Git repositories
- π Real-time Output - See deployment progress as it happens
- π Environment Management - Multiple
.env
files with variable expansion - β Automatic Verification - Built-in Etherscan verification
- π οΈ Flexible Setup - Custom dependency installation commands
# One-line install (macOS/Linux)
curl -fsSL https://raw.githubusercontent.com/0xdavid7/contract-deployer/main/install.sh | bash
- Create configuration file:
cp ~/.contract-deployer/examples/basic-deploy.toml ./deploy.toml
- Set up environment variables:
cat > .env << EOF
API_KEY_ETHERSCAN=your_etherscan_api_key
ALCHEMY_API_KEY=your_alchemy_api_key
KEYSTORE_ACCOUNT=your_keystore_account
KEYSTORE_PASSWORD=your_keystore_password
EOF
- Deploy your contract:
contract-deployer --config deploy.toml
[project]
name = "my-smart-contract"
script = "Deploy" # Will look for script/Deploy.s.sol
network = "sepolia" # Default network
setup_command = "bun install" # Dependencies installation
repo = "https://github.com/user/contract.git" # Optional: Git repository
[env]
load_files = [".env"] # Environment files to load
[networks.sepolia]
chain_id = 11155111
rpc_url = "https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
verify = true
[networks.mainnet]
chain_id = 1
rpc_url = "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
verify = true
[networks.localhost]
chain_id = 31337
rpc_url = "http://localhost:8545"
verify = false
# Required
API_KEY_ETHERSCAN=your_etherscan_api_key
ALCHEMY_API_KEY=your_alchemy_api_key
# Authentication (choose one method)
# Method 1: Keystore (recommended)
KEYSTORE_ACCOUNT=your_keystore_account
KEYSTORE_PASSWORD=your_keystore_password
# Method 2: Private key (development)
PRIVATE_KEY=0x_your_private_key
- Mainnet - Production Ethereum network
- Sepolia - Primary Ethereum testnet
- Localhost - Local development (Anvil, Hardhat)
- Polygon - Polygon PoS chain
- Arbitrum - Arbitrum One
- Optimism - Optimism mainnet
- Base - Coinbase's L2
- BSC - Binance Smart Chain
- Avalanche - Avalanche C-Chain
See examples/multi-chain.toml for complete network configurations.
# Repository specified in config
contract-deployer --config deploy.toml
# With custom arguments
contract-deployer --config deploy.toml --args "--value" --args "1000000"
# No repo specified in config = deploy from current directory
contract-deployer --config local-deploy.toml
# Deploy to multiple networks
contract-deployer --config mainnet-deploy.toml
contract-deployer --config polygon-deploy.toml
contract-deployer --config arbitrum-deploy.toml
# Start local network
anvil
# Deploy to local network
contract-deployer --config examples/development.toml
# Test and iterate
forge test
# Deploy to testnet
contract-deployer --config testnet-deploy.toml
# Deploy to mainnet
contract-deployer --config mainnet-deploy.toml
Basic Deployment (examples/basic-deploy.toml)
Simple configuration for deploying to Ethereum testnets.
Multi-Chain Setup (examples/multi-chain.toml)
Comprehensive setup supporting 15+ networks including Ethereum, Polygon, Arbitrum, Optimism, BSC, and more.
Development Setup (examples/development.toml)
Optimized for local development with Anvil, including pre-configured test accounts and fast deployment.
# Create keystore
cast wallet import my-account --interactive
# Use in config
KEYSTORE_ACCOUNT=my-account
KEYSTORE_PASSWORD=secure_password
# Use private key directly
PRIVATE_KEY=
[networks.custom]
rpc_url = "https://rpc.${NETWORK_NAME}.example.com/${API_KEY}"
[env]
load_files = [".env", ".env.local", ".env.${NETWORK}"]
[project]
setup_command = "npm install && npm run build && forge build"
[env.additional_vars]
DEPLOYMENT_SALT = "0x1234567890abcdef"
MIN_CONFIRMATION_BLOCKS = "12"
# Check keystore exists
cast wallet list
# Verify keystore address
cast wallet address --account your_account
# Test authentication
cast wallet address --account your_account --password your_password
# Test RPC endpoint
curl -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' \
https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY
# Check Etherscan API key
curl "https://api.etherscan.io/api?module=account&action=balance&address=0x1234&apikey=YOUR_KEY"
# Ensure network supports verification
verify = true # in network config
# Check installation
ls ~/.contract-deployer/bin/contract-deployer
# Check PATH
echo $PATH | grep contract-deployer
# Reload shell
source ~/.bashrc # or ~/.zshrc
forge script script/Deploy.s.sol \
--chain-id 11155111 \
--rpc-url sepolia \
--broadcast \
--verify \
--account my-account \
--password my-password
# deploy.toml
[project]
name = "my-contract"
script = "Deploy"
network = "sepolia"
setup_command = "forge build"
[networks.sepolia]
chain_id = 11155111
rpc_url = "https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
verify = true
contract-deployer --config deploy.toml
- β Linux (x86_64, ARM64)
- β macOS (Intel, Apple Silicon)
- β Windows (not supported)
curl -fsSL https://raw.githubusercontent.com/0xdavid7/contract-deployer/main/install.sh | bash
See INSTALLATION.md for detailed installation instructions.
git clone https://github.com/0xdavid7/contract-deployer.git
cd contract-deployer
cargo build --release
cp target/release/contract-deployer ~/.local/bin/
- Rust 1.70.0+
- Git
- Foundry (forge, cast, anvil)
git clone https://github.com/0xdavid7/contract-deployer.git
cd contract-deployer
cargo build
cargo test
# Start local network
anvil
# Test with development config
cargo run -- --config examples/development.toml
contract-deployer/
βββ src/
β βββ main.rs # Entry point
β βββ cli.rs # Command line interface
β βββ config.rs # TOML configuration
β βββ environment.rs # Environment management
β βββ deployer.rs # Core deployment logic
βββ examples/ # Configuration examples
βββ .github/workflows/ # CI/CD pipeline
- Configuration Parser - Handles TOML parsing and validation
- Environment Manager - Loads and expands environment variables
- Git Integration - Clones repositories with SSH/HTTPS authentication
- Forge Integration - Executes forge scripts with proper authentication
- Network Manager - Handles multi-network deployments
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Follow Rust best practices
- Add tests for new features
- Update documentation
- Ensure CI passes
This project is licensed under the MIT License - see the LICENSE file for details.
- Foundry - The underlying deployment infrastructure
- Rust Community - For excellent tooling and libraries
- Ethereum Ecosystem - For the standards and infrastructure
- Documentation: This README and INSTALLATION.md
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Windows Support - Add Windows binaries and installer
- Package Managers - Homebrew, Chocolatey, AUR packages
- Interactive Mode - CLI wizard for configuration creation
- Deployment History - Track and manage past deployments
- Multi-sig Support - Enhanced support for multi-signature deployments
- Plugin System - Extensible architecture for custom deployment workflows
Deploy smart contracts with confidence!