opentrade-gateway

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OpenTrade 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
opentrade
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.
  1. Confirm installed: Run
    which opentrade
    . If not found, install it:
    bash
    curl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh
    If the install script fails, ask the user to install manually following the instructions at: https://github.com/6551Team/openskills
  2. Check for updates: Read
    ~/.opentrade/last_check
    and compare it with the current timestamp:
    bash
    cached_ts=$(cat ~/.opentrade/last_check 2>/dev/null || true)
    now=$(date +%s)
    • If
      cached_ts
      is non-empty and
      (now - cached_ts) < 43200
      (12 hours), skip the update and proceed.
    • Otherwise (file missing or older than 12 hours), run the installer to check for updates:
      bash
      curl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh
      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.
  3. If any
    opentrade
    command fails with an unexpected error during this session, try reinstalling before giving up:
    bash
    curl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh
  4. 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_here
Get 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
命令前,请务必按顺序执行以下步骤。不要将常规命令的输出回显给用户,仅在安装、更新或处理故障时提供简短的状态更新即可。
  1. 确认已安装:运行
    which opentrade
    。如果找不到该命令,执行安装:
    bash
    curl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh
    如果安装脚本运行失败,请告知用户按照以下链接的说明手动安装:https://github.com/6551Team/openskills
  2. 检查更新:读取
    ~/.opentrade/last_check
    的内容,与当前时间戳对比:
    bash
    cached_ts=$(cat ~/.opentrade/last_check 2>/dev/null || true)
    now=$(date +%s)
    • 如果
      cached_ts
      不为空,且
      (now - cached_ts) < 43200
      (12小时),则跳过更新继续后续操作。
    • 否则(文件不存在或内容早于12小时),运行安装程序检查更新:
      bash
      curl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh
      如果安装了新版本,请告知用户并建议其从https://github.com/6551Team/openskills更新opentrade技能以获取最新功能。
  3. 如果本次会话中任何
    opentrade
    命令运行出现意外错误,在放弃操作前请尝试重新安装:
    bash
    curl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh
  4. 在项目根目录下找到或创建.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 routers
Response 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
    trader
    and
    api
    from the response
  • MANDATORY: ALL subsequent
    opentrade
    commands in this session MUST include
    --trader <trader>
    and
    --api <api>
    flags
  • 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
undefined
bash
undefined

Get 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
undefined
opentrade gateway orders --address 0x你的钱包地址 --chain xlayer --order-id 123456789
undefined

Chain Name Support

支持的链名称

The CLI accepts human-readable chain names and resolves them automatically.
ChainNamechainIndex
XLayer
xlayer
196
Solana
solana
501
Ethereum
ethereum
1
Base
base
8453
BSC
bsc
56
Arbitrum
arbitrum
42161
CLI接受易读的链名称,并会自动完成解析。
区块链名称chainIndex
XLayer
xlayer
196
Solana
solana
501
Ethereum
ethereum
1
Base
base
8453
BSC
bsc
56
Arbitrum
arbitrum
42161

Command Index

命令索引

#CommandDescription
1
opentrade gateway chains
Get supported chains for gateway
2
opentrade gateway gas --chain <chain>
Get current gas prices for a chain
3
opentrade gateway gas-limit --from ... --to ... --chain ...
Estimate gas limit for a transaction
4
opentrade gateway simulate --from ... --to ... --data ... --chain ...
Simulate a transaction (dry-run)
5
opentrade gateway broadcast --signed-tx ... --address ... --chain ...
Broadcast a signed transaction
6
opentrade gateway orders --address ... --chain ...
Track broadcast order status
#命令描述
1
opentrade gateway chains
获取网关支持的所有链
2
opentrade gateway gas --chain <chain>
获取指定链的当前gas价格
3
opentrade gateway gas-limit --from ... --to ... --chain ...
估算交易的gas限额
4
opentrade gateway simulate --from ... --to ... --data ... --chain ...
模拟交易(试运行)
5
opentrade gateway broadcast --signed-tx ... --address ... --chain ...
广播已签名交易
6
opentrade gateway orders --address ... --chain ...
跟踪广播订单的状态

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.value
    ,
    tx.gas
    from swap → user builds & signs →
    --signed-tx
    for broadcast
  • orderId
    from broadcast →
    --order-id
    param in orders query
用户:「将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 (
    --chain xlayer
    , low gas, fast confirmation) as the default, then ask which chain the user prefers
  • Missing
    --signed-tx
    → remind user to sign the transaction first (this CLI does NOT sign)
  • Missing wallet address → ask user
  • 缺少链信息 → 默认推荐XLayer(
    --chain xlayer
    ,gas低,确认速度快),然后询问用户偏好的链
  • 缺少
    --signed-tx
    → 提醒用户先对交易进行签名(本CLI不提供签名功能)
  • 缺少钱包地址 → 询问用户

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 chains
Output:
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
    : Chain name (e.g.,
    xlayer
    ,
    ethereum
    ,
    solana
    )
Example:
bash
opentrade gateway gas --chain xlayer
Output:
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:
  • --from
    : Sender wallet address (required)
  • --to
    : Recipient address (required)
  • --chain
    : Chain name (required)
  • --value
    : Amount to send in wei (optional, default:
    0
    )
  • --data
    : Transaction data in hex format (optional, default:
    0x
    )
