alchemy-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAlchemy CLI
Alchemy CLI
The Alchemy CLI () is installed. Use it for all Alchemy API interactions instead of curl or raw HTTP.
@alchemy/cli已安装Alchemy CLI()。请使用它完成所有Alchemy API交互,替代curl或原生HTTP请求。
@alchemy/cliInstall
安装
bash
npm i -g @alchemy/clibash
npm i -g @alchemy/cliBootstrap
初始化引导
Run this at the start of any session to get the full command contract (every command, flag, auth method, error code, and example):
bash
alchemy --json --no-interactive agent-prompt在任何会话开始时运行以下命令,获取完整的命令约定(包含所有命令、标志、身份验证方法、错误代码及示例):
bash
alchemy --json --no-interactive agent-promptExecution Rules
执行规则
- ALWAYS pass on every command
--json --no-interactive - Parse stdout as JSON on exit code 0
- Parse stderr as JSON on nonzero exit code
- NEVER run bare without
alchemy--json --no-interactive - NEVER use curl or raw HTTP when an CLI command exists for the task
alchemy
- 所有命令必须携带参数
--json --no-interactive - 退出码为0时,将标准输出解析为JSON格式
- 退出码非0时,将标准错误输出解析为JSON格式
- 绝对不要在不携带参数的情况下运行
--json --no-interactive命令alchemy - 当已有对应的CLI命令时,绝对不要使用curl或原生HTTP请求完成任务
alchemy
Preflight
预检步骤
Before the first command, check auth readiness:
bash
alchemy --json --no-interactive setup statusIf is false, follow the in the response to configure auth.
completenextCommands首次执行命令前,检查身份验证就绪状态:
bash
alchemy --json --no-interactive setup status如果为false,请按照响应中的配置身份验证。
completenextCommandsAuth Setup
身份验证设置
The fastest way to authenticate is via browser login:
bash
alchemy auth loginThis opens a browser to authenticate with your Alchemy account and automatically configures the CLI with your credentials.
To check auth status:
To log out:
alchemy auth statusalchemy auth logout最快的身份验证方式是通过浏览器登录:
bash
alchemy auth login此命令会打开浏览器,使用你的Alchemy账号完成身份验证,并自动为CLI配置凭据。
查看身份验证状态:
退出登录:
alchemy auth statusalchemy auth logoutAlternative auth methods
备选身份验证方式
| Method | Config command | Env var | Used by |
|---|---|---|---|
| Browser login | | -- | All commands (provides both API key and access key) |
| API key | | | balance, tx, block, rpc, tokens, nfts, transfers, prices, portfolio, simulate, solana |
| Access key | | | apps, network list |
| Webhook key | | | webhooks |
| x402 wallet | | | balance, tx, block, rpc, tokens, nfts, transfers |
Get API/access keys at dashboard.alchemy.com.
| 方式 | 配置命令 | 环境变量 | 适用命令 |
|---|---|---|---|
| 浏览器登录 | | -- | 所有命令(同时提供API密钥和访问密钥) |
| API密钥 | | | balance, tx, block, rpc, tokens, nfts, transfers, prices, portfolio, simulate, solana |
| 访问密钥 | | | apps, network list |
| Webhook密钥 | | | webhooks |
| x402钱包 | | | balance, tx, block, rpc, tokens, nfts, transfers |
在dashboard.alchemy.com获取API/访问密钥。
Task-to-Command Map
任务-命令映射表
Node (EVM)
节点(EVM)
| Task | Command |
|---|---|
| ETH balance | |
| Transaction details | |
| Transaction receipt | |
| Block details | |
| Gas prices | |
| Event logs | |
| Raw JSON-RPC | |
| Trace methods | |
| Debug methods | |
| 任务 | 命令 |
|---|---|
| ETH余额 | |
| 交易详情 | |
| 交易收据 | |
| 区块详情 | |
| 燃气价格 | |
| 事件日志 | |
| 原生JSON-RPC | |
| 追踪方法 | |
| 调试方法 | |
Data
数据操作
| Task | Command |
|---|---|
| ERC-20 balances | |
| ERC-20 balances (formatted) | |
| Token metadata | |
| Token allowance | |
| List owned NFTs | |
| NFT metadata | |
| NFT contract metadata | |
| Transfer history | |
| Spot prices by symbol | |
| Spot prices by address | |
| Historical prices | |
| Token portfolio | |
| NFT portfolio | |
| Portfolio transactions | |
| Simulate asset changes | |
| Simulate execution | |
| 任务 | 命令 |
|---|---|
| ERC-20余额 | |
| ERC-20余额(格式化) | |
| 代币元数据 | |
| 代币授权额度 | |
| 列出持有的NFT | |
| NFT元数据 | |
| NFT合约元数据 | |
| 转账历史 | |
| 按符号查询现货价格 | |
| 按地址查询现货价格 | |
| 历史价格 | |
| 代币投资组合 | |
| NFT投资组合 | |
| 投资组合交易记录 | |
| 模拟资产变化 | |
| 模拟执行 | |
Solana
Solana
| Task | Command |
|---|---|
| Solana JSON-RPC | |
| Solana DAS (NFTs/assets) | |
| 任务 | 命令 |
|---|---|
| Solana JSON-RPC | |
| Solana DAS(NFT/资产) | |
Webhooks
Webhook管理
| Task | Command |
|---|---|
| List webhooks | |
| Create webhook | |
| Update webhook | |
| Delete webhook | |
| 任务 | 命令 |
|---|---|
| 列出Webhook | |
| 创建Webhook | |
| 更新Webhook | |
| 删除Webhook | |
App Management
应用管理
| Task | Command |
|---|---|
| List apps | |
| Create app | |
| Update app | |
| Delete app | |
| List networks | |
| 任务 | 命令 |
|---|---|
| 列出应用 | |
| 创建应用 | |
| 更新应用 | |
| 删除应用 | |
| 列出网络 | |
CLI Admin
CLI管理
| Task | Command |
|---|---|
| Check for CLI updates | |
| View config | |
| Reset config | |
| CLI version | |
| 任务 | 命令 |
|---|---|
| 检查CLI更新 | |
| 查看配置 | |
| 重置配置 | |
| CLI版本 | |
Global Flags
全局标志
| Flag | Description |
|---|---|
| Force JSON output |
| Disable prompts and REPL |
| Target network (default: |
| Override API key per command |
| Override access key per command |
| Use x402 wallet auth for this command |
| Request timeout in milliseconds |
| Suppress non-essential output |
| Log request/response details to stderr |
| 标志 | 描述 |
|---|---|
| 强制输出JSON格式 |
| 禁用提示和REPL |
| 目标网络(默认: |
| 按命令覆盖API密钥 |
| 按命令覆盖访问密钥 |
| 为此命令使用x402钱包身份验证 |
| 请求超时时间(毫秒) |
| 抑制非必要输出 |
| 将请求/响应详情记录到标准错误输出 |
Error Handling
错误处理
Errors return structured JSON on stderr. Key error codes:
| Code | Retryable | Recovery |
|---|---|---|
| No | Set |
| Yes | Wait and retry with backoff |
| No | Fund x402 wallet or switch to API key auth |
| No | Check method, params, and network |
| Yes | Check connection and retry |
| No | Run |
For the full error code list, see output.
agent-prompt错误会在标准错误输出返回结构化JSON。关键错误代码:
| 代码 | 是否可重试 | 恢复方案 |
|---|---|---|
| 否 | 设置 |
| 是 | 等待后重试并使用退避策略 |
| 否 | 为x402钱包充值或切换为API密钥身份验证 |
| 否 | 检查方法、参数及网络 |
| 是 | 检查连接后重试 |
| 否 | 执行 |
完整错误代码列表请查看输出。
agent-prompt