区块链智能助手

AI区块链助手是一个通过自然语言与以太坊区块链交互的综合系统,提供CLI和桌面聊天UI,支持RAG知识库、区块链操作和外部API集成。

  • by topazcoder
  • Rust
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 topazcoder/ai-blockchain-assistant

使用说明

AI + Blockchain + Rust
Smart Assistant

🚀 Next-gen AI assistant for Ethereum blockchain: natural language, RAG, MCP and a beautiful chat UI.


AI区块链助手是一个使用自然语言与以太坊交互的综合系统。它的特点是:

  • 🤖 AI驱动的CLI和桌面聊天UI (牛磺酸+反应)
  • 📚 RAG知识库 (检索增强生成)
  • 🔗 区块链操作 (ETH转账、代币互换、合约查询)
  • 🌐 外部API集成 (DefiLlama,勇敢的搜索,0x)

📂 项目结构

ai-blockchain-assistant/
├── crates/         # All Rust and frontend code
│   ├── chatapp/    # Tauri + React chat UI
│   ├── mcp-server/ # Main MCP server (Rust)
│   ├── rig-client/ # CLI client (Rust)
│   └── shared/     # Shared Rust code
├── data/           # Blockchain docs, ABIs, embeddings for RAG
│   ├── docs/       # Markdown, Solidity, Uniswap docs
│   └── embeddings/ # Vector embeddings
├── scripts/        # Shell scripts for setup and running
│   ├── populate_rag.sh # Populate RAG with docs
│   ├── run_app.sh      # Run the Tauri app
│   └── run_repl.sh     # Run the CLI REPL
└── ...

🏗️ 建筑

User (CLI/Chat UI)
      ↓
RIG Client (Rust CLI) / Tauri Chat UI (React)
      ↓
MCP Server (Rust, LLM, RAG)
      ↓
Forked Ethereum (Anvil, Foundry)
      ↑
RAG Knowledge Base (Markdown, Solidity, Uniswap)

✨ 特性

  • 自然语言区块链命令(ETH、ERC20、Uniswap等)
  • 基于RAG的区块链概念答案
  • 代币交换、合约查询等
  • CLI和漂亮的桌面聊天UI
  • 外部API集成
  • 测试账户和本地主网分叉

⚡ 快速开始

1.先决条件

  • 锈蚀与货物
  • Node.js和npm(用于聊天UI)
  • Foundry(通过脚本自动安装)
  • 无烟煤API键

2.设置

克隆并进入仓库:

git clone https://github.com/Sillar-codes/ai-blockchain-assistant.git
cd ai-blockchain-assistant

设置您的Anthropic API密钥:

export ANTHROPIC_API_KEY="your_api_key_here"

(A) 运行CLI REPL

chmod +x scripts/run_repl.sh
./scripts/run_repl.sh

(B) 运行聊天界面(Tauri+React)

cargo install tauri-cli
cd crates/chatapp
npm install

然后

chmod +x scripts/run_app.sh
./scripts/run_app.sh

(C) 用文档填充RAG

chmod +x scripts/populate_rag.sh
./scripts/populate_rag.sh

🖥️ 截图


🤖 使用示例

命令行界面

> send 1 ETH from Alice to Bob
> How much USDC does Alice have?
> Is Uniswap V2 Router (0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) deployed?
> Swap 10 ETH for USDC on Alice's account
> Explain how Uniswap V2 works
> What are the key functions in the ERC-20 standard?

聊天界面

在聊天窗口中键入您的问题或命令,即可获得即时的人工智能答案和区块链操作。


🧠 RAG系统

RAG(检索增强生成)系统通过以下知识增强了人工智能助手:

  • 以太坊基础和概念
  • 代币标准(ERC-20、ERC-721)
  • Uniswap V2和V3协议
  • 智能合约接口

🧪 测试账户

系统使用Anvil的默认测试帐户:

  • 爱丽丝: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
  • 鲍勃: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8

每个账户都有10000 ETH用于测试。


🛠️ 脚本

  • scripts/populate_rag.sh --用区块链文档填充RAG系统
  • scripts/run_app.sh --运行Tauri聊天UI
  • scripts/run_repl.sh --运行CLI REPL

🤝 贡献

欢迎投稿、bug报告和功能请求!请打开问题或提交拉取请求。