A CLI tool for managing EVM chain configurations
- Interactive chain discovery and configuration
- Dynamic RPC health checking and failover
- Private key management
- Multiple RPC support per chain
- Environment variable interpolation
git clone https://github.com/marktoda/chainz.git
cd chainz
cargo install --path .# Initialize with interactive wizard
chainz init
# Add a new chain
chainz add
# List configured chains
chainz list
# execute a command for a given chain
chainz exec ethereum -- cast block-number
21532741
# Switch to a chain
chainz use ethereum
source .envChainz provides an interactive wizard for adding chains:
> chainz add
Chain Selection
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
? Type to search and select a chain
> ethereum (1)
optimism (10)
arbitrum (42161)
polygon (137)
...
RPC Configuration
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Testing RPCs...
β https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}
β https://eth.llamarpc.com
β https://mainnet.infura.io/v3/${INFURA_KEY}
Key Configuration
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
? Select a key
> default (0x123...789)
deployer (0xabc...def)
Add new key
Chain added: ethereum (ChainId: 1)List configured chains and their status:
> chainz list
Chain: ethereum
ββ ID: 1
ββ Active RPC: https://eth-mainnet.g.alchemy.com/v2/...
ββ Verification Key: 0xabc...def
ββ Key Name: default
Chain: optimism
ββ ID: 10
ββ Active RPC: https://opt-mainnet.g.alchemy.com/v2/...
ββ Verification Key: None
ββ Key Name: deployerUpdate chain configuration:
> chainz update
Testing all RPCs...
β ethereum: 2/3 RPCs working
β optimism: 1/1 RPCs working
β arbitrum: 0/1 RPCs working
? Select chain to update
? What would you like to update?
> RPC URL
Key
Verification API KeySwitch to a chain and set up environment:
> chainz use ethereum
Chain: ethereum
ββ ID: 1
ββ RPC: https://rpc.com
ββ Wallet: 0x123...789
> source .env
> echo $ETH_RPC_URL
https://rpc.comExecute commands with chain context:
> chainz exec 1 -- cast block-number
21532741
> chainz exec ethereum -- cast balance @wallet
1.5 ETH
> chainz exec 10 -- forge script DeployAdd and manage private keys:
> chainz key add deployer
Enter private key: ****
Added key 'deployer'
> chainz key list
Stored keys:
- default: 0x123...789
- deployer: 0xabc...defSet and use custom variables:
> chainz var set ALCHEMY_KEY abc123
> chainz var set ETHERSCAN_KEY def456
> chainz var list
ALCHEMY_KEY=abc123
ETHERSCAN_KEY=def456Configs are stored at $HOME/.chainz.json:
{
"chains": [
{
"name": "ethereum",
"chain_id": 1,
"rpc_urls": [
"https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}",
"https://eth.llamarpc.com"
],
"selected_rpc": "https://eth.llamarpc.com",
"verification_api_key": "abc123",
"key_name": "default"
}
],
"variables": {
"ALCHEMY_KEY": "def456"
},
"keys": {
"default": {
"type": "PrivateKey",
"value": "0x123..."
}
}
}- test onepassword key type
- fix keychain type
- clean up globalvariables structuring