Binance Onchain-Pay Open API Skill
Call Binance Onchain-Pay Open API endpoints with automatic RSA SHA256 request signing.
Use Cases & Scenarios
This skill is designed for the following scenarios:
1. 💳 Fiat-to-Crypto Purchase & Send
When to use: User wants to buy crypto with fiat currency and send directly to an external on-chain wallet address
- - Buy USDT with USD/EUR/TWD using credit card → Send to MetaMask address on BSC
- Purchase BTC with Google Pay → Transfer to hardware wallet
- Buy USDC with P2P → Send to DeFi protocol contract address
Key APIs: trading-pairs → payment-method-list → estimated-quote → INLINECODE3
2. 🔄 Direct Crypto Transfer (Send Primary)
When to use: User has crypto in Binance account and wants to send to external address
- - Send existing USDT from Binance Spot to friend's wallet address
- Transfer ETH to Uniswap contract for trading
- Move crypto from Binance to self-custodial wallet (Trust Wallet, Ledger, etc.)
Key APIs: pre-order with SEND_PRIMARY customization
3. 🔗 Cross-Chain Bridge Operations
When to use: User needs to buy crypto on one chain and transfer to another network
- - Buy USDC on Ethereum → Bridge to Polygon for lower fees
- Purchase tokens on BSC → Transfer to Base network
- Fiat to crypto on Solana → Send to Arbitrum for DeFi
Key APIs: crypto-network → pre-order with network selection
4. 🏪 Merchant Payment Integration
When to use: Integrate crypto payment gateway for e-commerce or services
- - Accept fiat payments and auto-convert to crypto
- Enable "Pay with Crypto" checkout flow
- Process subscription payments with crypto
Key APIs: pre-order with externalOrderId tracking
5. 🤖 Smart Contract Interaction (Onchain-Pay Easy)
When to use: Buy crypto and execute smart contract in one transaction
- - Buy USDT and deposit to lending protocol
- Purchase tokens and stake in DeFi pool
- Fiat on-ramp directly to GameFi or NFT marketplace
Key APIs: pre-order with ON_CHAIN_PROXY_MODE customization
6. 📊 Query & Monitoring
When to use: Check order status, available networks, or payment methods
- - Monitor order processing status (pending, completed, failed)
- List supported fiat currencies and cryptocurrencies
- Check available payment methods for specific country/amount
- Verify network fees and limits
Key APIs: order, crypto-network, trading-pairs, payment-method-list
Quick Reference
| Endpoint | API Path | Required Params | Optional Params |
|---|
| Payment Method List (v1) | INLINECODE16 | fiatCurrency, cryptoCurrency, totalAmount, amountType | network, contractAddress |
| Payment Method List (v2) |
papi/v2/ramp/connect/buy/payment-method-list | (none) | lang |
| Trading Pairs |
papi/v1/ramp/connect/buy/trading-pairs | (none) | (none) |
| Estimated Quote |
papi/v1/ramp/connect/buy/estimated-quote | fiatCurrency, requestedAmount, payMethodCode, amountType | cryptoCurrency, contractAddress, address, network |
| Pre-order |
papi/v1/ramp/connect/gray/buy/pre-order | externalOrderId, merchantCode, merchantName, ts | fiatCurrency, fiatAmount, cryptoCurrency, requestedAmount, amountType, address, network, payMethodCode, payMethodSubCode, redirectUrl, failRedirectUrl, redirectDeepLink, failRedirectDeepLink, customization, destContractAddress, destContractABI, destContractParams, affiliateCode, gtrTemplateCode, contractAddress |
| Get Order |
papi/v1/ramp/connect/order | externalOrderId | (none) |
| Crypto Network |
papi/v1/ramp/connect/crypto-network | (none) | (none) |
| P2P Trading Pairs |
papi/v1/ramp/connect/buy/p2p/trading-pairs | (none) | fiatCurrency |
How to Execute a Request
Step 1: Gather credentials
Use the default account (prod) unless the user specifies otherwise. You need:
- - BASEURL: API base URL
- CLIENTID: Client identifier
- APIKEY: The sign access token
- PEMPATH: Absolute path to the RSA private key PEM file
Use the account marked (default) in .local.md.
Step 2: Build the JSON body
Build a compact JSON body from user-specified parameters. Remove any parameters the user did not provide.
IMPORTANT: Address and Network Validation
- -
address (destination wallet address) and network (blockchain network) are REQUIRED for all pre-order requests - If the user has configured
Default Address and Default Network in .local.md, use them automatically - If not configured or not provided by user, ASK the user to provide both values before proceeding
Step 3: Sign and call using the bundled script
CODEBLOCK0
Step 4: Return results
Display the JSON response to the user in a readable format.
Authentication
See references/authentication.md for full signing details.
Summary:
- 1. Payload =
JSON_BODY + TIMESTAMP (milliseconds) - Sign payload with RSA SHA256 using PEM private key
- Base64 encode the signature (single line)
- Send as POST with headers:
X-Tesla-ClientId, X-Tesla-SignAccessToken, X-Tesla-Signature, X-Tesla-Timestamp, INLINECODE38
Parameters Reference
Payment Method List v1 (buy/payment-method-list)
| Parameter | Type | Required | Description |
|---|
| fiatCurrency | string | Yes | Fiat currency code (e.g., USD, EUR, BRL, UGX) |
| cryptoCurrency |
string | Yes | Crypto currency code (e.g.,
BTC,
USDT,
USDC,
SEI) |
| totalAmount | number | Yes | Amount value |
| amountType | number | Yes |
1 = fiat amount,
2 = crypto amount |
| network | string | No | Blockchain network (e.g.,
BSC,
ETH,
SOL,
BASE,
SEI) |
| contractAddress | string | No | Token contract address (required for non-native tokens) |
Payment Method List v2 (v2/buy/payment-method-list)
Get all available payment methods without specifying fiat/crypto parameters. Simplified version of v1.
| Parameter | Type | Required | Description |
|---|
| lang | string | No | Language code for localized payment method names (e.g., en, cn, es) |
Differences from v1:
- - Simpler: No need to specify fiatCurrency, cryptoCurrency, or amount
- Comprehensive: Returns all available payment methods for the merchant
- Use case: Useful for displaying all options before user input
Response Format: Same as v1, returns list of payment methods with their limits and properties.
Estimated Quote (buy/estimated-quote)
| Parameter | Type | Required | Description |
|---|
| fiatCurrency | string | Yes | Fiat currency code |
| cryptoCurrency |
string | No | Crypto currency code (optional if contractAddress provided) |
| requestedAmount | number | Yes | Amount value |
| payMethodCode | string | Yes | Payment method (e.g.,
BUY_CARD,
BUY_GOOGLE_PAY,
BUY_P2P,
BUY_WALLET) |
| amountType | number | Yes |
1 = fiat amount,
2 = crypto amount |
| network | string |
Yes* | Blockchain network (can use default from
.local.md) |
| contractAddress | string | No | Token contract address |
| address | string |
Yes* | Destination wallet address for receiving crypto |
\* Recommended: These parameters should be provided. If not specified by user, check .local.md for defaults. If no defaults exist, ask user before proceeding.
Pre-order (buy/pre-order)
Create a buy pre-order and return the redirect link for payment.
| Parameter | Type | Required | Description |
|---|
| externalOrderId | string | Yes | Partner's unique order ID (must be unique) |
| merchantCode |
string | Yes | Merchant code (e.g.,
connect-gray) |
| merchantName | string | Yes | Merchant display name (e.g.,
GrayTest) |
| ts | number | Yes | Current timestamp in milliseconds |
| fiatCurrency | string | No* | Fiat currency code (e.g.,
TWD,
USD,
EUR) |
| fiatAmount | number | No* | Fiat amount to spend |
| cryptoCurrency | string | No* | Crypto currency to buy (e.g.,
USDT,
BTC,
ETH) |
| requestedAmount | number | No* | Amount value (fiat or crypto based on amountType) |
| amountType | number | No* |
1 = fiat amount,
2 = crypto amount |
| address | string | No | Destination wallet address for receiving crypto |
| network | string | No | Blockchain network (e.g.,
BSC,
ETH,
SOL) |
| payMethodCode | string | No | Payment method code (e.g.,
BUY_CARD,
BUY_P2P,
BUY_GOOGLE_PAY,
BUY_APPLE_PAY,
BUY_PAYPAL,
BUY_WALLET,
BUY_REVOLUT) |
| payMethodSubCode | string | No | Payment method sub-code (e.g.,
card,
GOOGLE_PAY,
WECHAT) |
| redirectUrl | string | No | Success redirect URL |
| failRedirectUrl | string | No | Failure redirect URL |
| redirectDeepLink | string | No | Deep link for success (mobile apps) |
| failRedirectDeepLink | string | No | Deep link for failure (mobile apps) |
| customization | object | No | Custom configuration object (see Customization section below) |
| destContractAddress | string | No | Destination contract address (for Onchain-Pay Easy mode) |
| destContractABI | string | No | Contract ABI name (for Onchain-Pay Easy mode) |
| destContractParams | object | No | Contract parameters (for Onchain-Pay Easy mode) |
| affiliateCode | string | No | Affiliate code for commission tracking |
| gtrTemplateCode | string | No | GTR template code (e.g.,
OTHERS) |
| contractAddress | string | No | Token contract address (for non-native tokens) |
\* Either fiatAmount or (requestedAmount + amountType) should be provided. If fiatCurrency is not provided, the system will auto-select available fiat currencies.
Response Example:
CODEBLOCK1
Get Order (order)
| Parameter | Type | Required | Description |
|---|
| externalOrderId | string | Yes | The external order ID to query |
Customization Options
The customization field in pre-order API accepts various flags to customize the buy flow behavior. Each merchant must have the corresponding permission configured in db.merchant_info table.
Available Customization Flags
| Flag | Code | Type | Availability | Description | Use Case |
|---|
| INLINECODE100 | 1 | array | Open API ✓ | Lock specific order attributes so users cannot modify them. Values: 1=fiat currency, 2=crypto currency, 3=amount, 4=payment method, 5=network, 6=address, 7=fiat amount, 8=crypto amount | Fixed-parameter orders |
| INLINECODE109 |
2 | boolean | Open API ✓ | Skip the cashier page and proceed directly to payment. Reduces user friction in the checkout flow. | Streamlined payment experience |
|
AUTO_REDIRECTION | 3 | boolean | Open API ✓ | Automatically redirect to
redirectUrl after order completion without showing success page. | Seamless user experience |
|
HIDE_SEND | 6 | boolean | Open API ✓ | Hide the "Send" tab in the UI. Useful when only buy flow is needed. | Buy-only integration |
|
SEND_PRIMARY | 7 | boolean | Open API ✓ | Enable Send Crypto feature. If user's Binance balance is insufficient, auto-trigger buy flow first. | Send crypto to external address |
|
MERCHANT_DISPLAY_NAME | 8 | string | Open API ✓ | Override the display name shown to users in the UI. | Custom branding |
|
NET_RECEIVE | 9 | boolean | Open API ✓ | User receives net amount after deducting all fees. Total cost is more transparent. | Better UX for showing final received amount |
|
P2P_EXPRESS | 10 | boolean | Open API ✓ | Enable P2P Express mode for faster P2P order matching. | Quick P2P transactions |
|
OPEN_NETWORK | 11 | boolean | Web3 only | Allow users to select different networks. Default is locked to pre-selected network.
Note: Currently only available for Web3 entrance, not available for Open API. | Multi-network support (Web3 only) |
|
ON_CHAIN_PROXY_MODE | 12 | boolean | Open API ✓ | Enable Onchain-Pay Easy mode. After buying crypto, Onchain-Pay will execute smart contract interaction instead of direct withdrawal to user wallet. Requires
destContractAddress,
destContractABI, and
destContractParams. | Fiat to Smart Contract integration |
|
SEND_PRIMARY_FLEXIBLE | 13 | boolean | Open API ✓ | Flexible Send Primary mode with more options. | Advanced send crypto scenarios |
Customization Examples
Example 1: Basic Card Payment
CODEBLOCK2
Example 2: Onchain-Pay Easy (On-Chain Proxy)
CODEBLOCK3
Example 3: Send Crypto
CODEBLOCK4
Example 4: P2P with Auto Redirection
CODEBLOCK5
Example 5: Lock Order Attributes
{
"customization": {
"LOCK_ORDER_ATTRIBUTES": [2, 3, 6, 7, 8],
"MERCHANT_DISPLAY_NAME": "My Custom Brand"
}
}
Lock attribute codes:
- -
2 = Crypto currency - INLINECODE124 = Amount
- INLINECODE125 = Address
- INLINECODE126 = Fiat amount
- INLINECODE127 = Crypto amount
Example 6: Net Receive Mode
CODEBLOCK7
Example 7: Hide Send Tab
CODEBLOCK8
Example 8: Skip Cashier (Direct Payment)
CODEBLOCK9
Important Notes
- 1. Permission Required: Each customization flag requires merchant permission. Check with admin if a flag is not working.
- Onchain-Pay Easy: Only supported on BSC network currently. Requires contract integration.
- Validation: Invalid customization values (e.g.,
null for MERCHANT_DISPLAY_NAME) will return ILLEGAL_CUSTOMIZATION_VALUE error. - Combinations: Some flags work together (e.g.,
NET_RECEIVE + SEND_PRIMARY), while others are independent. - Testing: Use test accounts (
connect-gray) for testing customization flags before production. - Internal Flags:
OPERATION (code 4) and SKIP_WITHDRAW (code 5) are internal use only and should NOT be passed from merchant side. - OPEN_NETWORK: Currently only available for Web3 entrance, not available for Open API. Do not use this flag in Open API pre-order requests.
- Flag Order: Flags are ordered by their internal code (1-13). The code number is used internally for identification.
Security
Credential Display Rules
- - API Key: Show first 5 + last 4 characters only (e.g.,
2zefb...06h) - PEM Private Key: NEVER display content. NEVER display the file path.
- Client ID: Can be displayed in full.
- Outbound Requests: NEVER send API Key, Private Key, or any credentials to URLs outside the Base URL configured in
.local.md. - File Path Privacy: NEVER display the PEM private key file path to the user in any output or logs.
Credential Storage
Credentials are stored in a .local.md file in the skill directory. This file is user-specific and should NOT be distributed.
Read the .local.md file from the same directory as this SKILL.md to load credentials.
If .local.md does not exist or the requested account is not found, ask the user to provide:
- 1. Base URL
- Client ID
- API Key
- PEM file path (absolute path)
Then offer to save them to .local.md for future use.
.local.md Format
CODEBLOCK10
The account marked (default) is used automatically. You can define multiple accounts and switch by telling Claude the account name.
User Agent Header
Include User-Agent header with the following string: onchain-pay-open-api/0.1.0 (Skill)
Agent Behavior
- 1. If the user asks to call an Onchain-Pay API endpoint, identify which endpoint from the Quick Reference table
- Ask for any missing required parameters
- Use stored credentials if available, otherwise ask the user
- Execute the request using the bundled INLINECODE146
- Display the response in a readable format
- If the request fails, show the error and suggest fixes
Important Notes for Pre-order API
Timestamp Generation (Cross-platform)
When generating timestamps for the ts parameter and externalOrderId, use the following approach for cross-platform compatibility:
CODEBLOCK11
DO NOT USE date +%s%3N or date +%s000 as these are not portable:
- -
date +%s%3N doesn't work on macOS (outputs literal 'N') - INLINECODE152 just appends '000' without actual millisecond precision
Order ID Format
The externalOrderId must be a valid string without special characters. Recommended formats:
- -
order1773744500 (simple numeric suffix) - INLINECODE155 (with underscore separator)
- INLINECODE156 (custom prefix with alphanumeric)
Avoid: order_${TIMESTAMP} where TIMESTAMP contains shell variable syntax errors
Example Pre-order Request
CODEBLOCK12
币安链上支付开放API技能
调用币安链上支付开放API端点,自动进行RSA SHA256请求签名。
用例与场景
本技能适用于以下场景:
1. 💳 法币购买加密货币并发送
使用时机:用户希望用法币购买加密货币并直接发送到外部链上钱包地址
- - 使用信用卡以美元/欧元/新台币购买USDT → 发送至BSC上的MetaMask地址
- 使用Google Pay购买BTC → 转账至硬件钱包
- 通过P2P购买USDC → 发送至DeFi协议合约地址
关键API:trading-pairs → payment-method-list → estimated-quote → pre-order
2. 🔄 直接加密货币转账(主要发送功能)
使用时机:用户在币安账户中有加密货币并希望发送到外部地址
- - 将币安现货账户中的现有USDT发送至朋友的钱包地址
- 将ETH转账至Uniswap合约进行交易
- 将加密货币从币安转移至自托管钱包(Trust Wallet、Ledger等)
关键API:使用SEND_PRIMARY自定义选项的pre-order
3. 🔗 跨链桥操作
使用时机:用户需要在一个链上购买加密货币并转移到另一个网络
- - 在以太坊上购买USDC → 桥接至Polygon以降低费用
- 在BSC上购买代币 → 转移至Base网络
- 在Solana上用法币购买加密货币 → 发送至Arbitrum用于DeFi
关键API:crypto-network → 带网络选择的pre-order
4. 🏪 商户支付集成
使用时机:为电子商务或服务集成加密货币支付网关
- - 接受法币支付并自动转换为加密货币
- 启用使用加密货币支付结账流程
- 使用加密货币处理订阅支付
关键API:带externalOrderId追踪的pre-order
5. 🤖 智能合约交互(链上支付简易版)
使用时机:在一次交易中购买加密货币并执行智能合约
- - 购买USDT并存入借贷协议
- 购买代币并在DeFi池中质押
- 直接法币入金至GameFi或NFT市场
关键API:使用ONCHAINPROXY_MODE自定义选项的pre-order
6. 📊 查询与监控
使用时机:检查订单状态、可用网络或支付方式
- - 监控订单处理状态(待处理、已完成、失败)
- 列出支持的法币和加密货币
- 检查特定国家/金额的可用支付方式
- 验证网络费用和限额
关键API:order、crypto-network、trading-pairs、payment-method-list
快速参考
| 端点 | API路径 | 必需参数 | 可选参数 |
|---|
| 支付方式列表 (v1) | papi/v1/ramp/connect/buy/payment-method-list | fiatCurrency, cryptoCurrency, totalAmount, amountType | network, contractAddress |
| 支付方式列表 (v2) |
papi/v2/ramp/connect/buy/payment-method-list | (无) | lang |
| 交易对 | papi/v1/ramp/connect/buy/trading-pairs | (无) | (无) |
| 预估报价 | papi/v1/ramp/connect/buy/estimated-quote | fiatCurrency, requestedAmount, payMethodCode, amountType | cryptoCurrency, contractAddress, address, network |
| 预下单 | papi/v1/ramp/connect/gray/buy/pre-order | externalOrderId, merchantCode, merchantName, ts | fiatCurrency, fiatAmount, cryptoCurrency, requestedAmount, amountType, address, network, payMethodCode, payMethodSubCode, redirectUrl, failRedirectUrl, redirectDeepLink, failRedirectDeepLink, customization, destContractAddress, destContractABI, destContractParams, affiliateCode, gtrTemplateCode, contractAddress |
| 查询订单 | papi/v1/ramp/connect/order | externalOrderId | (无) |
| 加密货币网络 | papi/v1/ramp/connect/crypto-network | (无) | (无) |
| P2P交易对 | papi/v1/ramp/connect/buy/p2p/trading-pairs | (无) | fiatCurrency |
如何执行请求
第一步:收集凭证
除非用户另有指定,否则使用默认账户(生产环境)。您需要:
- - BASEURL:API基础URL
- CLIENTID:客户端标识符
- APIKEY:签名访问令牌
- PEMPATH:RSA私钥PEM文件的绝对路径
使用.local.md中标记为(default)的账户。
第二步:构建JSON请求体
根据用户指定的参数构建紧凑的JSON请求体。移除用户未提供的任何参数。
重要:地址和网络验证
- - address(目标钱包地址)和network(区块链网络)是所有预下单请求的必需参数
- 如果用户在.local.md中配置了默认地址和默认网络,则自动使用它们
- 如果未配置或用户未提供,请在继续之前询问用户提供这两个值
第三步:使用捆绑脚本签名并调用
bash
bash path>/scripts/signand_call.sh \
\
\
\
\
\
第四步:返回结果
以可读格式向用户显示JSON响应。
身份验证
完整签名详情请参见references/authentication.md。
摘要:
- 1. 负载 = JSON_BODY + TIMESTAMP(毫秒)
- 使用PEM私钥通过RSA SHA256对负载进行签名
- 对签名进行Base64编码(单行)
- 作为POST发送,包含以下标头:X-Tesla-ClientId、X-Tesla-SignAccessToken、X-Tesla-Signature、X-Tesla-Timestamp、Content-Type: application/json
参数参考
支付方式列表 v1(buy/payment-method-list)
| 参数 | 类型 | 必需 | 描述 |
|---|
| fiatCurrency | string | 是 | 法币代码(例如:USD、EUR、BRL、UGX) |
| cryptoCurrency |
string | 是 | 加密货币代码(例如:BTC、USDT、USDC、SEI) |
| totalAmount | number | 是 | 金额值 |
| amountType | number | 是 | 1 = 法币金额,2 = 加密货币金额 |
| network | string | 否 | 区块链网络(例如:BSC、ETH、SOL、BASE、SEI) |
| contractAddress | string | 否 | 代币合约地址(非原生代币必需) |
支付方式列表 v2(v2/buy/payment-method-list)
获取所有可用支付方式,无需指定法币/加密货币参数。v1的简化版本。
| 参数 | 类型 | 必需 | 描述 |
|---|
| lang | string | 否 | 本地化支付方式名称的语言代码(例如:en、cn、es) |
与v1的区别:
- - 更简单:无需指定fiatCurrency、cryptoCurrency或金额
- 更全面:返回商户所有可用的支付方式
- 使用场景:在用户输入前显示所有选项时有用
响应格式:与v1相同,返回支付方式列表及其限额和属性。
预估报价(buy/estimated-quote)
| 参数 | 类型 | 必需 | 描述 |
|---|
| fiatCurrency | string | 是 | 法币代码 |
| cryptoCurrency |
string | 否 | 加密货币代码(如果提供了contractAddress则为可选) |
| requestedAmount | number | 是 | 金额值 |
| payMethodCode | string | 是 | 支付方式(例如:BUY
CARD、BUYGOOGLE
PAY、BUYP2P、BUY_WALLET) |
| amountType | number | 是 | 1 = 法币金额,2 = 加密货币金额 |
| network | string |
是* |