A modern, interactive command-line tool for managing Safe Smart Accounts
Built on top of the Safe Core SDK, Safe CLI makes it easy to create, manage, and interact with Safe multi-signature wallets directly from your terminal.
Safe CLI provides a powerful command-line interface for:
- Creating and managing Safe accounts without using the web interface
- Coordinating multi-signature transactions with your team
- Interacting with smart contracts through an intuitive transaction builder
- Automating Safe operations in scripts and workflows
- Managing multiple Safes across different chains from one place
- Hardware wallet support - Use Ledger devices for maximum security
Perfect for developers, power users, and teams who prefer working in the terminal.
- π Secure wallet management - Encrypted private key storage with AES-256-GCM + Ledger hardware wallet support
- βοΈ Multi-chain support - Works with Ethereum, Polygon, Arbitrum, Optimism, Base, and more
- π¨ Beautiful interface - Modern terminal UI with interactive prompts
- π¦ Safe lifecycle - Create, deploy, and manage Safe accounts
- π Transaction handling - Create, sign, and execute transactions
- π€ Smart contract interaction - Automatic ABI fetching and interactive function builder
- π Proxy support - Detects and handles EIP-1967 proxy contracts
- π₯ Owner management - Add/remove owners and change thresholds
- π Multi-sig coordination - Multiple workflows for collecting signatures
- π₯ Transaction import - Import from Safe web app's Transaction Builder
# Install globally
npm install -g @safe-global/safe-cli
# Or run without installing
npx @safe-global/safe-cli1. Initialize configuration
safe config initThis sets up your chain configurations and optional API keys.
2. Set up a wallet
# Option A: Create a new wallet (generates private key)
safe wallet create
# Option B: Import existing private key
safe wallet import
# Option C: Import Ledger hardware wallet (recommended for production)
safe wallet import-ledgerPrivate keys are encrypted with a password. Ledger wallets use your hardware device for signing.
3. Create your first Safe
safe account createFollow the interactive prompts to configure owners and threshold.
That's it! You're ready to manage Safe accounts from your terminal.
| Command | Description |
|---|---|
safe config init |
Set up CLI for first use (includes API keys) |
safe config show |
View current configuration |
safe config chains list |
List configured networks |
safe config chains add |
Add a custom network |
safe config chains remove |
Remove a network |
safe config chains edit |
Edit chains in your text editor |
| Command | Description |
|---|---|
safe wallet create |
Create a new wallet with a generated private key |
safe wallet import |
Import a wallet with your existing private key |
safe wallet import-ledger |
Import a Ledger hardware wallet |
safe wallet list |
View all your wallets (shows wallet types) |
safe wallet use |
Switch to a different wallet |
safe wallet remove |
Delete a wallet |
| Command | Description |
|---|---|
safe account create |
Create a new Safe |
safe account deploy [address] |
Deploy a predicted Safe to the blockchain |
safe account open [address] |
Add an existing Safe to your workspace |
safe account list |
View all your Safes |
safe account info [address] |
Show Safe details (owners, threshold, balance) |
safe account add-owner [address] |
Add a new owner |
safe account remove-owner [address] |
Remove an owner |
safe account change-threshold [address] |
Change signature threshold |
π‘ Tip: Most commands support EIP-3770 format (eth:0x123...) or will prompt you interactively.
| Command | Description |
|---|---|
safe tx create |
Create a new transaction |
safe tx sign [txHash] |
Sign a transaction |
safe tx execute [txHash] |
Execute a transaction |
safe tx list |
View transactions |
safe tx status [txHash] |
Check signature progress |
safe tx export [txHash] |
Export as JSON for sharing |
safe tx import [json] |
Import from JSON |
Multi-sig Coordination:
| Command | Description |
|---|---|
safe tx push [txHash] |
Upload to Safe Transaction Service |
safe tx pull |
Download pending transactions |
safe tx sync |
Sync local and remote transactions |
# 1. Create a Safe (gets predicted address)
safe account create
# 2. Deploy it to the blockchain
safe account deploy eth:0x742d35Cc...# Create and sign a transaction
safe tx create
# β Select your Safe
# β Enter recipient address
# β Enter amount in wei
# β Sign it
# If you're the only signer needed, execute immediately
safe tx execute <txHash>
# Or, share the transaction with other signers (see Multi-sig section)safe tx create
# β Select your Safe
# β Enter contract address
# The CLI automatically:
# β Detects it's a contract
# β Fetches the ABI from Etherscan/Sourcify
# β Shows you all available functions
# β Helps you fill in parameters with validation
# β Encodes the transaction
# Then sign and execute as usualOption A: Using Safe Transaction Service (Recommended)
# Owner 1: Create and push
safe tx create
safe tx sign <txHash>
safe tx push <txHash>
# Owner 2: Pull and sign
safe tx pull
safe tx sign <txHash>
safe tx push <txHash>
# Any owner: Execute when threshold is met
safe tx execute <txHash>Option B: Offline with JSON Export
# Owner 1: Create and export
safe tx create
safe tx sign <txHash>
safe tx export <txHash>
# β Share the JSON with other owners
# Owner 2: Import and sign
safe tx import '{"safeTxHash":"0x..."...}'
safe tx sign <txHash>
# Check progress
safe tx status <txHash> # Shows "2/3 signatures"
# Execute when ready
safe tx execute <txHash>Configuration files are stored in:
- macOS:
~/Library/Preferences/safe-cli/ - Linux:
~/.config/safe-cli/ - Windows:
%APPDATA%\safe-cli\
Pre-configured for 18+ networks including:
- Ethereum, Sepolia (testnet)
- Layer 2s: Arbitrum, Optimism, Base, Polygon, zkSync Era, Polygon zkEVM, Scroll, Linea
- Alternative L1s: BNB Chain, Gnosis Chain, Avalanche, Celo, Aurora
- Emerging chains: Mantle, World Chain, Sonic, Unichain
Add custom networks with safe config chains add.
These are optional but recommended for enhanced functionality:
Get it from: Safe Developer Dashboard
Enables:
- Multi-sig coordination via Safe Transaction Service
- Push/pull transactions
- Integration with Safe web interface
Without it: You can still use offline JSON export/import for multi-sig.
Get it from: Etherscan (free)
Enables:
- Proxy contract detection (EIP-1967)
- Better ABI fetching for proxies
- Automatic ABI merging for proxy + implementation
Without it: Uses Sourcify as fallback (still works, but no proxy detection).
Setup: Run safe config init and follow the prompts, or edit the config file manually.
- Key generation: Uses Node.js crypto.randomBytes() for cryptographically secure random generation
- Encryption: Private keys encrypted with AES-256-GCM
- Key derivation: PBKDF2 with 100,000 iterations
- Local storage: All data stored locally on your machine
- No exposure: Keys never logged or transmitted in plain text
- Backup verification: Confirmation required when creating new wallets
- Maximum security: Private keys never leave the device
- Physical confirmation: All transactions require on-device approval
- Industry standard: BIP44 derivation paths
- Secure Element: Military-grade chip protection
Recommendation: Use Ledger hardware wallets for production Safe accounts with significant funds.
- Node.js >= 18.0.0
- npm or yarn
# Clone the repository
git clone https://github.com/5afe/safe-cli-nodejs.git
cd safe-cli-nodejs
# Install dependencies
npm install
# Run in development mode
npm run dev
# Type checking
npm run typecheck
# Run tests
npm test
# Build
npm run buildsrc/
βββ commands/ # Command implementations
β βββ config/ # Configuration commands
β βββ wallet/ # Wallet management (incl. Ledger)
β βββ account/ # Safe account operations
β βββ tx/ # Transaction commands
βββ services/ # Business logic
β βββ safe-service.ts
β βββ transaction-service.ts
β βββ ledger-service.ts # Ledger hardware wallet integration
β βββ abi-service.ts
β βββ validation-service.ts
βββ storage/ # Persistent storage
β βββ config-store.ts
β βββ wallet-store.ts
β βββ transaction-store.ts
βββ ui/ # Terminal UI components (React/Ink)
βββ types/ # TypeScript type definitions
βββ utils/ # Utility functions
- TypeScript - Type safety
- Commander.js - CLI framework
- React + Ink - Terminal UI
- @clack/prompts - Interactive prompts
- Viem - Ethereum utilities
- Safe Core SDK - Safe protocol integration
- LedgerJS - Hardware wallet integration
- Zod - Runtime validation
Contributions are welcome! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
npm test) - Commit with a clear message
- Push and open a Pull Request
Please ensure:
- Tests pass (
npm test) - TypeScript compiles (
npm run typecheck) - Code is formatted (
npm run format)
LGPL-3.0
Made with β€οΈ for the Safe community