Example:
bash
opentrade gateway gas-limit \
  --from 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
  --to 0x1234567890abcdef1234567890abcdef12345678 \
  --chain xlayer \
  --value 1000000000000000000
Output:
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
    : 链名称(必填)
  • --value
    : 发送金额,单位为wei(可选,默认值:
    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:
  • --from
    : Sender wallet address (required)
  • --to
    : Recipient address (required)
  • --chain
    : Chain name (required)
  • --value
    : Amount to send in wei (optional, default:
    0
    )
  • --data
    : Transaction data in hex format (optional, default:
    0x
    )
  • --gas-limit
    : Gas limit (optional)
  • --gas-price
    : Gas price in wei (optional)
Example:
bash
opentrade gateway simulate \
  --from 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
  --to 0x1234567890abcdef1234567890abcdef12345678 \
  --chain xlayer \
  --value 1000000000000000000 \
  --gas-limit 21000 \
  --gas-price 100000000
Output (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
    success: true
    : "Simulation successful! Gas used: 21000"
  • If
    success: false
    : "Simulation failed: [error message]"
  • 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
    : 链名称(必填)
  • --value
    : 发送金额,单位为wei(可选,默认值:
    0
  • --data
    : 十六进制格式的交易数据(可选,默认值:
    0x
  • --gas-limit
    : Gas限额(可选)
  • --gas-price
    : Gas价格,单位为wei(可选)
示例:
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": ""
}
向用户展示内容:
  • 如果
    success: true
    :「模拟成功!Gas消耗量:21000」
  • 如果
    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-tx
    : Signed transaction in hex format (EVM) or base58 (Solana) (required)
  • --address
    : Sender wallet address (required)
  • --chain
    : Chain name (required)
Example (EVM):
bash
opentrade gateway broadcast \
  --signed-tx 0xf86c808504a817c800825208941234567890abcdef1234567890abcdef12345678880de0b6b3a764000080820a96a0... \
  --address 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
  --chain xlayer
Example (Solana):
bash
opentrade gateway broadcast \
  --signed-tx 4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aHwYbgByseGmZJYDUSi5McBJdm7f9YY9d8FU7XMWoLM1gCWmoL92aPQuGHafb \
  --address YourSolanaWalletAddress \
  --chain solana
Output:
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>
参数:
  • --signed-tx
    : 十六进制格式(EVM链)或base58格式(Solana)的已签名交易(必填)
  • --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:
  • --address
    : Wallet address (required)
  • --chain
    : Chain name (required)
  • --order-id
    : Order ID from broadcast response (required)
Example:
bash
opentrade gateway orders \
  --address 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
  --chain xlayer \
  --order-id 123456789
Output:
json
{
  "code": "0",
  "data": [
    {
      "orderId": "123456789",
      "txHash": "0xabc123def456...",
      "txStatus": "2",
      "chainId": "196",
      "blockNumber": "12345678",
      "timestamp": "1709876543"
    }
  ],
  "msg": ""
}
Transaction Status Codes:
  • 0
    : Pending (not yet confirmed)
  • 1
    : Failed (transaction reverted or rejected)
  • 2
    : Success (confirmed on-chain)
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
    : 链名称(必填)
  • --order-id
    : 广播接口返回的订单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

已上链确认

undefined
undefined

Edge 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
    --signed-tx
    format matches the chain.
  • Chain not supported: call
    opentrade gateway chains
    first to verify.
  • 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
    --signed-tx
    is broadcast twice, the API may return an error or the same
    txHash
    — handle idempotently.
  • MEV保护:通过OpenTrade节点广播交易,在支持的链上可提供MEV保护。
  • Solana特殊处理:Solana的已签名交易使用base58编码(而非十六进制),请确保
    --signed-tx
    的格式与链匹配。
  • 链不支持:先调用
    opentrade gateway chains
    确认支持的链列表。
  • 节点返回失败:底层区块链节点拒绝了交易,常见原因包括:gas不足、nonce过低、合约执行回滚。请修正参数后重试。
  • 钱包类型不匹配:地址格式与链不匹配(例如在Solana链上使用EVM地址)。
  • 网络错误:重试一次,如果仍失败请提示用户稍后再试。
  • 地区限制(错误码50125或80001):不要向用户展示原始错误码,而是展示友好提示:
    ⚠️ 您所在地区暂不支持该服务。请切换到支持的地区后重试。
  • 交易已广播:如果同一个
    --signed-tx
    被广播两次,API可能返回错误或相同的
    txHash
    ,请做幂等处理。

Amount Display Rules

金额展示规则

  • Gas prices in Gwei for EVM chains (
    18.5 Gwei
    ), never raw wei
  • Gas limit as integer (
    21000
    ,
    145000
    )
  • USD gas cost estimate when possible
  • Transaction values in UI units (
    1.5 ETH
    ), never base units
  • EVM链的gas价格以Gwei为单位展示(
    18.5 Gwei
    ),不要直接展示原始wei值
  • 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.suggestBaseFee
    +
    proposePriorityFee
    for EIP-1559 chains,
    normal
    for legacy
  • 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步