内容
# 1scan - Blockchain Explorer API Gateway & MCP Server
一个统一的API网关,用于集成多个类似etherscan的区块链浏览器API,并支持人工智能助手的模型上下文协议(MCP)。
## 概述
1scan提供两个主要组件:
1. **API Gateway**: 用于访问多个区块链浏览器API的统一端点
2. **MCP Server**: 允许AI模型(如Cursor IDE中的Claude)直接查询区块链数据
## 支持的区块链网络
**从相应的区块链浏览器申请您自己的API密钥**
| Network Name | Chain ID | Explorer Link | Explorer API Endpoint |
| ------------------- | -------- | ------------------------------- | ------------------------------------ |
| Ethereum | 1 | https://etherscan.io | api.etherscan.io |
| Binance Smart Chain | 56 | https://bscscan.com | api.bscscan.com |
| Arbitrum One | 42161 | https://arbiscan.io | api.arbiscan.io |
| Polygon | 137 | https://polygonscan.com | api.polygonscan.com |
| Optimism | 10 | https://optimistic.etherscan.io | api-optimistic.etherscan.io |
| Avalanche C-Chain | 43114 | https://snowtrace.io | api.snowtrace.io |
| Base | 8453 | https://basescan.org | api.basescan.org |
| zkSync Era | 324 | https://explorer.zksync.io | block-explorer-api.mainnet.zksync.io |
| Gnosis | 100 | https://gnosisscan.io | api.gnosisscan.io |
| Fantom | 250 | https://ftmscan.com | api.ftmscan.com |
| Mantle | 5000 | https://mantlescan.info | api.mantlescan.info |
| Cronos | 25 | https://cronoscan.com | api.cronoscan.com |
| Polygon ZkEVM | 1101 | https://zkevm.polygonscan.com | api-zkevm.polygonscan.com |
| Linea | 59144 | https://lineascan.build | api.lineascan.build |
| Moonbeam | 1284 | https://moonscan.io | api.moonscan.io |
| Celo | 42220 | https://celoscan.io | api.celoscan.io |
| Scroll | 534352 | https://scrollscan.com | api.scrollscan.com |
| OpBNB | 204 | https://opbnbscan.com | api.opbnbscan.com |
| Moonriver | 1285 | https://moonriver.moonscan.io | api-moonriver.moonscan.io |
| Arbitrum Nova | 42170 | https://nova.arbiscan.io | api-nova.arbiscan.io |
| Blast | 81457 | https://blastscan.io | api.blastscan.io |
| Fraxtal | 252 | https://fraxscan.com | api.fraxscan.com |
| Wemix | 1111 | https://wemixscan.com | api.wemixscan.com |
| Xai | 660279 | https://xaiscan.io | api.xaiscan.io |
| World Chain | 480 | https://worldscan.org | api.worldscan.org |
| Ape | 33139 | https://apescan.io/ | api.apescan.io |
| Kroma | 255 | https://kromascan.com | api.kromascan.com |
| Taiko | 167000 | https://taikoscan.io | api.taikoscan.io |
| Bittorrent | 199 | https://bttcscan.com | api.bttcscan.com |
| Xdc | 50 | https://xdcscan.io | api.xdcscan.io |
## Features
- 🔄 用于多个区块链浏览器的统一API端点
- ⚖️ API负载均衡
- 🔑 API速率限制管理
- 🎯 通过URL参数自定义API密钥支持
- 🤖 用于AI助手查询区块链数据的MCP服务器
## Installation
### From Go
```bash
go install github.com/huahuayu/1scan@latest
```
### From Source
```bash
# Clone the repository
git clone https://github.com/huahuayu/1scan.git
cd 1scan
# Build both 1scan API server and MCP server
make build
```
## Quick Start
### 1. Create Configuration File
创建一个包含您的API密钥的`config.json`文件:
```json
{
"1": {
"endpoint": "api.etherscan.io",
"keys": {
"YOUR_ETHERSCAN_API_KEY_1": 5,
"YOUR_ETHERSCAN_API_KEY_2": 10
}
},
"56": {
"endpoint": "api.bscscan.com",
"keys": {
"YOUR_BSCSCAN_API_KEY": 5
}
}
}
```
每个链条目包含:
- `chainID`: 区块链网络ID
- `endpoint`: 区块链浏览器的API端点
- `keys`: API密钥及其速率限制(每秒请求数)的映射
### 2. Run the API Server
```bash
# Run with default settings
1scan -config /path/to/config.json
# Or using make
make run-1scan
```
### 3. Run the MCP Server
```bash
# Run with default settings
1scanmcp -config /path/to/config.json # default serve at port 3000
# Or using make
make run-1scanmcp
# With custom settings
1scanmcp -config /path/to/config.json -port 3000 -path /mcp
```
## Integrating with Cursor IDE
要在Cursor IDE中使用1scan MCP:
1. 启动API服务器和MCP服务器
```bash
# Terminal 1
make run-1scan
# Terminal 2
make run-1scanmcp
```
2. 在Cursor IDE中,转到Settings → AI → MCP Servers
3. 添加一个新的MCP服务器,URL为:
```json
{
"mcpServers": {
"1scan": {
"url": "http://localhost:3000/mcp/sse"
}
}
}
```
4. 如果需要,重启Cursor IDE
5. 现在您可以在AI对话中使用区块链数据:
```
Can you check the balance of address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e on Ethereum?
```
## MCP Server Configuration
运行MCP服务器时,您可以使用以下参数对其进行自定义:
- `-port`: 运行MCP服务器的端口(默认值:"3000")
- `-path`: MCP服务器端点的路径(默认值:"/mcp")
- `-config`: 配置文件的路径(默认值:"config.json")
- `-transport`: 传输类型(sse或stdio)(默认值:"sse")
Example:
```bash
1scanmcp -port 3000 -config /path/to/config.json
```
## Available MCP Tools
MCP服务器向AI模型公开以下工具:
- `getAccountBalance` - 获取特定区块链上帐户的余额
- `getTokenBalance` - 获取特定区块链上帐户的token余额
- `getTransactionByHash` - 按哈希获取交易详情
- `getBlockByNumber` - 按区块号获取区块信息
- `getContractABI` - 获取已验证合约的ABI
- `getContractSourceCode` - 获取已验证合约的源代码
- `getTokenInfo` - 获取有关ERC20 token的信息
- `getGasPrice` - 获取特定区块链上的当前gas价格
- `getLogs` - 获取与指定参数匹配的事件日志
- `getTransaction` - 按哈希获取交易详情
- `getTransactionCount` - 获取从地址发送的交易数量
- `getTransactionReceipt` - 按交易哈希获取交易回执
- `getBlockTransactionCountByNumber` - 获取区块中的交易数量
- `getBlockTransactionCountByHash` - 按区块哈希获取区块中的交易数量
- `getBlockByHash` - 按哈希获取区块信息
- `getNormalTransactions` - 按地址获取普通交易
- `getInternalTransactions` - 按地址或交易哈希获取内部交易
- `getERC20Transfers` - 按地址或合约获取ERC-20 token转移事件
- `getERC721Transfers` - 按地址或合约获取ERC-721 NFT转移事件
- `getValidators` - 获取验证器信息(对于具有验证器集的网络)
- `getContractCreation` - 获取合约创建信息
- `getContractVerificationStatus` - 检查合约验证状态
## Example MCP Interactions
以下是通过MCP接口与区块链数据交互的示例:
```
# Get account balance
What's the ETH balance of vitalik.eth (0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045) on Ethereum?
# Check a token balance
What's the USDC balance of address 0x28C6c06298d514Db089934071355E5743bf21d60 on Ethereum?
# Examine a transaction
Can you analyze transaction 0xdd6d7f687c9821404ae8c2ea7de5cfb5a23fc4c01ef1e7f535748cb147aa76dd on Ethereum?
# Look up block information
What transactions were in Ethereum block 18700000?
# Get contract ABI
Can you show me the ABI for the USDC contract (0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) on Ethereum?
# Analyze contract source code
I need to understand how the Uniswap V3 router works. Can you show me the source code for 0xE592427A0AEce92De3Edee1F18E0157C05861564 on Ethereum?
# Check multiple chains
What's the difference in gas fees between Ethereum and Arbitrum right now?
# Examine token information
Tell me about the tokenomics of the APE token on Ethereum.
```
## Complete List of MCP Tools
MCP服务器向AI模型公开以下工具:
- `getAccountBalance` - 获取特定区块链上帐户的余额
- `getTokenBalance` - 获取特定区块链上帐户的token余额
- `getTransactionByHash` - 按哈希获取交易详情
- `getBlockByNumber` - 按区块号获取区块信息
- `getContractABI` - 获取已验证合约的ABI
- `getContractSourceCode` - 获取已验证合约的源代码
- `getTokenInfo` - 获取有关ERC20 token的信息
- `getGasPrice` - 获取特定区块链上的当前gas价格
- `getLogs` - 获取与指定参数匹配的事件日志
- `getTransaction` - 按哈希获取交易详情
- `getTransactionCount` - 获取从地址发送的交易数量
- `getTransactionReceipt` - 按交易哈希获取交易回执
- `getBlockTransactionCountByNumber` - 获取区块中的交易数量
- `getBlockTransactionCountByHash` - 按区块哈希获取区块中的交易数量
- `getBlockByHash` - 按哈希获取区块信息
- `getNormalTransactions` - 按地址获取普通交易
- `getInternalTransactions` - 按地址或交易哈希获取内部交易
- `getERC20Transfers` - 按地址或合约获取ERC-20 token转移事件
- `getERC721Transfers` - 按地址或合约获取ERC-721 NFT转移事件
- `getValidators` - 获取验证器信息(对于具有验证器集的网络)
- `getContractCreation` - 获取合约创建信息
- `getContractVerificationStatus` - 检查合约验证状态
## Troubleshooting MCP Integration
如果您在从Cursor连接到MCP服务器时遇到问题:
1. 验证两个服务器是否都在运行:
```bash
# Check if servers are running
ps aux | grep 1scanmcp
```
2. 确保在Cursor中配置了正确的URL
## License
MIT License
连接信息
猜你喜欢
暂无推荐服务器