Skip to content

rohan911438/Avalanche-AI-copilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Avalanche AI Copilot: Smart Contract Development Platform

Avalanche Logo

Executive Summary

Avalanche AI Copilot is an advanced web-based development platform designed to revolutionize blockchain development on Avalanche. By leveraging Google's Gemini AI, the platform provides intelligent contract generation, analysis, and deployment capabilities, drastically reducing the learning curve for blockchain developers and accelerating time-to-market for decentralized applications.

๐Ÿš€ Key Features

Smart Contract Generation

  • AI-Powered Contract Creation: Convert natural language descriptions into professional-grade Solidity contracts
  • OpenZeppelin Integration: Automatically incorporate security best practices through industry-standard libraries
  • Inline Dependency Resolution: Seamlessly handle all contract dependencies without import errors
  • Template Library: Access pre-built templates for common contract types (ERC20, ERC721, Marketplaces, etc.)

Smart Contract Analysis

  • Code Explanation: Transform complex Solidity into plain English descriptions
  • Security Audit Highlights: Identify potential vulnerabilities and security concerns
  • Gas Optimization Tips: Suggestions for reducing transaction costs
  • Best Practices Review: Ensure adherence to Avalanche development standards

Deployment & Testing

  • One-Click Deployment: Deploy directly to Avalanche Fuji Testnet or C-Chain Mainnet
  • MetaMask Integration: Seamless wallet connection for transaction signing
  • Network Configuration: Pre-configured connection to Avalanche networks
  • Transaction Monitoring: Track contract deployment status in real-time
  • Snowtrace Integration: Instant access to blockchain explorer for verification

Advanced Features

  • Gemini Contract Processing: Automated fixing of AI-generated contracts
  • Custom Contract Templates: Save and reuse your contract designs
  • Import Resolution: Automatically handle OpenZeppelin dependencies
  • Contract Verification: Verify contract source code on Snowtrace

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     Frontend        โ”‚    โ”‚     Backend        โ”‚    โ”‚   Blockchain    โ”‚
โ”‚  (Next.js/React)    โ”‚โ—„โ”€โ”€โ–บโ”‚  (Express/Node.js) โ”‚โ—„โ”€โ”€โ–บโ”‚    Networks     โ”‚
โ”‚                     โ”‚    โ”‚                    โ”‚    โ”‚                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ โ€ข Contract Editor   โ”‚    โ”‚ โ€ข Google Gemini AI โ”‚    โ”‚ โ€ข Avalanche     โ”‚
โ”‚ โ€ข MetaMask Connect  โ”‚    โ”‚ โ€ข Contract Fixer   โ”‚    โ”‚   Fuji Testnet  โ”‚
โ”‚ โ€ข Deployment UI     โ”‚    โ”‚ โ€ข Solidity Compilerโ”‚    โ”‚ โ€ข Avalanche     โ”‚
โ”‚ โ€ข Template Selector โ”‚    โ”‚ โ€ข Import Resolver  โ”‚    โ”‚   C-Chain       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Technology Stack

Frontend

  • Framework: Next.js with React
  • UI Components: Tailwind CSS
  • Blockchain Connectivity: ethers.js
  • Wallet Integration: MetaMask
  • Code Editor: React-based code editor with syntax highlighting

Backend

  • Server: Node.js with Express
  • AI Integration: Google Gemini API
  • Contract Processing: Custom processing pipeline for AI-generated contracts
  • Compilation: solc.js and Hardhat compilation engine
  • Security: Import sanitization and validation

Blockchain

  • Networks: Avalanche Fuji Testnet and C-Chain Mainnet
  • Contract Standards: ERC20, ERC721, ERC1155
  • Libraries: OpenZeppelin (local vendor approach)
  • Explorer: Snowtrace API integration

๏ฟฝ Development Workflow

1. Contract Generation

Users describe their desired contract functionality in natural language, and the system:

  • Processes the request through Google's Gemini AI
  • Applies custom transformations to ensure compilation success
  • Inlines all necessary dependencies
  • Produces a complete, ready-to-deploy contract

2. Contract Analysis

Upload existing contracts to:

  • Receive plain English explanations of functionality
  • Identify potential security issues
  • Understand gas optimization opportunities
  • Review against best practices

3. Contract Deployment

With a finalized contract, users can:

  • Connect their MetaMask wallet
  • Select target network (Testnet/Mainnet)
  • Deploy with a single click
  • Monitor transaction status
  • View deployed contract on Snowtrace

๐ŸŒŸ Unique Innovations

1. AI Contract Processing Pipeline

