Skip to content

blinderchief/Aya_Hackathon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Aya Wallet - AI-Powered Crypto Assistant

Contact Information

  • Primary Contact: Suyash Kumar Singh
  • Telegram: @blinderchief
  • Team: Solo

Project Title

Aya Wallet - AI-Powered Cryptocurrency Assistant with Model Context Protocol (MCP)

Elevator Pitch

Aya Wallet is an AI-powered cryptocurrency wallet that understands natural language commands to handle everything from booking flights with crypto to swapping tokens across multiple blockchains.

Detailed Project Description

What is Aya Wallet?

Aya Wallet is a smart cryptocurrency wallet that lets you talk to your money. Instead of navigating complex menus or remembering blockchain addresses, you can simply type what you want to do in plain English.

For example, you can say:

  • "Book a flight from New York to Delhi on August 8th"
  • "Swap 2 ETH for USDC at the best rate"
  • "Bridge 1 ETH to Solana"
  • "Bid on Bored Ape #1234"
  • "Create a token on Hedera"

How Does It Work?

Aya Wallet uses a technology called Model Context Protocol (MCP) that breaks down your requests into specific actions across different domains:

  1. Booking MCP: Handles travel bookings and payments in cryptocurrency
  2. Hedera MCP: Manages operations on the Hedera blockchain
  3. Cross-Chain MCP: Transfers assets between different blockchains
  4. DeFi Swap MCP: Exchanges tokens at the best available rates
  5. NFT Auction MCP: Handles bidding on NFTs across marketplaces

The system has a central AI brain (using Comput3 or Gemini) that figures out what you're asking for and directs your request to the right specialized component.

Technical Features

  • Natural language processing for crypto transactions
  • Multi-blockchain support (Ethereum, Solana, Hedera)
  • Secure transaction handling with confirmation
  • Modular architecture that's easy to extend
  • Mock API implementation for demonstration purposes

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn
  • API keys for various services (Hedera, Infura, etc.)

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/aya-wallet-mcp.git
    cd aya-wallet-mcp
    
  2. Install dependencies:

    npm install
    
  3. Set up environment variables:

    # Copy the example environment file
    cp .env.example .env
    
    # Edit the .env file with your own API keys and credentials
    nano .env
    

    You'll need to obtain API keys for:

    • Comput3 AI or Gemini (choose one)
    • Booking.com via RapidAPI
    • Hedera account and private key
    • Infura for Ethereum access
    • Set a valid Ethereum address for payment receiving

Environment Variables

The following environment variables need to be configured in your .env file:

# AI Provider (choose one)
COMPUT3_API_KEY=your_comput3_api_key
COMPUT3_API_URL=https://api.comput3.ai/v1
COMPUT3_MODEL=llama3:70b

# Blockchain APIs
INFURA_KEY=your_infura_key
HEDERA_ACCOUNT=your_hedera_account_id
HEDERA_PRIVATE_KEY=your_hedera_private_key
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com

# Payment Configuration
PAYMENT_RECEIVER=0xYourValidEthereumAddress
PAYMENT_RECEIVER_SOLANA=YourSolanaAddress
PAYMENT_RECEIVER_HEDERA=0.0.YourHederaAccount

# External Service APIs
BOOKING_API_KEY=your_booking_api_key
HOTELS_API_KEY=your_hotels_api_key
RAPID_API_KEY=your_rapidapi_key

Important Note: Never commit your .env file to version control! It contains sensitive information.

Running the Application

  1. Start the server:

    npm start
    
  2. Open your browser and navigate to http://localhost:3000

Usage Examples

Booking a Flight

Input: "Book a flight from New York to Delhi on August 8th, 2023"
Output: 
[AI] I'll help you book a flight from New York to Delhi on August 8th, 2023.
[AI] Searching for available flights...
[AI] I found the following options:
     1. Air India ($850) - 14h 30m - 1 stop
     2. United Airlines ($920) - 15h 45m - 1 stop
     3. Emirates ($1100) - 18h 20m - 2 stops
[User] Select option 1
[AI] Great choice. The total is $850, which is 425 USDC. Would you like to proceed?
[User] Yes
[AI] Processing your payment...
[AI] Success! Your booking is confirmed. Booking reference: AI12345

Token Swap

Input: "Swap 2 ETH for USDC at the best rate"
Output:
[AI] I'll help you swap 2 ETH for USDC at the best rate.
[AI] Checking rates across exchanges...
[AI] Current rates:
     - Uniswap: 1 ETH = 1850 USDC
     - SushiSwap: 1 ETH = 1845 USDC
     - Curve: 1 ETH = 1852 USDC
[AI] The best rate is on Curve: 2 ETH = 3704 USDC
[AI] Would you like to proceed with this swap?
[User] Yes
[AI] Processing your swap...
[AI] Success! Swapped 2 ETH for 3704 USDC on Curve.
[AI] Transaction hash: 0x123...abc

Create Token on Hedera

Input: "Create a token called MyToken with 10000 supply on Hedera"
Output:
[AI] I'll help you create a token on Hedera.
[AI] Please provide the following details:
[AI] Token symbol?
[User] MTK
[AI] Decimals?
[User] 2
[AI] Processing your request to create MyToken (MTK) with 10000 supply and 2 decimals...
[AI] Success! Your token has been created.
[AI] Token ID: 0.0.12345
[AI] Transaction ID: 0.0.54321@1234567890

Known Issues and Troubleshooting

