Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions website/src/pages/en/subgraphs/guides/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export default {
enums: '',
'secure-api-keys-nextjs': '',
polymarket: '',
'contract-analyzer': '',
}
103 changes: 103 additions & 0 deletions website/src/pages/en/subgraphs/guides/contract-analyzer.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
title: Smart Contract Analysis with Cana CLI
---

# Cana CLI: Quick & Efficient Contract Analysis

Check failure on line 5 in website/src/pages/en/subgraphs/guides/contract-analyzer.mdx

View workflow job for this annotation

GitHub Actions / lint

Unexpected first heading rank `1`, expected rank `2`

Check failure on line 5 in website/src/pages/en/subgraphs/guides/contract-analyzer.mdx

View workflow job for this annotation

GitHub Actions / lint

Element {"type":"heading","depth":1} is restricted

**Cana CLI** is a command-line tool that streamlines helpful smart contract metadata analysis specific to subgraph development across multiple EVM-compatible chains.

## 📌 Key Features

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

## 🚀 Installation & Setup

Install Cana globally using npm:

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

Set up a blockchain for analysis:

```bash
cana setup
```

Provide the required block explorer API and block explorer endpoint URL details when prompted.

Running `cana setup` 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.

## 🍳 Usage

### 🔹 Chain Selection

Cana supports multiple EVM-compatible chains.

List chains added with:

```bash
cana chains
```

Then select a chain with:

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

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

### 🔹 Basic Contract Analysis

Analyze a contract with:

```bash
cana analyze 0xContractAddress
```

or

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

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

### 🔹 Understanding Output

Cana organizes results into the terminal as well as 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
```

### 🔹 Chain Management

Add and manage chains:

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

## ⚠️ Troubleshooting

- **Missing Data**: Ensure the contract address is correct, verified on the block explorer, and that your API key has the required permissions.

## ✅ Requirements

- Node.js v16+
- npm v6+
- Block explorer API keys

Keep your contract analyses efficient and well-organized. 🚀
Loading