opentrade-gateway
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenTrade Onchain Gateway CLI
OpenTrade Onchain Gateway CLI
6 commands for gas estimation, transaction simulation, broadcasting, and order tracking.
提供6个命令,用于gas估算、交易模拟、广播和订单跟踪。
Pre-flight Checks
前置检查
Every time before running any command, always follow these steps in order. Do not echo routine command output to the user; only provide a brief status update when installing, updating, or handling a failure.
opentrade-
Confirm installed: Run. If not found, install it:
which opentradebashcurl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | shIf the install script fails, ask the user to install manually following the instructions at: https://github.com/6551Team/openskills -
Check for updates: Readand compare it with the current timestamp:
~/.opentrade/last_checkbashcached_ts=$(cat ~/.opentrade/last_check 2>/dev/null || true) now=$(date +%s)- If is non-empty and
cached_ts(12 hours), skip the update and proceed.(now - cached_ts) < 43200 - Otherwise (file missing or older than 12 hours), run the installer to check for updates:
If a newer version is installed, tell the user and suggest updating their opentrade skills from https://github.com/6551Team/openskills to get the latest features.bash
curl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh
- If
-
If anycommand fails with an unexpected error during this session, try reinstalling before giving up:
opentradebashcurl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh -
Find or create a .env file in the project root to override the default API credentials, Load it before performing opentrade operations.
bash
OPEN_TOKEN=your_token_hereGet your API token at: https://6551.io/mcp
Security warning: Never commit .env to git (add it to .gitignore) and never expose credentials in logs, screenshots, or chat messages.
每次运行任何命令前,请务必按顺序执行以下步骤。不要将常规命令的输出回显给用户,仅在安装、更新或处理故障时提供简短的状态更新即可。
opentrade-
确认已安装:运行。如果找不到该命令,执行安装:
which opentradebashcurl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh如果安装脚本运行失败,请告知用户按照以下链接的说明手动安装:https://github.com/6551Team/openskills -
检查更新:读取的内容,与当前时间戳对比:
~/.opentrade/last_checkbashcached_ts=$(cat ~/.opentrade/last_check 2>/dev/null || true) now=$(date +%s)- 如果不为空,且
cached_ts(12小时),则跳过更新继续后续操作。(now - cached_ts) < 43200 - 否则(文件不存在或内容早于12小时),运行安装程序检查更新:
如果安装了新版本,请告知用户并建议其从https://github.com/6551Team/openskills更新opentrade技能以获取最新功能。bash
curl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh
- 如果
-
如果本次会话中任何命令运行出现意外错误,在放弃操作前请尝试重新安装:
opentradebashcurl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh -
在项目根目录下找到或创建.env文件以覆盖默认API凭证,执行opentrade操作前先加载该文件:
bash
OPEN_TOKEN=your_token_here你可以在此处获取API令牌:https://6551.io/mcp
安全警告:切勿将.env提交到git(请将其添加到.gitignore中),切勿在日志、截图或聊天消息中泄露凭证。
Router Discovery
路由发现
IMPORTANT: If the user has not specified a trading router, you MUST first discover available routers:
bash
opentrade trade routersResponse format:
json
{
"ok": true,
"data": [
{
"api": "v2",
"created_at": "2026-03-10 01:15:42",
"is_active": true,
"name": "6551dex test",
"quota_reward": 0,
"trader": "6551dex",
"updated_at": "2026-03-10 01:15:42"
},
{
"api": "v1",
"created_at": "2026-03-03 21:24:34",
"is_active": true,
"name": "okx test",
"quota_reward": 0,
"trader": "okx",
"updated_at": "2026-03-03 21:24:34"
}
]
}Usage:
- Extract and
traderfrom the responseapi - MANDATORY: ALL subsequent commands in this session MUST include
opentradeand--trader <trader>flags--api <api> - Example:
opentrade gateway gas --chain ethereum --trader okx --api v1 - Default fallback: If the API returns no data or is empty, use
--trader okx --api v1
重要提示:如果用户未指定交易路由器,你必须先查询可用的路由器:
bash
opentrade trade routers响应格式:
json
{
"ok": true,
"data": [
{
"api": "v2",
"created_at": "2026-03-10 01:15:42",
"is_active": true,
"name": "6551dex test",
"quota_reward": 0,
"trader": "6551dex",
"updated_at": "2026-03-10 01:15:42"
},
{
"api": "v1",
"created_at": "2026-03-03 21:24:34",
"is_active": true,
"name": "okx test",
"quota_reward": 0,
"trader": "okx",
"updated_at": "2026-03-03 21:24:34"
}
]
}使用规则:
- 从响应中提取和
trader字段api - 强制要求:本次会话中所有后续命令都必须包含
opentrade和--trader <trader>参数--api <api> - 示例:
opentrade gateway gas --chain ethereum --trader okx --api v1 - 默认兜底方案:如果API无返回数据或返回为空,请使用
--trader okx --api v1
Skill Routing
技能路由
- For swap quote and execution → use
opentrade-dex-swap - For market prices → use
opentrade-market - For token search → use
opentrade-token - For wallet balances / portfolio → use
opentrade-portfolio - For transaction broadcasting → use this skill ()
opentrade-gateway
- 兑换报价与执行 → 使用
opentrade-dex-swap - 市场价格查询 → 使用
opentrade-market - 代币搜索 → 使用
opentrade-token - 钱包余额/投资组合查询 → 使用
opentrade-portfolio - 交易广播 → 使用本技能()
opentrade-gateway
Quickstart
快速开始
bash
undefinedbash
undefinedGet current gas price on XLayer
获取XLayer当前gas价格
opentrade gateway gas --chain xlayer
opentrade gateway gas --chain xlayer
Estimate gas limit for a transaction
估算交易的gas限额
opentrade gateway gas-limit --from 0xYourWallet --to 0xRecipient --chain xlayer
opentrade gateway gas-limit --from 0x你的钱包地址 --to 0x接收地址 --chain xlayer
Simulate a transaction (dry-run)
模拟交易(试运行)
opentrade gateway simulate --from 0xYourWallet --to 0xContract --data 0x... --chain xlayer
opentrade gateway simulate --from 0x你的钱包地址 --to 0x合约地址 --data 0x... --chain xlayer
Broadcast a signed transaction
广播已签名交易
opentrade gateway broadcast --signed-tx 0xf86c...signed --address 0xYourWallet --chain xlayer
opentrade gateway broadcast --signed-tx 0xf86c...已签名内容 --address 0x你的钱包地址 --chain xlayer
Track order status
跟踪订单状态
opentrade gateway orders --address 0xYourWallet --chain xlayer --order-id 123456789
undefinedopentrade gateway orders --address 0x你的钱包地址 --chain xlayer --order-id 123456789
undefinedChain Name Support
支持的链名称
The CLI accepts human-readable chain names and resolves them automatically.
| Chain | Name | chainIndex |
|---|---|---|
| XLayer | | |
| Solana | | |
| Ethereum | | |
| Base | | |
| BSC | | |
| Arbitrum | | |
CLI接受易读的链名称,并会自动完成解析。
| 区块链 | 名称 | chainIndex |
|---|---|---|
| XLayer | | |
| Solana | | |
| Ethereum | | |
| Base | | |
| BSC | | |
| Arbitrum | | |
Command Index
命令索引
| # | Command | Description |
|---|---|---|
| 1 | | Get supported chains for gateway |
| 2 | | Get current gas prices for a chain |
| 3 | | Estimate gas limit for a transaction |
| 4 | | Simulate a transaction (dry-run) |
| 5 | | Broadcast a signed transaction |
| 6 | | Track broadcast order status |
| # | 命令 | 描述 |
|---|---|---|
| 1 | | 获取网关支持的所有链 |
| 2 | | 获取指定链的当前gas价格 |
| 3 | | 估算交易的gas限额 |
| 4 | | 模拟交易(试运行) |
| 5 | | 广播已签名交易 |
| 6 | | 跟踪广播订单的状态 |
Cross-Skill Workflows
跨技能工作流
This skill is the final mile — it takes a signed transaction and sends it on-chain. It pairs with swap (to get tx data).
本技能是「最后一公里」——它接收已签名的交易并将其发送到链上。它可以与兑换技能配合使用(获取交易数据)。
Workflow A: Swap → Broadcast → Track
工作流A:兑换 → 广播 → 跟踪
User: "Swap 1 ETH for USDC and broadcast it"
1. opentrade-dex-swap opentrade swap swap --from ... --to ... --amount ... --chain ethereum --wallet <addr>
↓ user signs the tx locally
2. opentrade-gateway opentrade gateway broadcast --signed-tx <signed_hex> --address <addr> --chain ethereum
↓ orderId returned
3. opentrade-gateway opentrade gateway orders --address <addr> --chain ethereum --order-id <orderId>Data handoff:
- ,
tx.data,tx.to,tx.valuefrom swap → user builds & signs →tx.gasfor broadcast--signed-tx - from broadcast →
orderIdparam in orders query--order-id
用户:「将1 ETH兑换为USDC并广播交易」
1. opentrade-dex-swap opentrade swap swap --from ... --to ... --amount ... --chain ethereum --wallet <地址>
↓ 用户在本地签名交易
2. opentrade-gateway opentrade gateway broadcast --signed-tx <已签名十六进制内容> --address <地址> --chain ethereum
↓ 返回orderId
3. opentrade-gateway opentrade gateway orders --address <地址> --chain ethereum --order-id <orderId>数据传递规则:
- 兑换接口返回的、
tx.data、tx.to、tx.value→ 用户构建并签名交易 → 作为tx.gas参数传入广播接口--signed-tx - 广播接口返回的→ 作为
orderId参数传入订单查询接口--order-id
Workflow B: Simulate → Broadcast → Track
工作流B:模拟 → 广播 → 跟踪
User: "Simulate this transaction first, then broadcast if safe"
1. opentrade gateway simulate --from 0xWallet --to 0xContract --data 0x... --chain ethereum
↓ simulation passes (no revert)
2. opentrade gateway broadcast --signed-tx <signed_hex> --address 0xWallet --chain ethereum
3. opentrade gateway orders --address 0xWallet --chain ethereum --order-id <orderId>用户:「先模拟这个交易,如果安全再广播」
1. opentrade gateway simulate --from 0x钱包地址 --to 0x合约地址 --data 0x... --chain ethereum
↓ 模拟通过(无执行回滚)
2. opentrade gateway broadcast --signed-tx <已签名十六进制内容> --address 0x钱包地址 --chain ethereum
3. opentrade gateway orders --address 0x钱包地址 --chain ethereum --order-id <orderId>Workflow C: Gas Check → Swap → Broadcast
工作流C:gas查询 → 兑换 → 广播
User: "Check gas, swap for USDC, then send it"
1. opentrade gateway gas --chain ethereum → check gas prices
2. opentrade-dex-swap opentrade swap swap --from ... --to ... --chain ethereum --wallet <addr>
↓ user signs
3. opentrade gateway broadcast --signed-tx <signed_hex> --address <addr> --chain ethereum
4. opentrade gateway orders --address <addr> --chain ethereum --order-id <orderId>用户:「先查gas价格,再兑换成USDC,然后发送」
1. opentrade gateway gas --chain ethereum → 检查gas价格
2. opentrade-dex-swap opentrade swap swap --from ... --to ... --chain ethereum --wallet <地址>
↓ 用户签名
3. opentrade gateway broadcast --signed-tx <已签名十六进制内容> --address <地址> --chain ethereum
4. opentrade gateway orders --address <地址> --chain ethereum --order-id <orderId>Operation Flow
操作流程
Step 1: Identify Intent
步骤1:识别用户意图
- Estimate gas for a chain →
opentrade gateway gas - Estimate gas limit for a specific tx →
opentrade gateway gas-limit - Test if a tx will succeed →
opentrade gateway simulate - Broadcast a signed tx →
opentrade gateway broadcast - Track a broadcast order →
opentrade gateway orders - Check supported chains →
opentrade gateway chains
- 查询某条链的gas价格 →
opentrade gateway gas - 估算指定交易的gas限额 →
opentrade gateway gas-limit - 测试交易是否能成功执行 →
opentrade gateway simulate - 广播已签名交易 →
opentrade gateway broadcast - 跟踪广播订单状态 →
opentrade gateway orders - 检查支持的链 →
opentrade gateway chains
Step 2: Collect Parameters
步骤2:收集参数
- Missing chain → recommend XLayer (, low gas, fast confirmation) as the default, then ask which chain the user prefers
--chain xlayer - Missing → remind user to sign the transaction first (this CLI does NOT sign)
--signed-tx - Missing wallet address → ask user
- 缺少链信息 → 默认推荐XLayer(,gas低,确认速度快),然后询问用户偏好的链
--chain xlayer - 缺少→ 提醒用户先对交易进行签名(本CLI不提供签名功能)
--signed-tx - 缺少钱包地址 → 询问用户
Step 3: Execute & Display
步骤3:执行并展示结果
- Run the command
- Parse JSON output
- Display human-readable summary (see each command section below)
- 运行命令
- 解析JSON输出
- 展示易读的结果摘要(参见下方每个命令的说明部分)
1. Supported Chains
1. 支持的链
List all chains supported by the gateway.
bash
opentrade gateway chainsOutput:
json
{
"code": "0",
"data": [
{ "chainId": "196", "chainName": "XLayer" },
{ "chainId": "1", "chainName": "Ethereum" },
{ "chainId": "501", "chainName": "Solana" }
],
"msg": ""
}Display to user:
- List chain names with IDs
- Highlight commonly used chains
列出网关支持的所有链。
bash
opentrade gateway chains输出:
json
{
"code": "0",
"data": [
{ "chainId": "196", "chainName": "XLayer" },
{ "chainId": "1", "chainName": "Ethereum" },
{ "chainId": "501", "chainName": "Solana" }
],
"msg": ""
}向用户展示内容:
- 列出所有链名称及对应的ID
- 高亮常用链
2. Gas Price
2. Gas价格查询
Get current gas price for a specific chain.
bash
opentrade gateway gas --chain <chain_name>Parameters:
- : Chain name (e.g.,
--chain,xlayer,ethereum)solana
Example:
bash
opentrade gateway gas --chain xlayerOutput:
json
{
"code": "0",
"data": [
{
"chainId": "196",
"eip1559Protocol": {
"suggestBaseFee": "100000000",
"proposePriorityFee": "0"
},
"normal": {
"maxFeePerGas": "100000000",
"baseFee": "100000000",
"gasPrice": "100000000",
"priorityFeePerGas": "0"
},
"fast": {
"maxFeePerGas": "100000000",
"baseFee": "100000000",
"gasPrice": "100000000",
"priorityFeePerGas": "0"
},
"slow": {
"maxFeePerGas": "100000000",
"baseFee": "100000000",
"gasPrice": "100000000",
"priorityFeePerGas": "0"
}
}
],
"msg": ""
}Display to user:
- Convert wei to Gwei:
100000000 wei = 0.1 Gwei - Show all three speeds: slow, normal, fast
- Recommend "normal" for most transactions
获取指定链的当前gas价格。
bash
opentrade gateway gas --chain <chain_name>参数:
- : 链名称(例如
--chain、xlayer、ethereum)solana
示例:
bash
opentrade gateway gas --chain xlayer输出:
json
{
"code": "0",
"data": [
{
"chainId": "196",
"eip1559Protocol": {
"suggestBaseFee": "100000000",
"proposePriorityFee": "0"
},
"normal": {
"maxFeePerGas": "100000000",
"baseFee": "100000000",
"gasPrice": "100000000",
"priorityFeePerGas": "0"
},
"fast": {
"maxFeePerGas": "100000000",
"baseFee": "100000000",
"gasPrice": "100000000",
"priorityFeePerGas": "0"
},
"slow": {
"maxFeePerGas": "100000000",
"baseFee": "100000000",
"gasPrice": "100000000",
"priorityFeePerGas": "0"
}
}
],
"msg": ""
}向用户展示内容:
- 将wei转换为Gwei:
100000000 wei = 0.1 Gwei - 展示三种速度的价格:慢速、正常、快速
- 大多数交易推荐使用「正常」档位
3. Gas Limit Estimation
3. Gas限额估算
Estimate the gas limit required for a transaction.
bash
opentrade gateway gas-limit \
--from <sender_address> \
--to <recipient_address> \
--chain <chain_name> \
[--value <amount_in_wei>] \
[--data <hex_data>]Parameters:
- : Sender wallet address (required)
--from - : Recipient address (required)
--to - : Chain name (required)
--chain - : Amount to send in wei (optional, default:
--value)0 - : Transaction data in hex format (optional, default:
--data)0x
Example:
bash
opentrade gateway gas-limit \
--from 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
--to 0x1234567890abcdef1234567890abcdef12345678 \
--chain xlayer \
--value 1000000000000000000Output:
json
{
"code": "0",
"data": [
{
"gasLimit": "21000"
}
],
"msg": ""
}Display to user:
- Show gas limit as integer:
21000 - Estimate total gas cost:
gasLimit × gasPrice - Show USD equivalent if possible
估算交易所需的gas限额。
bash
opentrade gateway gas-limit \
--from <sender_address> \
--to <recipient_address> \
--chain <chain_name> \
[--value <amount_in_wei>] \
[--data <hex_data>]参数:
- : 发送方钱包地址(必填)
--from - : 接收方地址(必填)
--to - : 链名称(必填)
--chain - : 发送金额,单位为wei(可选,默认值:
--value)0 - : 十六进制格式的交易数据(可选,默认值:
--data)0x
示例:
bash
opentrade gateway gas-limit \
--from 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
--to 0x1234567890abcdef1234567890abcdef12345678 \
--chain xlayer \
--value 1000000000000000000输出:
json
{
"code": "0",
"data": [
{
"gasLimit": "21000"
}
],
"msg": ""
}向用户展示内容:
- 展示整数形式的gas限额:
21000 - 估算总gas成本:
gasLimit × gasPrice - 如有可能,展示对应的美元等价金额
4. Transaction Simulation
4. 交易模拟
Simulate a transaction before broadcasting (dry-run).
bash
opentrade gateway simulate \
--from <sender_address> \
--to <recipient_address> \
--chain <chain_name> \
[--value <amount_in_wei>] \
[--data <hex_data>] \
[--gas-limit <limit>] \
[--gas-price <price_in_wei>]Parameters:
- : Sender wallet address (required)
--from - : Recipient address (required)
--to - : Chain name (required)
--chain - : Amount to send in wei (optional, default:
--value)0 - : Transaction data in hex format (optional, default:
--data)0x - : Gas limit (optional)
--gas-limit - : Gas price in wei (optional)
--gas-price
Example:
bash
opentrade gateway simulate \
--from 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
--to 0x1234567890abcdef1234567890abcdef12345678 \
--chain xlayer \
--value 1000000000000000000 \
--gas-limit 21000 \
--gas-price 100000000Output (Success):
json
{
"code": "0",
"data": [
{
"executionResult": {
"used": 21000,
"success": true,
"gasLimit": 21000,
"gasUsed": 21000
}
}
],
"msg": ""
}Output (Failure):
json
{
"code": "0",
"data": [
{
"executionResult": {
"used": 0,
"success": false,
"error": "execution reverted: insufficient balance"
}
}
],
"msg": ""
}Display to user:
- If : "Simulation successful! Gas used: 21000"
success: true - If : "Simulation failed: [error message]"
success: false - Show revert reason if available
广播前模拟交易执行(试运行)。
bash
opentrade gateway simulate \
--from <sender_address> \
--to <recipient_address> \
--chain <chain_name> \
[--value <amount_in_wei>] \
[--data <hex_data>] \
[--gas-limit <limit>] \
[--gas-price <price_in_wei>]参数:
- : 发送方钱包地址(必填)
--from - : 接收方地址(必填)
--to - : 链名称(必填)
--chain - : 发送金额,单位为wei(可选,默认值:
--value)0 - : 十六进制格式的交易数据(可选,默认值:
--data)0x - : Gas限额(可选)
--gas-limit - : Gas价格,单位为wei(可选)
--gas-price
示例:
bash
opentrade gateway simulate \
--from 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
--to 0x1234567890abcdef1234567890abcdef12345678 \
--chain xlayer \
--value 1000000000000000000 \
--gas-limit 21000 \
--gas-price 100000000输出(成功):
json
{
"code": "0",
"data": [
{
"executionResult": {
"used": 21000,
"success": true,
"gasLimit": 21000,
"gasUsed": 21000
}
}
],
"msg": ""
}输出(失败):
json
{
"code": "0",
"data": [
{
"executionResult": {
"used": 0,
"success": false,
"error": "execution reverted: insufficient balance"
}
}
],
"msg": ""
}向用户展示内容:
- 如果:「模拟成功!Gas消耗量:21000」
success: true - 如果:「模拟失败:[错误信息]」
success: false - 如有回滚原因,请一并展示
5. Broadcast Transaction
5. 交易广播
Broadcast a signed transaction to the blockchain.
bash
opentrade gateway broadcast \
--signed-tx <signed_transaction_hex> \
--address <sender_address> \
--chain <chain_name>Parameters:
- : Signed transaction in hex format (EVM) or base58 (Solana) (required)
--signed-tx - : Sender wallet address (required)
--address - : Chain name (required)
--chain
Example (EVM):
bash
opentrade gateway broadcast \
--signed-tx 0xf86c808504a817c800825208941234567890abcdef1234567890abcdef12345678880de0b6b3a764000080820a96a0... \
--address 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
--chain xlayerExample (Solana):
bash
opentrade gateway broadcast \
--signed-tx 4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aHwYbgByseGmZJYDUSi5McBJdm7f9YY9d8FU7XMWoLM1gCWmoL92aPQuGHafb \
--address YourSolanaWalletAddress \
--chain solanaOutput:
json
{
"code": "0",
"data": [
{
"orderId": "123456789",
"txHash": "0xabc123def456..."
}
],
"msg": ""
}Display to user:
- "Transaction broadcast successfully!"
- "Order ID: 123456789"
- "Tx Hash: 0xabc123def456..."
- "Track status with: opentrade gateway orders --address <wallet_address> --chain <chain_name> --order-id 123456789"
将已签名交易广播到区块链。
bash
opentrade gateway broadcast \
--signed-tx <signed_transaction_hex> \
--address <sender_address> \
--chain <chain_name>参数:
- : 十六进制格式(EVM链)或base58格式(Solana)的已签名交易(必填)
--signed-tx - : 发送方钱包地址(必填)
--address - : 链名称(必填)
--chain
示例(EVM链):
bash
opentrade gateway broadcast \
--signed-tx 0xf86c808504a817c800825208941234567890abcdef1234567890abcdef12345678880de0b6b3a764000080820a96a0... \
--address 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
--chain xlayer示例(Solana):
bash
opentrade gateway broadcast \
--signed-tx 4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aHwYbgByseGmZJYDUSi5McBJdm7f9YY9d8FU7XMWoLM1gCWmoL92aPQuGHafb \
--address YourSolanaWalletAddress \
--chain solana输出:
json
{
"code": "0",
"data": [
{
"orderId": "123456789",
"txHash": "0xabc123def456..."
}
],
"msg": ""
}向用户展示内容:
- 「交易广播成功!」
- 「订单ID:123456789」
- 「交易哈希:0xabc123def456...」
- 「你可以使用以下命令跟踪状态:opentrade gateway orders --address <钱包地址> --chain <链名称> --order-id 123456789」
6. Query Order Status
6. 订单状态查询
Query the status of a broadcast transaction by order ID.
bash
opentrade gateway orders \
--address <wallet_address> \
--chain <chain_name> \
--order-id <order_id>Parameters:
- : Wallet address (required)
--address - : Chain name (required)
--chain - : Order ID from broadcast response (required)
--order-id
Example:
bash
opentrade gateway orders \
--address 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
--chain xlayer \
--order-id 123456789Output:
json
{
"code": "0",
"data": [
{
"orderId": "123456789",
"txHash": "0xabc123def456...",
"txStatus": "2",
"chainId": "196",
"blockNumber": "12345678",
"timestamp": "1709876543"
}
],
"msg": ""
}Transaction Status Codes:
- : Pending (not yet confirmed)
0 - : Failed (transaction reverted or rejected)
1 - : Success (confirmed on-chain)
2
Display to user:
- "Order 123456789: Success"
- "Tx Hash: 0xabc123def456..."
- "Block: 12345678"
- "Status: Confirmed on-chain"
通过订单ID查询已广播交易的状态。
bash
opentrade gateway orders \
--address <wallet_address> \
--chain <chain_name> \
--order-id <order_id>参数:
- : 钱包地址(必填)
--address - : 链名称(必填)
--chain - : 广播接口返回的订单ID(必填)
--order-id
示例:
bash
opentrade gateway orders \
--address 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
--chain xlayer \
--order-id 123456789输出:
json
{
"code": "0",
"data": [
{
"orderId": "123456789",
"txHash": "0xabc123def456...",
"txStatus": "2",
"chainId": "196",
"blockNumber": "12345678",
"timestamp": "1709876543"
}
],
"msg": ""
}交易状态码说明:
- :待确认(尚未上链确认)
0 - :失败(交易回滚或被拒绝)
1 - :成功(已上链确认)
2
向用户展示内容:
- 「订单123456789:成功」
- 「交易哈希:0xabc123def456...」
- 「区块号:12345678」
- 「状态:已上链确认」
Workflow Examples
工作流示例
User says: "What's the gas price on XLayer?"
bash
opentrade gateway gas --chain xlayer用户说:「XLayer的gas价格是多少?」
bash
opentrade gateway gas --chain xlayer→ Display: Normal: 0.1 Gwei, Fast: 0.1 Gwei, Slow: 0.1 Gwei
→ 展示:正常档位:0.1 Gwei,快速档位:0.1 Gwei,慢速档位:0.1 Gwei
**User says:** "How much gas do I need to send 1 ETH?"
```bash
opentrade gateway gas-limit \
--from 0xYourWallet \
--to 0xRecipient \
--chain ethereum \
--value 1000000000000000000
**用户说:「发送1 ETH需要多少gas?」**
```bash
opentrade gateway gas-limit \
--from 0x你的钱包地址 \
--to 0x接收地址 \
--chain ethereum \
--value 1000000000000000000→ Display: Gas limit: 21000, Estimated cost: ~0.002 ETH ($5.50)
→ 展示:Gas限额:21000,预估成本:约0.002 ETH(5.50美元)
**User says:** "Simulate this transaction before I send it"
```bash
opentrade gateway simulate \
--from 0xYourWallet \
--to 0xContract \
--chain xlayer \
--data 0xa9059cbb... \
--gas-limit 100000
**用户说:「我发送前先模拟一下这个交易」**
```bash
opentrade gateway simulate \
--from 0x你的钱包地址 \
--to 0x合约地址 \
--chain xlayer \
--data 0xa9059cbb... \
--gas-limit 100000→ Display: Simulation successful! Gas used: 65432
→ 展示:模拟成功!Gas消耗量:65432
**User says:** "Broadcast this signed transaction"
```bash
opentrade gateway broadcast \
--signed-tx 0xf86c...signed \
--address 0xYourWallet \
--chain xlayer
**用户说:「广播这个已签名的交易」**
```bash
opentrade gateway broadcast \
--signed-tx 0xf86c...已签名内容 \
--address 0x你的钱包地址 \
--chain xlayer→ Display:
→ 展示:
Transaction broadcast! Order ID: 123456789
交易已广播!订单ID:123456789
Tx Hash: 0xabc...def
交易哈希:0xabc...def
**User says:** "Check the status of my broadcast order"
```bash
opentrade gateway orders --address 0xYourWallet --chain xlayer --order-id 123456789
**用户说:「查一下我广播的订单状态」**
```bash
opentrade gateway orders --address 0x你的钱包地址 --chain xlayer --order-id 123456789→ Display:
→ 展示:
Order 123456789: Success (txStatus=2)
订单123456789:成功(txStatus=2)
Tx Hash: 0xabc...def
交易哈希:0xabc...def
Confirmed on-chain
已上链确认
undefinedundefinedEdge Cases
边缘情况处理
- MEV protection: Broadcasting through OpenTrade nodes may offer MEV protection on supported chains.
- Solana special handling: Solana signed transactions use base58 encoding (not hex). Ensure the format matches the chain.
--signed-tx - Chain not supported: call first to verify.
opentrade gateway chains - Node return failed: the underlying blockchain node rejected the transaction. Common causes: insufficient gas, nonce too low, contract revert. Retry with corrected parameters.
- Wallet type mismatch: the address format does not match the chain (e.g., EVM address on Solana chain).
- Network error: retry once, then prompt user to try again later
- Region restriction (error code 50125 or 80001): do NOT show the raw error code to the user. Instead, display a friendly message:
⚠️ Service is not available in your region. Please switch to a supported region and try again. - Transaction already broadcast: if the same is broadcast twice, the API may return an error or the same
--signed-tx— handle idempotently.txHash
- MEV保护:通过OpenTrade节点广播交易,在支持的链上可提供MEV保护。
- Solana特殊处理:Solana的已签名交易使用base58编码(而非十六进制),请确保的格式与链匹配。
--signed-tx - 链不支持:先调用确认支持的链列表。
opentrade gateway chains - 节点返回失败:底层区块链节点拒绝了交易,常见原因包括:gas不足、nonce过低、合约执行回滚。请修正参数后重试。
- 钱包类型不匹配:地址格式与链不匹配(例如在Solana链上使用EVM地址)。
- 网络错误:重试一次,如果仍失败请提示用户稍后再试。
- 地区限制(错误码50125或80001):不要向用户展示原始错误码,而是展示友好提示:
⚠️ 您所在地区暂不支持该服务。请切换到支持的地区后重试。 - 交易已广播:如果同一个被广播两次,API可能返回错误或相同的
--signed-tx,请做幂等处理。txHash
Amount Display Rules
金额展示规则
- Gas prices in Gwei for EVM chains (), never raw wei
18.5 Gwei - Gas limit as integer (,
21000)145000 - USD gas cost estimate when possible
- Transaction values in UI units (), never base units
1.5 ETH
- EVM链的gas价格以Gwei为单位展示(),不要直接展示原始wei值
18.5 Gwei - Gas限额以整数形式展示(、
21000)145000 - 如有可能,展示gas成本的美元估算值
- 交易金额以UI单位展示(),不要展示基础单位值
1.5 ETH
Global Notes
全局注意事项
- This skill does NOT sign transactions — it only broadcasts pre-signed transactions
- Amounts in parameters use minimal units (wei/lamports)
- Gas price fields: use +
eip1559Protocol.suggestBaseFeefor EIP-1559 chains,proposePriorityFeefor legacynormal - EVM contract addresses must be all lowercase
- The CLI resolves chain names automatically (e.g., →
ethereum,1→solana)501 - The CLI handles authentication internally via environment variables — see Prerequisites step 4 for default values
- 本技能不提供交易签名功能——仅用于广播预先签名的交易
- 参数中的金额使用最小单位(wei/lamports)
- Gas价格字段:EIP-1559链使用+
eip1559Protocol.suggestBaseFee,传统链使用proposePriorityFee档位normal - EVM合约地址必须为全小写
- CLI会自动解析链名称(例如→
ethereum、1→solana)501 - CLI通过环境变量内部处理身份认证——默认值参见前置检查第4步