Skip to main content
The ChainGuard CLI provides quick access to security scanning from your terminal.

Installation

npm install -g chainguard-cli
or
npx chainguard-cli <command>

Configuration

Set your API key:
chainguard config set api-key cg_live_xxxxxxxx
Or use environment variable:
export CHAINGUARD_API_KEY=cg_live_xxxxxxxx

Commands

scan

Scan URLs, contracts, wallets, or transactions.
# Scan a URL
chainguard scan url https://example.com

# Scan a contract
chainguard scan contract 0xdAC17F958D2ee523a2206206994597C13D831ec7 --chain ethereum

# Scan a wallet
chainguard scan wallet 0x742d35Cc6634C0532925a3b844Bc454c459dFE2C

# Scan with JSON output
chainguard scan url https://example.com --json

Options

  • --chain, -c: Blockchain network (ethereum, bsc, polygon).
  • --json, -j: Output as JSON.
  • --verbose, -v: Show detailed output.
  • --timeout, -t: Request timeout in seconds.

risk

Get risk scores and reports.
# Quick score
chainguard risk score 0x742d35Cc6634C0532925a3b844Bc454c459dFE2C

# Full report
chainguard risk report 0x742d35Cc6634C0532925a3b844Bc454c459dFE2C

# Export report as PDF
chainguard risk report 0x... --format pdf --output report.pdf

watch

Monitor entities in real-time.
# Watch a contract for risk changes
chainguard watch 0xdAC17F958D2ee523a2206206994597C13D831ec7

# Watch multiple addresses
chainguard watch 0x... 0x... 0x...

# Watch with custom threshold
chainguard watch 0x... --threshold 50

batch

Process multiple entities from a file.
# Create input file
cat > addresses.txt << EOF
0xdAC17F958D2ee523a2206206994597C13D831ec7
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
0x6B175474E89094C44Da98b954EedcDC9BC55c6
EOF

# Batch scan
chainguard batch scan addresses.txt --chain ethereum --output results.json

# Batch risk scores
chainguard batch risk addresses.txt --output scores.csv

config

Manage CLI configuration.
# Set API key
chainguard config set api-key cg_live_xxxxxxxx

# Set default chain
chainguard config set default-chain ethereum

# View config
chainguard config list

# Reset config
chainguard config reset

Examples

Check a Token Before Buying

$ chainguard scan contract 0xDEAD... --chain bsc

╔═══════════════════════════════════════════════════════════╗
                    CONTRACT ANALYSIS
╠═══════════════════════════════════════════════════════════╣
  Address:     0xDEAD...
  Chain:       BSC
  Name:        SuspiciousToken
  Symbol:      SCAM
╠═══════════════════════════════════════════════════════════╣
  RISK SCORE:  🔴 92/100 (CRITICAL)                        ║
╠═══════════════════════════════════════════════════════════╣
  ⚠️  HONEYPOT DETECTED
  ⚠️  Sell tax: 99%
  ⚠️  Source not verified
  ⚠️  Contract deployed 2 hours ago
╠═══════════════════════════════════════════════════════════╣
  RECOMMENDATION: BLOCK - DO NOT INTERACT
╚═══════════════════════════════════════════════════════════╝

Quick URL Check

$ chainguard scan url https://metamask-claim.xyz

╔═══════════════════════════════════════════════════════════╗
                      URL ANALYSIS
╠═══════════════════════════════════════════════════════════╣
  URL:         https://metamask-claim.xyz
  Final URL:   https://metamask-claim.xyz/connect
╠═══════════════════════════════════════════════════════════╣
  RISK SCORE:  🔴 95/100 (CRITICAL)                        ║
╠═══════════════════════════════════════════════════════════╣
  ⚠️  Known phishing domain
  ⚠️  Typosquatting detected (metamask.io)                 ║
  ⚠️  Domain registered 3 days ago
╠═══════════════════════════════════════════════════════════╣
  RECOMMENDATION: BLOCK - PHISHING SITE
╚═══════════════════════════════════════════════════════════╝

Output Formats

Table (default)

Human-readable table format with colors.

JSON

chainguard scan url https://example.com --json
{
  "url": "https://example.com",
  "riskScore": 5,
  "riskLevel": "safe",
  "threats": [],
  "recommendation": "PROCEED"
}

CSV

chainguard batch risk addresses.txt --output results.csv

Exit Codes

  • 0: Success.
  • 1: General error.
  • 2: Invalid arguments.
  • 3: Authentication error.
  • 4: Rate limit exceeded.
  • 10+: Risk threshold exceeded.
Use exit codes in scripts:
chainguard scan contract 0x... --chain ethereum
if [ $? -ge 10 ]; then
  echo "High risk detected!"
fi

Shell Integration

Bash Completion

# Add to ~/.bashrc
source <(chainguard completion bash)

Zsh Completion

# Add to ~/.zshrc
source <(chainguard completion zsh)

CI/CD Integration

GitHub Actions

- name: Security Check
  run: |
    npm install -g chainguard-cli
    chainguard scan contract ${{ env.CONTRACT_ADDRESS }} --chain ethereum --json > scan-result.json
    
    RISK=$(jq '.riskScore' scan-result.json)
    if [ "$RISK" -gt 50 ]; then
      echo "::error::High risk contract detected"
      exit 1
    fi
The CLI caches results locally for 5 minutes to reduce API calls. Use --no-cache to force fresh scans.