Our system implements a sophisticated multi-stage processing pipeline for AI-generated contracts:

  • Pre-processing: Cleans Markdown artifacts and formats code
  • Dependency Analysis: Identifies required OpenZeppelin contracts
  • Dependency Resolution: Inlines necessary code without imports
  • Compiler Feedback Loop: Uses compilation errors to guide fixes
  • Post-processing: Optimizes gas usage and improves readability

2. Contract Pattern Recognition

The platform includes an advanced pattern recognition system that:

  • Identifies common contract types (tokens, NFTs, marketplaces)
  • Suggests appropriate security features
  • Recommends established patterns for common functionality
  • Ensures compliance with Avalanche best practices

3. OpenZeppelin Integration Strategy

Unlike traditional import-based approaches, we implement:

  • Local vendor approach for core contracts
  • Dynamic inline resolution of dependencies
  • Consistent versioning across projects
  • Optimized code through selective inclusion

๐Ÿš€ Getting Started

Prerequisites

  • Node.js (v18+)
  • Google Gemini API key
  • MetaMask browser extension for deployment
  • AVAX tokens for deployment (use the Avalanche Faucet for Fuji Testnet)

Installation

  1. Clone the repository

    git clone https://github.com/rohan911438/Avalanche-AI-copilot.git
    cd Avalanche-AI-copilot
  2. Install backend dependencies

    cd backend
    npm install
  3. Configure backend environment variables

    # Create/edit .env file in the backend directory
    GEMINI_API_KEY=your_gemini_api_key
    PORT=3001
  4. Install frontend dependencies

    cd ../avalanche-frontend
    npm install

Running the Application

  1. Start the backend server

    cd backend
    node server.js

    The server will start on port 3001 (or the port specified in your .env file). You should see: "๐Ÿš€ Server running on port 3001"

  2. Start the frontend development server

    cd avalanche-frontend
    npm run dev
  3. Access the application Open your browser and navigate to http://localhost:3000

Using the Application

  1. Generate a Contract:

    • Navigate to the "Generate" tab
    • Enter a description of the contract you want to create
    • Click "Generate Contract"
  2. Explain a Contract:

    • Navigate to the "Explain" tab
    • Paste the Solidity code you want to analyze
    • Click "Explain Contract"
  3. Deploy a Contract:

    • Navigate to the "Deploy" tab
    • Ensure you have a contract ready (either generated or pasted)
    • Connect your MetaMask wallet
    • Select the network (Fuji Testnet recommended for testing)
    • Click "Compile Contract" and then "Deploy to Avalanche"
    • Confirm the transaction in MetaMask
    • View your deployed contract on Snowtrace

Troubleshooting

Backend won't start:

  • Ensure you have installed all dependencies: npm install
  • Verify your .env file contains the required GEMINI_API_KEY
  • Check if the port is already in use

MetaMask Connection Issues:

  • Ensure MetaMask is installed and unlocked
  • Add Avalanche networks to MetaMask if they aren't already configured

Deployment Errors:

  • For Fuji Testnet: Make sure you have testnet AVAX from the faucet
  • Check compilation errors in the console
  • Verify you're on the correct network in MetaMask

๐Ÿ”— Links

๐Ÿ”ฎ Future Roadmap

  • Contract Interaction Interface: GUI for interacting with deployed contracts
  • Contract Verification: Automated verification on Snowtrace
  • Advanced Template System: Expanded library of contract templates
  • Multi-contract Projects: Support for complex multi-contract systems
  • Gas Optimization Engine: Advanced suggestions for gas efficiency
  • Automated Testing: Generation of unit tests for contracts

๐Ÿค Contributing

We welcome contributions from the community! Please see our Contributing Guide for details.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details. Copyright (c) 2025 Rohan Kumar (@rohan911438).

๐Ÿ”— Resources

๐Ÿ”ง Configuration for MetaMask

To configure MetaMask for Avalanche networks:

Fuji Testnet:

Network Name: Avalanche Fuji Testnet
New RPC URL: https://api.avax-test.network/ext/bc/C/rpc
Chain ID: 43113 (0xA869 in hex)
Currency Symbol: AVAX
Block Explorer URL: https://testnet.snowtrace.io/

Avalanche Mainnet:

Network Name: Avalanche C-Chain
New RPC URL: https://api.avax.network/ext/bc/C/rpc
Chain ID: 43114 (0xA86A in hex)
Currency Symbol: AVAX
Block Explorer URL: https://snowtrace.io/

Built with โค๏ธ by Rohan Kumar (@rohan911438) for the Avalanche developer community

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors