指挥棒
Tempo区块链的CLI工具包和MCP服务器。
特性
- 126 MCP工具 -通过模型上下文协议完成区块链操作
- CLI接口 -所有操作的命令行界面
- TIP-20代币操作 -转移、批准、造币、销毁和角色管理
- DEX集成 -掉期、限价单和价格计算
- 账户管理 -余额、非数、费用代币
- 访问密钥管理 -授权和撤销访问密钥
- 政策体系 -创建和管理转移策略(TIP-403)
- 奖励分配 -领取并分配奖励
- 测试网水龙头 -测试网上的基金地址
安装
CLI用法(推荐)
全局安装以使用 baton 命令在任何地方:
npm install -g @augmnt-sh/baton或者直接使用npx运行(无需安装):
npx @augmnt-sh/baton 编程式用法
作为项目依赖项安装:
npm install @augmnt-sh/baton来源
git clone https://github.com/augmnt/baton.git
cd baton
npm install
npm run build快速开始
最快的入门方法是使用交互式设置向导:
baton init这将指导您完成:
- 创建新钱包或导入现有钱包
- 选择您的网络(测试网或主网)
- 将配置保存到
.env - 可选地从测试网水龙头为您的钱包提供资金
示例设置流程
$ baton init
██████╗ █████╗ ████████╗ ██████╗ ███╗ ██╗
██╔══██╗██╔══██╗╚══██╔══╝██╔═══██╗████╗ ██║
██████╔╝███████║ ██║ ██║ ██║██╔██╗ ██║
██╔══██╗██╔══██║ ██║ ██║ ██║██║╚██╗██║
██████╔╝██║ ██║ ██║ ╚██████╔╝██║ ╚████║
╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
Welcome to Baton Setup
? How would you like to set up your wallet?
❯ Create a new wallet
Import existing wallet (private key)
Import from mnemonic phrase
? Generate recovery phrase (mnemonic)? Yes
✓ Wallet generated successfully!
Address: 0x742d35Cc6634C0532925a3b844Bc454e4438f44e
Mnemonic: word1 word2 word3 ... word12
⚠️ IMPORTANT: Write down your mnemonic phrase and store it safely!
? Which network would you like to use?
❯ Testnet (recommended for getting started)
Mainnet
? Save configuration to .env file? Yes
✓ Configuration saved to .env
? Fund wallet from testnet faucet? Yes
✓ Funded successfully!
🚀 You're all set!更新配置
要稍后更新配置,请执行以下操作:
# Interactive configuration menu
baton config
# Or use specific commands:
baton config show # View current config
baton config set-key # Update private key (secure input)
baton config set-network # Change network安全说明: 这 set-key 命令使用安全的密码样式输入-您的私钥永远不会在屏幕上显示或保存到shell历史记录中。
______________________________________________________________________
配置
环境变量
Baton使用以下环境变量:
| 变量 | 必填 | 描述 |
|---|---|---|
TEMPO_PRIVATE_KEY | 用于写操作 | 用于签署交易的私钥 |
TEMPO_RPC_URL | 否 | 自定义RPC终结点(默认为Tempo测试网) |
TEMPO_EXPLORER_URL | 否 | 自定义块浏览器URL |
TEMPO_NETWORK | 没有 | mainnet 或 testnet (默认:测试网) |
配置方法
选项1:MCP服务器配置(建议用于Claude)
添加MCP服务器时直接传递环境变量:
claude mcp add baton -e TEMPO_PRIVATE_KEY=0x... -- npx @augmnt-sh/baton mcp这是最安全的方法,因为密钥存储在Claude的MCP配置中,不会暴露在shell历史或环境中。
选项2:外壳轮廓
添加到 ~/.zshrc 或 ~/.bashrc:
export TEMPO_PRIVATE_KEY=0x...
export TEMPO_NETWORK=testnet选项3:.env文件
创建 .env 工作目录中的文件:
TEMPO_PRIVATE_KEY=0x...
TEMPO_RPC_URL=https://rpc.moderato.tempo.xyz
TEMPO_NETWORK=testnet注:对于MCP服务器 .env 文件必须位于Claude运行的目录(您的项目目录)中,而不是接力棒安装目录中。
CLI使用情况
设置命令
# Interactive setup wizard (recommended for new users)
baton init
# Configuration management
baton config # Interactive config menu
baton config show # View current configuration
baton config set-key # Update private key (secure input)
baton config set-network # Change network (mainnet/testnet)钱包操作
# Generate a new wallet
baton wallet new
# Generate with mnemonic
baton wallet new --mnemonic
# Derive address from private key
baton wallet derive
# Derive from mnemonic
baton wallet from-mnemonic "word1 word2 ..."账户操作
# Get all balances
baton balances
# Get specific token balance
baton account balance --token
# Get account info
baton account info
# Get nonce
baton account nonce 令牌操作
# Get token info
baton token info
# Transfer tokens
baton token transfer
# Transfer with memo
baton token transfer --memo "Payment for services"
# Approve spender
baton token approve
# Get allowance
baton token allowance
# Mint tokens (requires MINTER_ROLE)
baton token mint
# Burn tokens
baton token burn DEX运营
# Get swap quote
baton dex quote
# Execute swap
baton dex swap
# Place limit order
baton dex order --buy
baton dex order --sell
# Cancel order
baton dex cancel
# Get order info
baton dex order-info
# Price utilities
baton dex price --tick 100
baton dex price --price 1.01连锁经营
# Get chain info
baton chain info
# Get block number
baton chain block-number
# Get block
baton chain block
# Get transaction
baton chain tx 水龙头(测试网)
# Fund address
baton faucet fund
# Check faucet status
baton faucet status
# Check cooldown
baton faucet cooldown 全局选项
# Use testnet
baton --network testnet
# Use custom RPC
baton --rpc https://custom-rpc.example.com
# JSON output
baton -o jsonMCP服务器
启动服务器
baton mcp与Claude Code集成
基本设置(只读操作):
claude mcp add baton -- npx @augmnt-sh/baton mcp使用私钥进行写操作:
claude mcp add baton -e TEMPO_PRIVATE_KEY=0x... -- npx @augmnt-sh/baton mcp对于测试网:
claude mcp add baton -e TEMPO_NETWORK=testnet -e TEMPO_PRIVATE_KEY=0x... -- npx @augmnt-sh/baton mcp要更新配置,请删除并重新添加:
claude mcp remove baton
claude mcp add baton -e TEMPO_PRIVATE_KEY=0x... -- npx @augmnt-sh/baton mcp用户级别(适用于所有项目):
claude mcp add -s user baton -e TEMPO_PRIVATE_KEY=0x... -- npx @augmnt-sh/baton mcp与Claude Desktop集成
将以下内容添加到您的Claude Desktop配置文件中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json 窗户: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"baton": {
"command": "node",
"args": ["/path/to/baton/dist/src/mcp-server.js"],
"env": {
"TEMPO_NETWORK": "testnet",
"TEMPO_PRIVATE_KEY": "0x..."
}
}
}
}或者通过npm全局安装:
{
"mcpServers": {
"baton": {
"command": "npx",
"args": ["@augmnt-sh/baton", "mcp"],
"env": {
"TEMPO_NETWORK": "testnet"
}
}
}
}可用工具
MCP服务器提供126个按域组织的工具:
| 域 | 工具 | 描述 |
|---|---|---|
| 链 | 5 | 区块和交易查询 |
| 钱包 | 6 | 钱包生成和派生 |
| 账户 | 13 | 余额和账户信息 |
| 代币 | 14 | TIP-20代币操作 |
| DEX | 10 | 掉期和订单管理 |
| 费用 | 9 | 费用代币管理 |
| 手续费AMM | 7 | 手续费流动性操作 |
| 钥匙链 | 11 | 访问密钥管理 |
| 策略 | 8 | 传输策略管理 |
| 奖励 | 10 | 奖励分配 |
| 历史记录 | 7 | 传输历史记录 |
| 水龙头 | 8 | 测试网水龙头 |
| 合同 | 8 | 通用合同操作 |
| 实用程序 | 10 | 实用程序功能 |
资源
tempo://tokens/known-已知令牌地址tempo://contracts/addresses-合同地址tempo://contracts/abis/tip20-TIP-20abitempo://config/network-当前网络配置
提示
transfer-tokens-引导式代币转移工作流程swap-tokens-引导式交换工作流程check-account-完整的账户概述new-wallet-生成并资助新钱包
编程式用法
import {
generateWallet,
getBalances,
transfer,
getSwapQuote,
swap,
} from '@augmnt-sh/baton'
// Generate wallet
const wallet = generateWallet()
console.log(wallet.address)
// Get balances
const balances = await getBalances('0x...')
// Transfer tokens
const result = await transfer({
token: '0x20c0000000000000000000000000000000000001',
to: '0x...',
amount: 100000000n, // 100 tokens (6 decimals)
})
// Swap tokens
const quote = await getSwapQuote({
tokenIn: '0x20c0000000000000000000000000000000000000',
tokenOut: '0x20c0000000000000000000000000000000000001',
amountIn: 100000000n,
})
const swapResult = await swap({
tokenIn: '0x20c0000000000000000000000000000000000000',
tokenOut: '0x20c0000000000000000000000000000000000001',
amountIn: 100000000n,
})关键概念
6位小数
所有TIP-20代币都使用6位小数。CLI中的金额是人类可读的:
# Transfer 100.5 tokens
baton token transfer 100.5在代码中,使用最小单位:
import { parseAmount, formatAmount } from '@augmnt-sh/baton'
const amount = parseAmount('100.5') // 100500000n
const formatted = formatAmount(100500000n) // "100.5"备忘录编码
备注以字节32编码:
# String memo (max 31 chars)
baton token transfer 100 --memo "Payment"
# Or hex bytes32
baton token transfer 100 --memo "0x..."Tick定价
DEX价格使用分时值:
import { priceToTick, tickToPrice } from '@augmnt-sh/baton'
const tick = priceToTick(1.0001) // Get tick for price
const price = tickToPrice(100) // Get price from tick已知令牌
| 令牌 | 地址 |
|---|---|
| pathUSD | 0x20c0000000000000000000000000000000000000 |
| AlphaUSD | 0x20c0000000000000000000000000000000000001 |
| Beta美元 | 0x20c0000000000000000000000000000000000002 |
| ThetaUSD | 0x20c0000000000000000000000000000000000003 |
合同地址
| 合同 | 地址 |
|---|---|
| TIP20_工厂 | 0x20fc000000000000000000000000000000000000 |
| 稳定币_DEX | 0xdec0000000000000000000000000000000000000 |
| 费用经理 | 0xfeec000000000000000000000000000000000000 |
| ACCOUNT_KEYCHAIN | 0xAAAAAAAA00000000000000000000000000000000 |
| FEE_AMM | 0xfee0000000000000000000000000000000000000 |
| 保单登记簿 | 0x403000000000000000000000000000000000000 |
| 多播3 | 0xcA11bde05977b3631167028862bE2a173976CA11 |
安全
- 永远不要共享您的私钥
- 从以下位置读取私钥
TEMPO_PRIVATE_KEY环境变量 - 钥匙从未被记录或存储
- 使用访问密钥授予权限
许可证
麻省理工学院
