Stargate
Blockchain network switcher CLI for Foundry. Switch between networks and automatically set ETH_RPC_URL for forge/cast.
Installation
Add to your ~/.zshrc (or ~/.bashrc for bash):
Restart your shell or run source ~/.zshrc to activate.
Configuration
Set your Alchemy API key:
# Interactive mode (recommended - input is hidden)
# Or pass directly (visible in shell history)
Config is stored at ~/.stargate/config.toml.
Usage
# Switch to a network (by name, alias, or chain ID)
# Switch to local anvil
# See current network
# List all networks
# Open block explorer
Supported Networks
| Network | Aliases | Chain ID |
|---|---|---|
| mainnet | eth, ethereum | 1 |
| polygon | - | 137 |
| optimism | op | 10 |
| arbitrum | arb | 42161 |
| base | - | 8453 |
| bnb | bsc | 56 |
| linea | - | 59144 |
| ink | - | 57073 |
| anvil | local | 31337 |
Environment Variables
After running switch <network>, these are exported:
ETH_RPC_URL- RPC endpoint (Foundry reads this automatically)BLOCK_EXPLORER- Block explorer base URLSTARGATE_NETWORK- Current network nameSTARGATE_CHAIN_ID- Current chain ID
Starship Integration
Starship users can display the current network name in their prompt by adding this to their starship.toml:
# display the network name currently connected with cast
[]
= 'local'
= "[$env_value]($style)"
Developers
Building from Source
The binary will be at target/release/stargate.
Local Installation
Option 1: Install globally (replaces any existing installation)
Option 2: Test without installing
Build and run directly:
Test shell integration with local build:
# Test switch output
# Test init output
# Test full integration
Running Tests
Git Hooks
This project uses lefthook for git hooks.
# Install lefthook (macOS)
# Install hooks
Hooks run automatically on commit (fmt, clippy) and push (test, build).