Docs
Search⌘ K
  • Home
  • حول The Graph
  • الشبكات المدعومة
  • Protocol Contracts
  • Subgraphs
    • متعدد-السلاسل
      • Token API
        • Hypergraph
          • AI Suite
            • Indexing
              • Resources
                Subgraphs > How-to Guides

                2 minutes

                Smart Contract Analysis with Cana CLI

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

                نظره عامة

                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+⁠
                • npm v6+⁠
                • Block explorer API keys

                Installation & Setup

                1. Install Cana CLI

                Use npm to install it globally:

                1npm install -g contract-analyzer
                1. Configure Cana CLI

                Set up a blockchain environment for analysis:

                1cana 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:

                1cana chains

                Then select a chain with this command:

                1cana 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:

                1cana analyze 0xContractAddress

                or

                1cana -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:

                1contracts-analyzed/2└── ContractName_chainName_YYYY-MM-DD/3  ├── contract/            # Folder for individual contract files4  ├── abi.json              # Contract ABI5  └── 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:

                1cana setup             # Add a new chain2cana chains            # List configured chains3cana 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.

                ⁠Edit on GitHub⁠

                Query Polymarket DataPruning with indexerHints
                On this page
                • نظره عامة
                • Key Features
                • Prerequisites
                • Installation & Setup
                • Steps: Using Cana CLI for Smart Contract Analysis
                • Troubleshooting
                • Conclusion
                The GraphStatusTestnetBrand AssetsForumSecurityPrivacy PolicyTerms of Service