---
title: Smart Contract Analysis with Cana CLI
---

Improve smart contract analysis with **Cana CLI**. It's fast, efficient, and designed specifically for EVM chains.

## Overview

**Cana CLI** is a command-line tool that streamlines helpful smart contract metadata analysis specific to subgraph development across multiple EVM-compatible chains. It simplifies retrieving contract details, detecting proxy implementations, extracting ABIs, and more.

### Key Features

With Cana CLI, you can:

- Detect deployment blocks
- Verify source code
- Extract ABIs & event signatures
- Identify proxy and implementation contracts
- Support multiple chains

### Prerequisites

Before installing Cana CLI, make sure you have:

- [Node.js v16+](https://nodejs.org/en)
- [npm v6+](https://docs.npmjs.com/cli/v11/commands/npm-install)
- Block explorer API keys

### Installation & Setup

1. Install Cana CLI

Use npm to install it globally:

```bash
npm install -g contract-analyzer
```

2. Configure Cana CLI

Set up a blockchain environment for analysis:

```bash
cana setup
```

During setup, you'll be prompted to provide the required block explorer API key and block explorer endpoint URL.

After setup, Cana CLI creates a configuration file at `~/.contract-analyzer/config.json`. This file stores your block explorer API credentials, endpoint URLs, and chain selection preferences for future use.

### Steps: Using Cana CLI for Smart Contract Analysis

#### 1. Select a Chain

Cana CLI supports multiple EVM-compatible chains.

For a list of chains added run this command:

```bash
cana chains
```

Then select a chain with this command:

```bash
cana chains --switch <chain>
```

Once a chain is selected, all subsequent contract analyses will continue on that chain.

#### 2. Basic Contract Analysis

Run the following command to analyze a contract:

```bash
cana analyze 0xContractAddress
```

or

```bash
cana -a 0xContractAddress
```

This command fetches and displays essential contract information in the terminal using a clear, organized format.

#### 3. Understanding the Output

Cana CLI organizes results into the terminal and into a structured directory when detailed contract data is successfully retrieved:

```
contracts-analyzed/
└── ContractName_chainName_YYYY-MM-DD/
  ├── contract/            # Folder for individual contract files
  ├── abi.json              # Contract ABI
  └── event-information.json # Event signatures and examples
```

This format makes it easy to reference contract metadata, event signatures, and ABIs for subgraph development.

#### 4. Chain Management

Add and manage chains:

```bash
cana setup             # Add a new chain
cana chains            # List configured chains
cana chains -s <chain> # Switch chains
```

### Troubleshooting

Missing Data? Ensure that the contract address is correct, that it's verified on the block explorer, and that your API key has the required permissions.

### Conclusion

With Cana CLI, you can efficiently analyze smart contracts, extract crucial metadata, and support subgraph development with ease.