Common Issues

  1. Invalid Ethereum Address Error

    • Symptom: Error message "invalid address (argument="address", value="0x...", code=INVALID_ARGUMENT)"
    • Solution: Ensure you're using a valid Ethereum address in your .env file. Valid addresses are 42 characters long, starting with 0x followed by 40 hexadecimal characters.
  2. Booking Cancellation Not Working

    • Symptom: Attempting to cancel a booking doesn't trigger the cancellation flow
    • Solution: Ensure your prompt clearly includes words like "cancel" or "refund" along with booking reference information.
  3. AI Provider Connection Failed

    • Symptom: Error connecting to AI provider (Comput3 or Gemini)
    • Solution: Check your API keys in the .env file and ensure the correct API URL is set. Verify that your account has sufficient credits.

Debugging Tips

  1. Enable Debug Logging

    • Set DEBUG=true in your .env file to see detailed logs
    • Example: DEBUG=true npm start
  2. Test Individual MCPs

    • Use the test scripts to verify each MCP is working correctly:
    npm run test:booking
    npm run test:hedera
    npm run test:defi
    
  3. Check Server Logs

    • Monitor the server logs for error messages
    • Look for HTTP status codes in API responses (401 indicates authentication issues)

Project Structure

aya-wallet-mcp/
├── booking-mcp/                # Travel booking functionality
│   ├── booking.js              # Main booking logic
│   ├── flightBooking.js        # Flight-specific booking
│   └── hotelBooking.js         # Hotel-specific booking
├── hedera-mcp/                 # Hedera blockchain functionality
│   ├── hedera.js               # Main Hedera operations
│   └── tokenCreation.js        # HTS token creation
├── cross-chain-mcp/            # Cross-chain transfers
│   ├── bridge.js               # Asset bridging
│   └── transfers.js            # Cross-chain transfers
├── innovative-mcps/            # Specialized MCPs
│   ├── defi-swap.js            # DeFi token swaps
│   ├── nft-auction.js          # NFT bidding
│   ├── subscription.js         # Recurring payments
│   ├── did.js                  # Decentralized identity
│   └── scheduler.js            # Transaction scheduling
├── server/                     # Main server
│   ├── index.js                # Express server setup
│   ├── intent.js               # Intent detection
│   ├── cryptoPaymentHook.js    # Payment processing
│   └── comput3.js              # AI provider integration
├── frontend/                   # Web interface
│   ├── index.html              # Main HTML
│   ├── app.js                  # React application
│   └── styles.css              # Styling
├── tests/                      # Test suite
├── .env.example                # Example environment variables
├── .env                        # Your environment variables (not in git)
├── package.json                # Project dependencies
└── README.md                   # This file

Developer Guide

Architecture Overview

Aya Wallet uses a modular architecture with these key components:

  1. Intent Recognition: The AI (Comput3/Gemini) parses user prompts to identify the intent
  2. MCP Routing: Based on the intent, the server routes the request to the appropriate MCP
  3. MCP Processing: The MCP executes the business logic and calls necessary APIs/blockchains
  4. Payment Hook: Securely processes cryptocurrency transactions with user approval
  5. Response Generation: The AI generates a natural language response to the user

Adding a New MCP

To add a new MCP for additional functionality:

  1. Create a new directory or file for your MCP:

    // innovative-mcps/my-new-mcp.js
    class MyNewMCP {
      constructor(wallet, aiProvider) {
        this.wallet = wallet;
        this.ai = aiProvider;
      }
      
      async processRequest(prompt, userDetails) {
        // Parse the intent using the AI
        const intent = await this.ai.parsePrompt(prompt);
        
        // Execute your business logic
        const result = await this.executeBusinessLogic(intent);
        
        // Process payment if needed
        if (intent.requiresPayment) {
          const payment = await this.preparePayment(intent.amount, intent.token);
          await this.processPayment(payment, userDetails);
        }
        
        return { success: true, result };
      }
      
      async executeBusinessLogic(intent) {
        // Your implementation here
      }
      
      async preparePayment(amount, token) {
        // Payment preparation logic
      }
      
      async processPayment(payment, userDetails) {
        // Payment processing using the hook
      }
    }
    
    module.exports = MyNewMCP;
  2. Register your MCP in the server's router:

    // server/index.js
    const MyNewMCP = require('../innovative-mcps/my-new-mcp');
    
    // Inside your Express router setup
    app.post('/api/my-new-mcp', async (req, res) => {
      try {
        const myNewMCP = new MyNewMCP(wallet, aiProvider);
        const result = await myNewMCP.processRequest(req.body.prompt, req.body.userDetails);
        res.json({ success: true, result });
      } catch (error) {
        res.status(500).json({ success: false, error: error.message });
      }
    });
  3. Update the intent detection to recognize prompts for your new MCP:

    // server/intent.js
    function detectIntent(prompt) {
      if (prompt.includes('my new feature')) {
        return { type: 'my-new-mcp', confidence: 0.9 };
      }
      // Other intent detection logic
    }

Testing

We use Jest for testing. Run the test suite with:

npm test

To run specific tests:

npm test -- --testPathPattern=booking

Write tests for your new MCP:

// tests/my-new-mcp.test.js
const MyNewMCP = require('../innovative-mcps/my-new-mcp');

describe('MyNewMCP', () => {
  it('should process a valid request', async () => {
    // Test implementation
  });
  
  it('should handle errors gracefully', async () => {
    // Test implementation
  });
});

Acknowledgments

  • ElizaOS team for the AI framework
  • Comput3 for GPU infrastructure
  • Hedera, Ethereum, and Solana for blockchain infrastructure
  • The MCP standard for enabling modular AI applications

About

Aya wallet-AI_Assistant(with MCP tools)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors