opentrade-wallet
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenTrade Custodial Wallet
OpenTrade 托管钱包
4 API endpoints for custodial wallet creation, account query, swap execution, and native token withdrawal.
IMPORTANT: Custodial wallet only supports BSC and Solana networks.IMPORTANT: Newly created wallets have zero balance. You must deposit BNB (to the BSC address) or SOL (to the Solana address) before you can swap or withdraw. Do NOT send tokens from other chains (e.g., Ethereum, Polygon, Arbitrum) to these addresses — funds sent from unsupported chains will be lost.
提供4个API端点,用于托管钱包创建、账户查询、兑换执行和原生代币提现。
重要提示:托管钱包仅支持BSC和Solana网络。重要提示:新创建的钱包余额为零。您必须先向BSC地址存入BNB或向Solana地址存入SOL,才能进行兑换或提现操作。请勿将其他链(例如Ethereum、Polygon、Arbitrum)的代币发送到这些地址——从不支持的链发送的资金将会永久丢失。
Pre-flight Checks
前置检查
Every time before running any custodial wallet command, always follow these steps in order:
- Find or create a file in the project root to load the API credentials:
.env
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.
- Set the base URL and auth header:
bash
BASE_URL="https://ai.6551.io"
AUTH_HEADER="Authorization: Bearer $OPEN_TOKEN"每次运行任何托管钱包命令前,请务必按顺序执行以下步骤:
- 在项目根目录中找到或创建文件,用于加载API凭证:
.env
bash
OPEN_TOKEN=your_token_here您可以在此处获取API令牌:https://6551.io/mcp
安全警告:切勿将.env提交到git(请将其添加到.gitignore中),也切勿在日志、截图或聊天消息中泄露凭证。
- 设置基础URL和认证头:
bash
BASE_URL="https://ai.6551.io"
AUTH_HEADER="Authorization: Bearer $OPEN_TOKEN"Skill Routing
技能路由
- For swap quotes (read-only price estimate) → use
opentrade-dex-swap - For token search / metadata → use
opentrade-token - For market prices → use
opentrade-market - For wallet balances / portfolio → use
opentrade-portfolio - For transaction broadcasting (non-custodial) → use
opentrade-gateway - For custodial wallet management → use this skill ()
opentrade-wallet
- 兑换报价(只读价格估算)→ 使用
opentrade-dex-swap - 代币搜索/元数据查询 → 使用
opentrade-token - 市场价格查询 → 使用
opentrade-market - 钱包余额/资产组合查询 → 使用
opentrade-portfolio - 交易广播(非托管)→ 使用
opentrade-gateway - 托管钱包管理 → 使用本技能()
opentrade-wallet
Quickstart
快速开始
bash
undefinedbash
undefined1. Create a custodial wallet (EVM + Solana)
1. 创建托管钱包(同时生成EVM和Solana地址)
curl -s -X POST "$BASE_URL/open/trader/custodial/create"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
curl -s -X POST "$BASE_URL/open/trader/custodial/create"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
2. Get custodial account addresses
2. 获取托管账户地址
curl -s "$BASE_URL/open/trader/custodial/account"
-H "$AUTH_HEADER"
-H "$AUTH_HEADER"
curl -s "$BASE_URL/open/trader/custodial/account"
-H "$AUTH_HEADER"
-H "$AUTH_HEADER"
3. Custodial swap (auto-sign + broadcast)
3. 托管兑换(自动签名+广播)
curl -s -X POST "$BASE_URL/open/trader/custodial/swap"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"chainIndex":"56","fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","toTokenAddress":"0x55d398326f99059fF775485246999027B3197955","amount":"1000000000000000000","slippagePercent":"1"}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"chainIndex":"56","fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","toTokenAddress":"0x55d398326f99059fF775485246999027B3197955","amount":"1000000000000000000","slippagePercent":"1"}'
curl -s -X POST "$BASE_URL/open/trader/custodial/swap"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"chainIndex":"56","fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","toTokenAddress":"0x55d398326f99059fF775485246999027B3197955","amount":"1000000000000000000","slippagePercent":"1"}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"chainIndex":"56","fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","toTokenAddress":"0x55d398326f99059fF775485246999027B3197955","amount":"1000000000000000000","slippagePercent":"1"}'
4. Withdraw native tokens
4. 提现原生代币
curl -s -X POST "$BASE_URL/open/trader/custodial/withdraw"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"network":"bsc","to":"0xRecipientAddress","amount":1000000000000000000}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"network":"bsc","to":"0xRecipientAddress","amount":1000000000000000000}'
undefinedcurl -s -X POST "$BASE_URL/open/trader/custodial/withdraw"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"network":"bsc","to":"0xRecipientAddress","amount":1000000000000000000}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"network":"bsc","to":"0xRecipientAddress","amount":1000000000000000000}'
undefinedCommand Index
命令索引
| # | Endpoint | Method | Description |
|---|---|---|---|
| 1 | | POST | 创建托管钱包(同时生成 EVM 和 Solana 地址) |
| 2 | | GET | 获取托管钱包地址 |
| 3 | | POST | 托管钱包执行 DEX swap(自动签名+广播) |
| 4 | | POST | 从托管钱包提现原生代币(BSC/SOL) |
| # | Endpoint | Method | Description |
|---|---|---|---|
| 1 | | POST | 创建托管钱包(同时生成 EVM 和 Solana 地址) |
| 2 | | GET | 获取托管钱包地址 |
| 3 | | POST | 托管钱包执行 DEX swap(自动签名+广播) |
| 4 | | POST | 从托管钱包提现原生代币(BSC/SOL) |
Supported Networks
支持的网络
Custodial wallet only supports BSC and Solana.
| Chain | chainIndex | Native Token | Withdraw Network |
|---|---|---|---|
| BSC | | BNB | |
| Solana | | SOL | |
托管钱包仅支持BSC和Solana。
| Chain | chainIndex | Native Token | Withdraw Network |
|---|---|---|---|
| BSC | | BNB | |
| Solana | | SOL | |
Cross-Skill Workflows
跨技能工作流
Workflow A: Create Wallet → Deposit → Check Balance → Swap
工作流A:创建钱包 → 充值 → 查余额 → 兑换
User: "Create a custodial wallet and swap 1 BNB for USDT"
1. opentrade-wallet POST /open/trader/custodial/create → get evm_address, sol_address
→ Tell user to deposit BNB (BSC) or SOL (Solana) to the new address
→ WARNING: only accept BNB/SOL, do NOT send other chain assets
2. opentrade-portfolio opentrade portfolio all-balances --address <evm_address> --chains bsc
→ verify BNB balance >= 1 (user must have deposited first)
3. opentrade-wallet POST /open/trader/custodial/swap
{"chainIndex":"56","fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"toTokenAddress":"0x55d398326f99059fF775485246999027B3197955",
"amount":"1000000000000000000","slippagePercent":"1"}
→ returns tx_hashData handoff:
- from step 1 →
evm_addressin step 2--address - Custodial swap auto-signs and broadcasts — no manual signing needed
用户:“创建一个托管钱包,并用1个BNB兑换USDT”
1. opentrade-wallet POST /open/trader/custodial/create → 获取 evm_address, sol_address
→ 告知用户向新地址存入BNB(BSC网络)或SOL(Solana网络)
→ 警告:仅接受BNB/SOL,请勿发送其他链的资产
2. opentrade-portfolio opentrade portfolio all-balances --address <evm_address> --chains bsc
→ 验证BNB余额≥1(用户必须先完成充值)
3. opentrade-wallet POST /open/trader/custodial/swap
{"chainIndex":"56","fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"toTokenAddress":"0x55d398326f99059fF775485246999027B3197955",
"amount":"1000000000000000000","slippagePercent":"1"}
→ 返回 tx_hash数据流转:
- 步骤1返回的→ 步骤2的
evm_address参数--address - 托管兑换会自动签名和广播——无需手动签名
Workflow B: Swap Quote → Custodial Swap
工作流B:兑换报价 → 托管兑换
User: "Get a quote for swapping BNB to USDT, then execute with custodial wallet"
1. opentrade-dex-swap opentrade swap quote \
--from 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee \
--to 0x55d398326f99059fF775485246999027B3197955 \
--amount 1000000000000000000 --chain bsc
→ display quote: expected output, price impact
↓ user confirms
2. opentrade-wallet POST /open/trader/custodial/swap
→ auto-sign and broadcast, returns tx_hash用户:“查询BNB兑换USDT的报价,然后用托管钱包执行”
1. opentrade-dex-swap opentrade swap quote \
--from 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee \
--to 0x55d398326f99059fF775485246999027B3197955 \
--amount 1000000000000000000 --chain bsc
→ 展示报价:预期到账金额、价格影响
↓ 用户确认后
2. opentrade-wallet POST /open/trader/custodial/swap
→ 自动签名并广播,返回 tx_hashWorkflow C: Withdraw After Swap
工作流C:兑换后提现
User: "Swap BNB to USDT, then withdraw BNB to my external wallet"
1. opentrade-wallet POST /open/trader/custodial/swap → swap tokens
2. opentrade-wallet POST /open/trader/custodial/withdraw
{"network":"bsc","to":"0xExternalWallet","amount":1000000000000000000}
→ returns tx_hashNote: Withdraw only supports native tokens (BNB on BSC, SOL on Solana).
用户:“将BNB兑换为USDT,然后把BNB提现到我的外部钱包”
1. opentrade-wallet POST /open/trader/custodial/swap → 完成代币兑换
2. opentrade-wallet POST /open/trader/custodial/withdraw
{"network":"bsc","to":"0xExternalWallet","amount":1000000000000000000}
→ 返回 tx_hash注意:提现仅支持原生代币(BSC链的BNB、Solana链的SOL)。
Operation Flow
操作流程
Step 1: Identify Intent
步骤1:识别用户意图
- Create a new custodial wallet →
POST /open/trader/custodial/create - View custodial wallet addresses →
GET /open/trader/custodial/account - Execute a swap automatically →
POST /open/trader/custodial/swap - Withdraw native tokens →
POST /open/trader/custodial/withdraw
- 创建新的托管钱包 →
POST /open/trader/custodial/create - 查看托管钱包地址 →
GET /open/trader/custodial/account - 自动执行兑换 →
POST /open/trader/custodial/swap - 提现原生代币 →
POST /open/trader/custodial/withdraw
Step 2: Collect Parameters
步骤2:收集参数
- Missing wallet address → call first, or create one with
GET /open/trader/custodial/accountPOST /open/trader/custodial/create - Missing token addresses → use to search token by name
opentrade-token - Missing amount → ask user, remind to convert to minimal units
- Missing slippage → suggest 1% default
- Missing network for withdraw → ask user, only or
bscsupportedsol - User requests unsupported chain → inform user that custodial wallet only supports BSC and Solana
- 缺少钱包地址 → 先调用查询,或调用
GET /open/trader/custodial/account创建新钱包POST /open/trader/custodial/create - 缺少代币地址 → 使用按名称搜索代币
opentrade-token - 缺少金额 → 询问用户,提醒需要转换为最小单位
- 缺少滑点 → 建议使用默认的1%
- 提现缺少网络信息 → 询问用户,仅支持或
bscsol - 用户请求不支持的链 → 告知用户托管钱包仅支持BSC和Solana
Step 3: Execute & Display
步骤3:执行并展示结果
- Run the API call
- Parse JSON response
- Display human-readable summary
- 调用API
- 解析JSON返回结果
- 展示易于理解的摘要信息
Step 4: Suggest Next Steps
步骤4:建议后续操作
| Just completed | Suggest |
|---|---|
| Wallet created | 1. Deposit BNB (BSC) or SOL (Solana) to the new address — do NOT send other chain assets 2. Check balance → |
| Account queried | 1. Check balance → |
| Swap executed | 1. Check updated balance → |
| Withdraw completed | 1. Check remaining balance → |
Present conversationally — never expose endpoint paths to the user.
| 刚完成的操作 | 建议操作 |
|---|---|
| 钱包创建完成 | 1. 向新地址存入BNB(BSC网络)或SOL(Solana网络)——请勿发送其他链的资产 2. 查看余额 → |
| 账户查询完成 | 1. 查看余额 → |
| 兑换执行完成 | 1. 查看更新后的余额 → |
| 提现完成 | 1. 查看剩余余额 → |
请以对话形式呈现——切勿向用户暴露接口路径。
API Reference
API参考
1. Create Custodial Wallet
1. 创建托管钱包
创建托管钱包,同时生成 EVM(BSC)和 Solana 地址。每个用户只能创建一个钱包。
bash
curl -s -X POST "$BASE_URL/open/trader/custodial/create" \
-H "$AUTH_HEADER" \
-H "Content-Type: application/json"Parameters: None (user identity from JWT token)
Response:
json
{
"success": true,
"data": {
"evm_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"sol_address": "7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV"
}
}Return fields:
| Field | Type | Description |
|---|---|---|
| String | BSC 链地址 |
| String | Solana 链地址 |
Display to user:
- "Custodial wallet created!"
- "BSC Address: 0x742d..."
- "Solana Address: 7EcD..."
- "Please deposit BNB to your BSC address or SOL to your Solana address before trading."
- "WARNING: Only send BNB (BSC network) or SOL (Solana network). Do NOT send tokens from other chains — funds will be lost."
创建托管钱包,同时生成 EVM(BSC)和 Solana 地址。每个用户只能创建一个钱包。
bash
curl -s -X POST "$BASE_URL/open/trader/custodial/create" \
-H "$AUTH_HEADER" \
-H "Content-Type: application/json"参数: 无(用户身份从JWT令牌中获取)
返回结果:
json
{
"success": true,
"data": {
"evm_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"sol_address": "7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV"
}
}返回字段说明:
| 字段 | 类型 | 描述 |
|---|---|---|
| String | BSC 链地址 |
| String | Solana 链地址 |
向用户展示的内容:
- "托管钱包创建成功!"
- "BSC地址: 0x742d..."
- "Solana地址: 7EcD..."
- "交易前请向BSC地址存入BNB,或向Solana地址存入SOL。"
- "警告:仅可发送BSC网络的BNB或Solana网络的SOL。请勿发送其他链的代币——资金将会丢失。"
2. Get Custodial Account
2. 获取托管账户信息
获取当前用户的托管钱包地址。
bash
curl -s "$BASE_URL/open/trader/custodial/account" \
-H "$AUTH_HEADER"Parameters: None
Response:
json
{
"success": true,
"data": {
"evm_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"sol_address": "7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV"
}
}Return fields:
| Field | Type | Description |
|---|---|---|
| String | BSC 链地址 |
| String | Solana 链地址 |
获取当前用户的托管钱包地址。
bash
curl -s "$BASE_URL/open/trader/custodial/account" \
-H "$AUTH_HEADER"参数: 无
返回结果:
json
{
"success": true,
"data": {
"evm_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"sol_address": "7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV"
}
}返回字段说明:
| 字段 | 类型 | 描述 |
|---|---|---|
| String | BSC 链地址 |
| String | Solana 链地址 |
3. Custodial Swap
3. 托管兑换
使用托管钱包执行 DEX swap。服务端自动完成签名和广播。仅支持 BSC(chainIndex: 56)和 Solana(chainIndex: 501)。
bash
curl -s -X POST "$BASE_URL/open/trader/custodial/swap" \
-H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
-d '{
"chainIndex": "56",
"fromTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"toTokenAddress": "0x55d398326f99059fF775485246999027B3197955",
"amount": "1000000000000000000",
"slippagePercent": "1"
}'Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String | Yes | 链 ID: |
| String | Yes | 源代币合约地址 |
| String | Yes | 目标代币合约地址 |
| String | Yes | 交易数量(最小单位) |
| String | No | 滑点百分比(默认 |
Response:
json
{
"success": true,
"data": {
"tx_hash": "0xabc123def456...",
"error": ""
}
}Return fields:
| Field | Type | Description |
|---|---|---|
| String | 交易哈希(成功时返回) |
| String | 错误信息(失败时返回) |
Display to user:
- "Swap executed successfully!"
- "Tx Hash: 0xabc123..."
- If is non-empty, display the error message
error
使用托管钱包执行 DEX swap。服务端自动完成签名和广播。仅支持 BSC(chainIndex: 56)和 Solana(chainIndex: 501)。
bash
curl -s -X POST "$BASE_URL/open/trader/custodial/swap" \
-H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
-d '{
"chainIndex": "56",
"fromTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"toTokenAddress": "0x55d398326f99059fF775485246999027B3197955",
"amount": "1000000000000000000",
"slippagePercent": "1"
}'参数说明:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String | 是 | 链 ID: |
| String | 是 | 源代币合约地址 |
| String | 是 | 目标代币合约地址 |
| String | 是 | 交易数量(最小单位) |
| String | 否 | 滑点百分比(默认 |
返回结果:
json
{
"success": true,
"data": {
"tx_hash": "0xabc123def456...",
"error": ""
}
}返回字段说明:
| 字段 | 类型 | 描述 |
|---|---|---|
| String | 交易哈希(成功时返回) |
| String | 错误信息(失败时返回) |
向用户展示的内容:
- "兑换执行成功!"
- "交易哈希: 0xabc123..."
- 如果字段不为空,展示对应的错误信息
error
4. Custodial Withdraw
4. 托管提现
从托管钱包提现原生代币。仅支持 BSC (BNB) 和 Solana (SOL)。
bash
curl -s -X POST "$BASE_URL/open/trader/custodial/withdraw" \
-H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
-d '{
"network": "bsc",
"to": "0xRecipientAddress",
"amount": 1000000000000000000
}'Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
| String | Yes | 网络类型: |
| String | Yes | 接收地址 |
| Integer | Yes | 提现数量(最小单位,必须大于 0)。BSC 单位为 wei(1 BNB = 10^18 wei),Solana 单位为 lamports(1 SOL = 10^9 lamports) |
Response:
json
{
"success": true,
"data": {
"tx_hash": "0xdef789...",
"network": "bsc"
}
}Return fields:
| Field | Type | Description |
|---|---|---|
| String | 提现交易哈希 |
| String | 执行提现的网络 |
Display to user:
- "Withdrawal successful!"
- "Tx Hash: 0xdef789..."
- "Network: BSC"
从托管钱包提现原生代币。仅支持 BSC (BNB) 和 Solana (SOL)。
bash
curl -s -X POST "$BASE_URL/open/trader/custodial/withdraw" \
-H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
-d '{
"network": "bsc",
"to": "0xRecipientAddress",
"amount": 1000000000000000000
}'参数说明:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| String | 是 | 网络类型: |
| String | 是 | 接收地址 |
| Integer | 是 | 提现数量(最小单位,必须大于 0)。BSC 单位为 wei(1 BNB = 10^18 wei),Solana 单位为 lamports(1 SOL = 10^9 lamports) |
返回结果:
json
{
"success": true,
"data": {
"tx_hash": "0xdef789...",
"network": "bsc"
}
}返回字段说明:
| 字段 | 类型 | 描述 |
|---|---|---|
| String | 提现交易哈希 |
| String | 执行提现的网络 |
向用户展示的内容:
- "提现成功!"
- "交易哈希: 0xdef789..."
- "网络: BSC"
Native Token Addresses
原生代币地址
| Chain | Native Token Address |
|---|---|
| BSC | |
| Solana | |
| 链 | 原生代币地址 |
|---|---|
| BSC | |
| Solana | |
Input / Output Examples
输入/输出示例
User says: "Create a custodial wallet for me"
bash
curl -s -X POST "$BASE_URL/open/trader/custodial/create" -H "$AUTH_HEADER" -H "Content-Type: application/json"用户说: "给我创建一个托管钱包"
bash
curl -s -X POST "$BASE_URL/open/trader/custodial/create" -H "$AUTH_HEADER" -H "Content-Type: application/json"→ Wallet created! BSC: 0x742d..., Solana: 7EcD...
→ 钱包创建成功!BSC地址: 0x742d..., Solana地址: 7EcD...
**User says:** "Swap 0.1 BNB for USDT on BSC using my custodial wallet"
```bash
**用户说:** "用我的托管钱包在BSC链上将0.1个BNB兑换为USDT"
```bashAmount: 0.1 BNB = 100000000000000000 wei
金额: 0.1 BNB = 100000000000000000 wei
curl -s -X POST "$BASE_URL/open/trader/custodial/swap"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"chainIndex":"56","fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","toTokenAddress":"0x55d398326f99059fF775485246999027B3197955","amount":"100000000000000000","slippagePercent":"1"}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"chainIndex":"56","fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","toTokenAddress":"0x55d398326f99059fF775485246999027B3197955","amount":"100000000000000000","slippagePercent":"1"}'
curl -s -X POST "$BASE_URL/open/trader/custodial/swap"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"chainIndex":"56","fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","toTokenAddress":"0x55d398326f99059fF775485246999027B3197955","amount":"100000000000000000","slippagePercent":"1"}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"chainIndex":"56","fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","toTokenAddress":"0x55d398326f99059fF775485246999027B3197955","amount":"100000000000000000","slippagePercent":"1"}'
→ Swap executed! Tx Hash: 0xabc...
→ 兑换执行成功!交易哈希: 0xabc...
**User says:** "Withdraw 1 SOL to my external wallet"
```bash
**用户说:** "将1个SOL提现到我的外部钱包"
```bashAmount: 1 SOL = 1000000000 lamports
金额: 1 SOL = 1000000000 lamports
curl -s -X POST "$BASE_URL/open/trader/custodial/withdraw"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"network":"sol","to":"ExternalSolanaAddress","amount":1000000000}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"network":"sol","to":"ExternalSolanaAddress","amount":1000000000}'
curl -s -X POST "$BASE_URL/open/trader/custodial/withdraw"
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"network":"sol","to":"ExternalSolanaAddress","amount":1000000000}'
-H "$AUTH_HEADER" -H "Content-Type: application/json"
-d '{"network":"sol","to":"ExternalSolanaAddress","amount":1000000000}'
→ Withdrawal successful! Tx Hash: 5xYz...
→ 提现成功!交易哈希: 5xYz...
undefinedundefinedEdge Cases
边缘情况处理
- Wallet already exists: will return an error if the user already has a wallet. Use
POST /open/trader/custodial/createto retrieve existing addresses.GET /open/trader/custodial/account - New wallet has zero balance: After creating a wallet, the user must deposit BNB (via BSC network) or SOL (via Solana network) before performing any swap or withdraw. Do NOT deposit tokens from other chains (Ethereum, Polygon, Arbitrum, etc.) — those funds will be permanently lost.
- Unsupported chain: Custodial wallet only supports BSC (chainIndex: 56) and Solana (chainIndex: 501). If the user requests another chain (e.g., Ethereum, Arbitrum), inform them that the custodial wallet does not support that chain and suggest using a non-custodial workflow with +
opentrade-dex-swap.opentrade-gateway - Insufficient balance: Swap or withdraw will fail if the custodial wallet has insufficient funds. Check balance with first.
opentrade-portfolio - Unsupported network for withdraw: Only and
bscare supported for withdraw.sol - Amount must be positive: The field for withdraw must be greater than 0.
amount - High slippage swap: If slippage is too low, the swap may fail. Suggest increasing slippage for volatile tokens.
- 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.
- 钱包已存在: 如果用户已经创建过钱包,会返回错误。请使用
POST /open/trader/custodial/create获取已有的地址。GET /open/trader/custodial/account - 新钱包余额为零: 创建钱包后,用户必须先存入BSC网络的BNB或Solana网络的SOL,才能执行兑换或提现操作。请勿存入其他链(Ethereum、Polygon、Arbitrum等)的代币——这些资金将会永久丢失。
- 不支持的链: 托管钱包仅支持BSC(chainIndex: 56)和Solana(chainIndex: 501)。如果用户请求其他链(例如Ethereum、Arbitrum),告知用户托管钱包不支持该链,建议使用+
opentrade-dex-swap的非托管工作流。opentrade-gateway - 余额不足: 如果托管钱包资金不足,兑换或提现会失败。请先使用查询余额。
opentrade-portfolio - 提现网络不支持: 提现仅支持和
bsc网络。sol - 金额必须为正: 提现的字段必须大于0。
amount - 高滑点兑换: 如果滑点设置过低,兑换可能会失败。对于波动较大的代币,建议提高滑点。
- 网络错误: 重试一次后,如果仍然失败,提示用户稍后再试。
- 区域限制(错误码50125或80001): 请勿向用户展示原始错误码,而是展示友好提示:
您所在的区域无法使用该服务。请切换到支持的区域后重试。
Amount Display Rules
金额展示规则
- Input/output amounts in UI units (,
0.1 BNB)50 USDT - Internal API params use minimal units (=
1 BNB,"1000000000000000000"=1 SOL)1000000000 - Display tx hash as clickable link when possible
- 界面上的输入/输出金额使用常规单位(、
0.1 BNB)50 USDT - 内部API参数使用最小单位(=
1 BNB、"1000000000000000000"=1 SOL)1000000000 - 尽可能将交易哈希展示为可点击的链接
Global Notes
全局注意事项
- All endpoints require header
Authorization: Bearer <token> - Only BSC and Solana are supported — do not attempt other chains
- Amounts must be in minimal units (wei for BSC, lamports for Solana)
- EVM contract addresses must be all lowercase
- Custodial swap handles signing and broadcasting automatically — no need to call sign or broadcast separately
- Withdraw only supports native tokens (BNB/SOL)
- The custodial wallet is powered by Turnkey with AWS KMS for delegated key custody — 6551 does NOT store your private keys
- 所有接口都需要携带请求头
Authorization: Bearer <token> - 仅支持BSC和Solana——请勿尝试其他链
- 金额必须使用最小单位(BSC用wei,Solana用lamports)
- EVM合约地址必须全小写
- 托管兑换会自动处理签名和广播——无需单独调用签名或广播接口
- 提现仅支持原生代币(BNB/SOL)
- 托管钱包由Turnkey提供支持,使用AWS KMS进行委托密钥托管——6551不会存储您的私钥