hackquest logo

Chainpilot

ChainPilot is an AI-powered blockchain copilot that helps you chat, swap tokens, send crypto, track balances, and explore multiple chains with ease — all non-custodially.

视频

描述

# ChainPilot 🚀

Welcome to **ChainPilot** — your AI-powered blockchain copilot for the next generation of crypto users!

## What is ChainPilot?

ChainPilot is an intelligent, user-friendly web app that empowers anyone to:

- 💬 **Chat with an AI agent** about blockchain, DeFi, and crypto topics
- 🔄 **Swap tokens** across chains with simple, guided steps
- 📤 **Send crypto** to anyone, safely and easily
-**Check live gas fees** and get real-time blockchain data
- 📊 **Track wallet balances** and view transaction history
- 📚 **Learn blockchain concepts** in plain English
- 🦊 **Connect your wallet** (MetaMask)
- 🔒 **Enjoy non-custodial, secure interactions** — your keys, your crypto, your control

All powered by a conversational AI assistant that makes blockchain accessible for everyone.

---

## 🌐 Currently Supported Blockchains

ChainPilot currently supports:

- **Flow Testnet**
- **Ethereum**
- **Binance Smart Chain (BSC)**
- **Arbitrum**
- **Polygon**

🛠️ *More chains coming soon — stay tuned!*


---

## 📄 Deployed Contract

- **Contract Address (CT/ChainToken)**: `0x8E32897002906e0ec1F27A5495C80CefcfACCe07`
- **Block Explorer (Flow Testnet)**: [View on FlowScan](https://evm-testnet.flowscan.io/address/0x8E32897002906e0ec1F27A5495C80CefcfACCe07)


---

## 🌟 Capabilities

- **AI Chatbot**: Ask anything about crypto, DeFi, NFTs, or smart contracts
- **Flow Blockchain Integration**: Direct queries for Flow Testnet accounts, transactions, and blocks
- **Guided Actions**: Swap, send, and interact with contracts through natural language
- **Multi-Chain Support**: Ethereum, Polygon, Arbitrum, Optimism, and Flow Testnet
- **Real-Time Data**: Get up-to-date gas fees, token prices, and wallet info
- **Educational**: Learn as you go, with clear explanations and step-by-step help
- **Modern UI**: Beautiful, responsive, and theme-aware design

---

## 🚧 Future Goals

- **More Chains**: Add support for additional blockchains and L2s
- **Deeper DeFi**: Integrate lending, staking, and yield farming protocols
- **Personalized AI**: Smarter, context-aware assistant with memory
- **Notifications**: Real-time alerts for transactions and market changes
- **Mobile App**: Native mobile experience for on-the-go blockchain management
- **Open Source**: Community-driven features and plugins

---

**ChainPilot** is your trusted guide to the world of blockchain. Whether you're a beginner or a pro, let the AI and 🦊 MetaMask SDK make your crypto journey smarter, safer, and more fun!

---

## API: Chat Agent (`/api/start`)

This project exposes a chat/agent API implemented directly in Next.js, mirroring a Python LangChain agent.

- Endpoint: `POST /api/start`
- Body:

```json
{
  "input": "What balance of 0x... on polygon?",
  "chat_history": [
    { "role": "human", "content": "Hi" },
    { "role": "ai", "content": "Hello!" }
  ]
}
```

- Response:

```json
{
  "output": "Native: 1.23 MATIC\nUSDC: 10.5",
  "intermediate_steps": null
}
```

### Supported Tools

- `add(a,b)`, `sub(a,b)`, `mul(a,b)`
- `web_search(query)` via SerpAPI
- `get_main_balances(address, chain)` for native, USDC, USDT
- `get_wallet_transactions(address, chain, limit)`
- **Flow Blockchain Functions**:
  - `getFlowAccountBalance(address)` - Get Flow account balance and details
  - `getFlowTransaction(txId)` - Get transaction details and status
  - `getFlowTransactionResult(txId)` - Get detailed transaction result
  - `getFlowBlock(height)` - Get block information by height
  - `getFlowBlockById(blockId)` - Get block information by ID
  - `getFlowEvents(type, startHeight, endHeight)` - Query events
  - `getFlowNetworkParameters()` - Get network configuration

### Flow API Examples

Query Flow blockchain data directly:

```bash
# Check Flow account balance
curl -X POST http://localhost:3000/api/start \
  -H "Content-Type: application/json" \
  -d '{"input":"What is the balance of 0x1234567890abcdef on Flow?"}'

# Check Flow transaction
curl -X POST http://localhost:3000/api/start \
  -H "Content-Type: application/json" \
  -d '{"input":"Check Flow transaction 0xabc123..."}'

# Get Flow block info
curl -X POST http://localhost:3000/api/start \
  -H "Content-Type: application/json" \
  -d '{"input":"Show me Flow block at height 12345678"}'
```

For detailed Flow API documentation, see [FLOW_API_GUIDE.md](./FLOW_API_GUIDE.md)

### Environment Variables

Create a `.env.local` at the project root with:

```bash
# Google GenAI (Gemini)
GOOGLE_API_KEY=your_google_genai_api_key

# SerpAPI for web search
SERPAPI_API_KEY=your_serpapi_key

# Explorers
POLYGONSCAN_API_KEY=your_polygonscan_key
ETHERSCAN_API_KEY=your_etherscan_key
BSCSCAN_API_KEY=your_bscscan_key
ARBISCAN_API_KEY=your_arbiscan_key
```

Only chains with an explorer key set will return token balances/transactions. Native balances work without explorer keys.

### Test Quickly

```bash
curl -X POST http://localhost:3000/api/start \
  -H "Content-Type: application/json" \
  -d '{"input":"What balance of 0xB702203B9FD0ee85aeDB9d314C075D480d716635 on polygon?"}'
```

You can also check health with:

```bash
curl http://localhost:3000/api/start
```

本次黑客松进展

80

技术栈

React
Next
Web3
Ethers
Solidity
Node

融资状态

100

队长
MManjeet Sharma
赛道
AIDeFiOther