Logo

dev-resources.site

for different kinds of informations.

πŸš€ Getting Started with kritisi CLI: An AI-Driven Security Tool for Solidity

Published at
12/14/2024
Categories
blockchain
security
solidity
ethereum
Author
zororaka
Author
8 person written this
zororaka
open
πŸš€ Getting Started with kritisi CLI: An AI-Driven Security Tool for Solidity

The kritisi CLI is a powerful tool for developers working with Solidity smart contracts. It leverages AI to enhance code quality, detect vulnerabilities, and ensure compliance with best practices. Let’s dive into how to install and use this tool step by step.


✨ Features

  • πŸ” Set API Keys for AI services like OpenAI and Groq.
  • πŸ€– Set AI Models for tailored results.
  • πŸ› οΈ Merge Solidity Files with ease.
  • πŸ“ Generate NatSpec Documentation using AI.
  • πŸ“Š Run Security Audits with detailed severity reports.

πŸš€ Installation

First, ensure you have Node.js installed on your system. Then install the kritisi CLI globally:

npm install -g kritisi
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

kritisi --version
Enter fullscreen mode Exit fullscreen mode

πŸ› οΈ Usage Guide

1. Register for API Keys

To use AI features, you need API keys from OpenAI and Groq. Follow these steps:

OpenAI

  1. Go to OpenAI.
  2. Sign up or log in to your account.
  3. Navigate to the API section and generate a new API key.
  4. Save the API key securely.

Groq

  1. Visit Groq and create an account.
  2. Once logged in, go to the developer section to generate an API key.
  3. Save the API key securely.

2. Set Your API Key

After obtaining API keys, set them up for the selected service.

Command:

kritisi setkey --service <service>
Enter fullscreen mode Exit fullscreen mode

Example:

kritisi setkey --service openai
Enter fullscreen mode Exit fullscreen mode

You will be prompted to enter your API key interactively. For example:

Enter the API key openai:
Enter fullscreen mode Exit fullscreen mode

Once entered, the key will be securely saved.

3. Set AI Model

Select the AI model for the service you’re using.

Command:

kritisi setmodel --service <service>
Enter fullscreen mode Exit fullscreen mode

Example:

kritisi setmodel --service openai
Enter fullscreen mode Exit fullscreen mode

You will be prompted to enter the model name interactively:

Enter the model name for openai (e.g., 'gpt-4'):
Enter fullscreen mode Exit fullscreen mode

4. Merge Solidity Files

Combine all imported Solidity files into a single file with this handy command.

Command:

kritisi merger --path <path-to-solidity-file>
Enter fullscreen mode Exit fullscreen mode

Example:

kritisi merger --path ./contracts/MyContract.sol
Enter fullscreen mode Exit fullscreen mode

This will generate a merged file with _merge appended to the original file name.

5. Add NatSpec Documentation

Automatically add NatSpec comments to your Solidity code.

Command:

kritisi natspec --service <service> --path <path-to-solidity-file>
Enter fullscreen mode Exit fullscreen mode

Example:

kritisi natspec --service openai --path ./contracts/MyContract.sol
Enter fullscreen mode Exit fullscreen mode

6. Run Security Audit

Analyze your smart contract for security vulnerabilities and generate a detailed report.

Command:

kritisi security --service <service> --path <path-to-solidity-file>
Enter fullscreen mode Exit fullscreen mode

Example:

kritisi security --service groq --path ./contracts/MyContract.sol
Enter fullscreen mode Exit fullscreen mode

The security report will be saved as a PDF in the same directory.


πŸ“š Example Workflow

Let’s walk through a simple example:

  1. Register for API Keys:

  2. Set the OpenAI API Key:

    kritisi setkey --service openai
    

    Enter your API key when prompted.

  3. Set the AI Model:

    kritisi setmodel --service openai
    

    Provide the model name (e.g., gpt-4).

  4. Run a Security Audit:

    kritisi security --service openai --path ./contracts/MyContract.sol
    

    Check the generated PDF for the detailed report.


πŸ”§ Troubleshooting

  • If you encounter errors related to missing API keys, ensure you have set them using the setkey command.
  • Use the --help flag with any command to get detailed usage instructions:
kritisi <command> --help
Enter fullscreen mode Exit fullscreen mode

🌟 Conclusion

The kritisi CLI empowers Solidity developers with AI-driven insights, streamlining the auditing and documentation process. Whether you're ensuring security compliance or generating comprehensive documentation, this tool has you covered.


πŸ› οΈ Resources

Happy Coding! πŸŽ‰

solidity Article's
30 articles in total
Favicon
Have You Fallen for a Phishing Scam? Let’s Talk About It πŸ‘€
Favicon
Solidity
Favicon
Why Every Crypto Developer Should Understand Tokenomics πŸš€
Favicon
How we used the ERC-2535 Diamonds at Proof of Peacemaking Protocol
Favicon
πŸ” Solidity Limitations, Solutions, Best Practices and Gas Optimization πŸš€
Favicon
go调用solidityεˆηΊ¦ζ–°ζ–Ήζ³•
Favicon
βš–οΈ The Importance of Using ReentrancyGuard in Solidity Smart Contract
Favicon
Formal Verification: An Example
Favicon
OverFlow and UnderFlow causes in Solidity
Favicon
When to Use ERC-721 vs ERC-1155: Choosing the Right NFT Standard
Favicon
Solidity Pattern - Proxy Delegate and Decorator Patterns
Favicon
Solidity Patterns - CEI
Favicon
Foundry vs Hardhat (A story version)
Favicon
Energy NFT Marketplace
Favicon
OverFlow and UnderFlow causes in Solidity
Favicon
πŸš€ Getting Started with kritisi CLI: An AI-Driven Security Tool for Solidity
Favicon
Formal Verification: The Foundation of Ethereum Smart Contracts
Favicon
The Danger of Randomness in Smart Contracts and its solution
Favicon
What is Reentrancy?
Favicon
Understanding approve and depositCollateral: The Core of ERC-20 Token Transfers in Solidity
Favicon
Ethereum Transaction Calls and State Changes
Favicon
Creating a Toy Solidity compiler and running it in a Toy EVM
Favicon
Send Tokens in Bulk with Low Fees and Fast Delivery: The Ultimate Airdrop Tool for 2024
Favicon
πŸ›‘οΈ Why Using OpenZeppelin in Smart Contracts Is Essential
Favicon
The delegatecall Function in Solidity
Favicon
The delegatecall Function in Solidity
Favicon
A Walkthrough of Solidity Custom Errors
Favicon
How to write dynamic staking smart contract step by step in practice
Favicon
Mainnet Forking in Foundry
Favicon
Every Blockchain Developer Must Know About This Scam!

Featured ones: