AI agent skill for Bitget Wallet โ token swap, cross-chain bridge, and gasless transactions via Order Mode API. Supports 7 EVM chains + Solana.
# Add to your Claude Code skills
git clone https://github.com/bitget-wallet-ai-lab/bitget-wallet-skillhttps://bopenapi.bgwapi.ioBGW_API_KEY / BGW_API_SECRET env vars for your own keys.bgw_swap_public (for swap endpoints)What you need to know beyond command syntax to use these tools correctly. These are cross-command constraints, common pitfalls, and the relationships between commands that the CLI README alone doesn't cover.
This skill uses date-based versioning (YYYY.M.DD). Each release includes a sequential suffix: YYYY.M.DD-1, YYYY.M.DD-2, etc. The current version is in the frontmatter above. See CHANGELOG.md for full history.
Daily first-use version check:
On the first use of the week (at most once every 7 days), compare the installed version (from frontmatter) against the latest version available from the repository:
version from frontmatter abovehttps://raw.githubusercontent.com/bitget-wallet-ai-lab/bitget-wallet-skill/main/CHANGELOG.mdIf a new version is available, inform the user:
๐ Bitget Wallet Skill update available
โข Installed: [installed version]
โข Latest: [latest version]
โข Changes: [one-line summary from CHANGELOG]
โข Security-related: [yes/no โ highlight if Security section exists]
Upgrade? [yes/no]
An AI Agent skill that wraps the Bitget Wallet API, enabling natural-language-driven on-chain data queries and swap operations.
| Capability | Description | Example | |------------|-------------|---------| | Token Info | Price, market cap, holders, social links | "What's the price of SOL?" | | Batch Price Query | Multi-token price lookup in one call | Portfolio valuation | | K-line Data | 1m/5m/1h/4h/1d candlestick data | Trend analysis, charting | | Transaction Stats | 5m/1h/4h/24h buy/sell volume & trader count | Activity detection, whale monitoring | | Rankings | Top gainers / top losers | Market scanning, alpha discovery | | Liquidity Pools | LP pool information | Slippage estimation, depth analysis | | Security Audit | Contract safety checks (honeypot, permissions, blacklist) | Pre-trade risk control | | Batch Tx Info | Batch transaction statistics for multiple tokens | "Compare volume for SOL and ETH" | | Historical Coins | Discover new tokens by timestamp | "What tokens launched today?" | | Swap Send | Broadcast signed transactions with MEV protection | "Broadcast my signed swap" | | Swap Quote | Best-route quote for cross-chain/same-chain swaps | "How much USDC for 1 SOL?" | | Swap Calldata | Generate unsigned transaction data | Execute trades via wallet signing | | Order Quote | Cross-chain + gasless aware price quote | "Quote 10 USDC Base to BNB USDT" | | Order Create | Create order with unsigned tx/signature data | One-step cross-chain swap | | Order Submit | Submit signed transactions for an order | Gasless or normal execution | | | Track order lifecycle (initโprocessingโsuccess) | "Check my swap status" |
No comments yet. Be the first to share your thoughts!
If the user confirms upgrade:
Re-install the skill from the main branch of the repository at https://github.com/bitget-wallet-ai-lab/bitget-wallet-skill. Replace all local skill files with the latest versions, then re-read SKILL.md to load the updated Domain Knowledge.
Post-upgrade security check:
bitget_api.py โ summarize changes to the userIf versions match: No announcement needed, proceed normally.
Check frequency: At most once every 7 days. The agent should track the last check date and skip if fewer than 7 days have passed.
The first time a user initiates a swap, before executing, guide them through these one-time preferences:
Transaction deadline โ how long the on-chain transaction remains valid:
120 seconds (better protection against sandwich attacks in volatile markets)300 seconds (balanced โ suitable for most users)600 seconds (for slow signing workflows, e.g., hardware wallets or multi-sig)Automatic security check โ whether to audit unfamiliar tokens before swaps:
security automatically before swapSave preferences โ store in the agent's memory/config for future swaps
Remind user they can update anytime (e.g., "update my swap settings" or "change my default deadline")
If the user declines configuration, use sensible defaults: deadline=300, security=always.
All BGW API inputs and outputs use human-readable values, NOT smallest chain units (wei, lamports, satoshi).
| โ
Correct | โ Wrong |
|-----------|---------|
| --amount 0.1 (0.1 USDT) | --amount 100000000000000000 (100 quadrillion USDT!) |
| --amount 1 (1 SOL) | --amount 1000000000 (1 billion SOL!) |
This applies to: swap-quote, swap-calldata, swap-send, and all toAmount / fromAmount values in responses. The decimals field in responses is informational only โ do not use it for conversion.
Swap is a multi-step process. These commands must be called in order:
1. swap-quote โ Get route and estimated output
2. swap-calldata โ Generate unsigned transaction data
3. (wallet signs the transaction externally)
4. swap-send โ Broadcast the signed transaction
swap-calldata without first getting a quote.swap-send requires a signed raw transaction. The signing happens outside this skill (wallet app, hardware wallet, or local keyfile).deadline field (default: 600 seconds = 10 minutes). After this time, the on-chain transaction will revert even if broadcast. The --deadline parameter in swap-calldata allows customization (in seconds). Use the user's configured deadline preference (see "First-Time Swap Configuration"). If not yet configured, default to 300 seconds and inform the user.estimateRevert=true means the API estimates the transaction may fail on-chain, but it is not guaranteed to fail. For valid amounts, successful on-chain execution has been observed even with estimateRevert=true. Still, inform the user of the risk.toAmount is human-readable. "0.1005" means 0.1005 tokens, not a raw integer.market field from the quote response is required as input for swap-calldata.The security command returns raw audit data. Key fields to check:
| Field | Meaning | Action |
|-------|---------|--------|
| highRisk = true | Token has critical security issues | Warn user strongly. Do not recommend trading. |
| riskCount > 0 | Number of risk items found | List the specific risks to the user |
| warnCount > 0 | Number of warnings | Mention but less critical than risks |
| buyTax / sellTax > 0 | Token charges tax on trades | Include in cost estimation |
| isProxy = true | Contract is upgradeable | Mention โ owner can change contract behavior |
| cannotSellAll = true | Cannot sell 100% of holdings | Major red flag for meme coins |
Best practice: Run security before any swap involving an unfamiliar token. This should follow the user's configured security preference (see "First-Time Swap Configuration"). If set to "Always check" (default), run automatically and silently โ only surface results if risks are found. Never skip security checks for tokens the user has not traded before, regardless of preference.
1s, 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w5m, 1h, 4h, 24h onlycreateTime is a datetime string in format "YYYY-MM-DD HH:MM:SS" (NOT a Unix timestamp).limit is a number (max results per page).lastTime field (also a datetime string) โ pass it as createTime in the next request to paginate.--create-time "2026-02-27 00:00:00" --limit 20Use empty string "" as the contract address for native tokens (ETH, SOL, BNB, etc.). This is a common source of errors โ do not pass the wrapped token address (e.g., WETH, WSOL) when querying native token info.
Always use these verified addresses for USDT/USDC. Do not guess or generate contract addresses from memory โ incorrect addresses will cause API errors (error_code: 80000, "get token info failed").
USDT vs USDT0: Tether has begun migrating USDT to USDT0 (omnichain version via LayerZero) on some chains. On Arbitrum, the same contract address now represents USDT0 instead of legacy USDT. The contract addresses remain unchanged and work identically with the BGW API โ no special handling is needed. When a user asks to swap "USDT", use the address below regardless of whether the chain has migrated to USDT0.
| Chain (code) | USDT (USDT0) | USDC |
|-------------|------|------|
| Ethereum (eth) | 0xdAC17F958D2ee523a2206206994597C13D831ec7 | 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 |
| BNB Chain (bnb) | 0x55d398326f99059fF775485246999027B3197955 | 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d |
| Base (base) | 0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2 | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
| Arbitrum (arbitrum) | 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9 | 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 |
| Optimism (optimism) | 0x94b008aA00579c1307B0EF2c499aD98a8ce58e58 | 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85 |
| Polygon (matic) | 0xc2132D05D31c914a87C6611C10748AEb04B58e8F | 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359 |
| Solana (sol) | Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v |
| Morph (morph) | 0xe7cd86e13AC4309349F30B3435a9d337750fC82D | โ (not yet available) |
| Chain | Contract |
|-------|----------|
| Ethereum (eth) | 0x54D2252757e1672EEaD234D27B1270728fF90581 |
| Morph (morph) | 0x389C08Bc23A7317000a1FD76c7c5B0cb0b4640b5 |
For other tokens, use token-info or a block explorer to verify the contract address before calling swap endpoints.
The data commands (token-info, kline, tx-info, liquidity) are most useful when combined, not in isolation:
token-info (price + market cap + holders) โ tx-info (recent activity) โ security (safety check). This gives a complete picture in 3 calls.kline --period 1h --size 24 for daily trend, --period 1d --size 30 for monthly. Compare with tx-info to see if volume supports the price movement.liquidity to check pool size. If your trade amount is >2% of pool liquidity, expect significant slippage.rankings --name topGainers finds trending tokens. Always follow up with security before acting on any discovery.tx-info shows buyer/seller count and volume. A high volume with very few buyers suggests whale activity โ proceed with caution.Before executing any swap, the agent should silently run risk checks and then present a single confirmation summary to the user. Do not prompt the user at every step.
Behind the scenes (agent runs automatically):
1. security โ Check highRisk, honeypot, tax
2. token-info โ Get current price, market cap, holder count
3. liquidity โ Check pool depth vs trade size
4. swap-quote โ Get route, expected output, slippage
If any red flags are found (highRisk, high tax, low liquidity, extreme slippage), stop and warn the user immediately with specifics.
If everything looks normal, present a single confirmation:
Swap Summary:
โข 0.1 USDC โ ~0.1000 USDT (BNB Chain)
โข Market: bgwevmaggregator
โข Slippage tolerance: 0.5%
โข Price impact: ~0.07%
โข Estimated gas: ~$0.05
โข Token safety: โ
No risks found
โข Deadline: [user's configured preference, default 300s]
Proceed? [yes/no]
After user confirms:
5. swap-calldata โ Generate unsigned transaction
6. (wallet signs the transaction)
7. swap-send โ Broadcast via MEV-protected endpoint
For well-known tokens (ETH, SOL, BNB, USDT, USDC, DAI, WBTC), the risk checks will almost always pass โ the single confirmation is sufficient. For unfamiliar or new tokens, be more verbose about the risks.
The Order Mode API (order-* commands) is the recommended way to execute swaps. It supports everything the legacy swap-* flow does, plus:
feeRate)When to use Order Mode vs Legacy Swap:
| Scenario | Use |
|----------|-----|
| Cross-chain swap | Order Mode (only option) |
| No native token for gas | Order Mode with no_gas |
| Same-chain swap | Either (Order Mode recommended) |
| Need order tracking/refunds | Order Mode |
1. order-quote โ Get price, recommended market, check no_gas support
2. order-create โ Create order, receive unsigned tx/signature data
3. (wallet signs the transaction or EIP-712 typed data)
4. order-submit โ Submit signed tx, get orderId confirmation
5. order-status โ Poll until status = success/failed/refunded
Key fields to check:
| Field | Meaning |
|-------|---------|
| toAmount | Estimated output (human-readable) |
| market | Required for order-create โ pass it exactly |
| slippage | Recommended slippage tolerance |
| priceImpact | Price impact percentage |
| fee.totalAmountInUsd | Total fee in USD |
| fee.appFee | Partner's fee portion |
| fee.platformFee | Platform fee portion |
| features: ["no_gas"] | If present, gasless mode is available |
| eip7702Bindend | Whether address has EIP-7702 binding |
Gasless mode uses EIP-7702 delegation โ a backend relayer constructs and pays for the transaction on your behalf. The gas cost is deducted from the input token amount.
order-quote โ check if features contains "no_gas"--feature no_gas to order-createsignatures (not txs) โ EIP-712 + EIP-7702 authhash fields, submit signaturesAuto-detection logic:
Default: always use no_gas when available.
if order-quote returns features: ["no_gas"]:
auto-apply --feature no_gas to order-create
elif user has no native token for gas:
warn: "Insufficient gas. This route does not support gasless mode."
else:
proceed without no_gas (normal tx mode)
โ ๏ธ Important: features in order-quote is not always reliable.
In testing, some routes return features: [] in the quote but still accept --feature no_gas in order-create. When the wallet has zero native token balance, always try no_gas regardless of the quote's features field. If order-create rejects it, fall back to informing the user they need gas.
The response contains either txs (normal transaction) or signatures (EIP-7702 gasless):
Mode 1: Normal Transaction (txs)
{
"orderId": "...",
"txs": [{
"kind": "transaction",
"chainName": "base",
"chainId": "8453",
"data": {
"to": "0x...",
"calldata": "0x...",
"gasLimit": "54526",
"nonce": 308,
"value": "0",
"supportEIP1559": true,
"maxFeePerGas": "...",
"maxPriorityFeePerGas": "..."
}
}]
}
โ Build transaction from data fields, sign with wallet, submit raw tx hex.
Mode 2: EIP-7702 Signature (signatures) โ Gasless
Returned when --feature no_gas is used. Contains 2 signatures to sign:
{
"orderId": "...",
"signatures": [
{
"kind": "signature",
"chainName": "base",
"chainId": "8453",
"hash": "0x...", // โ Sign THIS hash directly
"data": {
"signType": "eip712", // EIP-712: approve + swap bundled
"types": { "Aggregator": [...], "Call": [...] },
"domain": { "name": "BW7702Admin", "verifyingContract": "0x8C80e4d1..." },
"message": {
"calls": [
{ "target": "0x8335...", "callData": "0x095ea7b3..." }, // approve
{ "target": "0xBc1D...", "callData": "0xd984396a..." } // swap
]
}
}
},
{
"kind": "signature",
"chainName": "base",
"chainId": "8453",
"hash": "0x...", // โ Sign THIS hash directly
"data": {
"signType": "eip7702_auth", // EIP-7702: delegate to smart contract
"contract": "0xa845C743...", // delegation target
"nonce": "0"
}
}
]
}
What each signature does:
โ Sign each item's hash field with unsafe_sign_hash. Do NOT recompute hashes.
โ Backend relayer receives signatures, constructs full EIP-7702 type-4 tx, pays gas, broadcasts.
Critical: Use the API-provided hash field to sign. Do NOT recompute EIP-712 hashes yourself.
The encode_typed_data implementations in common libraries (eth-account, ethers.js) may produce different hashes for complex nested structs (Call[] with bytes callData). The API pre-computes the correct hash and returns it in each signature item's hash field.
Signing logic (for signatures mode โ gasless/EIP-7702):
from eth_account import Account
acct = Account.from_key(private_key)
signed_list = []
for sig_item in order_data["signatures"]:
hash_bytes = bytes.fromhex(sig_item["hash"][2:])
signed = acct.unsafe_sign_hash(hash_bytes)
signed_list.append("0x" + signed.signature.hex())
# Submit: order-submit --order-id <id> --signed-txs <signed_list>
Signing logic (for txs mode โ normal gas):
for tx_item in order_data["txs"]:
tx_dict = {
"to": tx_item["data"]["to"],
"data": tx_item["data"]["calldata"],
"gas": int(tx_item["data"]["gasLimit"]),
"nonce": int(tx_item["data"]["nonce"]),
"chainId": int(tx_item["chainId"]),
"gasPrice": int(tx_item["data"]["gasPrice"]),
"value": <parse tx_item["data"]["value"]>,
}
signed_tx = acct.sign_transaction(tx_dict)
signed_list.append("0x" + signed_tx.raw_transaction.hex())
Helper script: python3 scripts/order_sign.py --private-key <key> accepts order-create JSON from stdin and outputs signed hex array.
Backend flow after submit:
Agent signs โ submits signatures โ Backend relayer receives โ
Constructs full EIP-7702 tx (embeds our signatures) โ
Relayer pays gas โ Broadcasts to chain
The Agent never constructs the full EIP-7702 transaction. The backend relayer handles tx construction, gas payment, and broadcasting. We only provide signatures.
Important notes:
EIP-7702 binding state affects signature count:
| State | eip7702Bindend | Signatures | What's signed |
|-------|-------------------|-----------|---------------|
| First gasless tx | false | 2 | EIP-712 (approve + swap) + EIP-7702 auth (delegation) |
| Subsequent gasless tx | true | 1 | EIP-712 (swap only, approve already done) |
The binding persists on-chain. Once bound, future gasless transactions on the same chain are faster (1 signature, ~5 seconds).
init โ processing โ success
โ failed
โ refunding โ refunded
| Status | Meaning | Action |
|--------|---------|--------|
| init | Order created, not yet submitted | Use toAmount for confirmation |
| processing | Transaction in progress | Poll, show "็ญๅพ
็กฎ่ฎค..." |
| success | Completed successfully | Show receiveAmount + txId + explorer link |
| failed | Transaction failed | Show error, suggest retry |
| refunding | Refund in progress | Wait, notify user |
| refunded | Funds returned | Show refund tx details |
order-status response fields (all statuses):
| Field | Description | Available |
|-------|-------------|-----------|
| orderId | Order identifier | Always |
| status | Current status | Always |
| fromChain / toChain | Source / destination chain | Always |
| fromContract / toContract | Token contracts | Always |
| fromAmount | Input amount | Always |
| toAmount | Estimated output (more accurate than quote) | Always (after create) |
| receiveAmount | Actual received amount | Only on success |
| txs | Array of {chain, txId, stage, tokens} | Only on success |
| createTime / updateTime | Unix timestamps | Always |
Polling strategy:
processing after max wait, give user the order ID to check later.Cross-chain minimum amount: Varies by chain. EVM chains: ~$1-5. Solana: $10 minimum (liqBridge only, no CCTP). Morph: $5 minimum. Below minimum returns 80002 amount too low.
no_gas requires quote support: Only use --feature no_gas when order-quote returns "no_gas" in the features array. The API may accept the flag at create time without validation, but the backend will fail to execute. Solana currently does NOT support no_gas (features always []).
Base same-chain without no_gas: order-create on Base without --feature no_gas returns 80000 system error when the wallet has no ETH. This is because the API can't construct a normal tx for an account with no gas. Solution: use no_gas.
EIP-712 hash mismatch: Do NOT use encode_typed_data from eth-account or similar libraries. Their encoding of nested Call[] with bytes callData differs from the API/contract implementation. Always sign the API-provided hash directly.
Signature format: 65 bytes r + s + v where v is 27 or 28 (not y_parity 0/1). This is the standard output of unsafe_sign_hash.
Order expiry: Orders have a deadline (typically 2 minutes from creation). Sign and submit promptly after order-create. If expired, create a new order.
No approve needed for gasless: EIP-7702 gasless mode bundles approve + swap into one atomic operation via the Aggregator contract. No separate approve transaction needed.
Never duplicate order execution: Signed and submitted orders are irreversible. Before creating a new order for the same trade, always check the previous order's status via order-status. If a previous script/process might still be running, verify it's truly dead before retrying. Creating and submitting two orders for the same trade will execute both and spend double the funds.
Cross-chain orders return multiple TXs: A successful cross-chain order-status returns 2 entries in txs[] โ stage: "source" (origin chain) and stage: "target" (destination chain). Show both explorer links to the user.
Cross-chain toAddress MUST use target chain's native address format: When swapping cross-chain, the toAddress must be a valid address on the destination chain, not the source chain. This applies to BOTH order-quote and order-create โ the quote will return 80000 without it for non-EVM targets.
toAddress must be a Solana address (Base58, Ed25519) โ must be passed in quote tootoAddress must be a Tron address (T... Base58Check)| Code | Meaning | Action |
|------|---------|--------|
| 80001 | Insufficient balance | Check balance, suggest smaller amount |
| 80002 | Amount too low | Increase amount |
| 80003 | Amount too high | Decrease amount |
| 80004 | Order expired | Re-create order |
| 80005 | Insufficient liquidity | Try different route or smaller amount |
| 80006 | Invalid request | Check parameters |
| 80007 | Signature mismatch | Re-sign with correct data |
Trust model: We sign hashes provided by the API. Verification layers:
| Layer | Verified | Method |
|-------|----------|--------|
| DOMAIN_SEPARATOR | โ
| Matches on-chain contract 0x8C80e4d1... |
| AGGREGATOR_TYPE_HASH | โ
| Found in contract bytecode |
| CALL_TYPE_HASH | โ
| Found in contract bytecode |
| Message content | โ
Readable | EIP-712 message.calls shows approve/swap targets & calldata |
| Hash correctness | โ ๏ธ Trusted | Cannot independently recompute due to encoding differences |
| Response integrity | โ ๏ธ TLS only | No server-side signature on response (enhancement pending) |
Pre-sign verification checklist:
message.calls โ verify targets are known contracts (router, token)message.msgSender matches your wallet addressdomain.verifyingContract is the known BW7702Admin contractdomain.chainId matches expected chainPlanned enhancement: API response signing with server public key for MITM protection.
| Chain | Code | Same-chain | Cross-chain |
|-------|------|-----------|-------------|
| Ethereum | eth | โ
| โ
|
| Solana | sol | โ
| โ
(EVMโSol โ
; SolโEVM requires SOL for gas) |
| BNB Chain | bnb | โ
| โ
|
| Base | base | โ
| โ
|
| Arbitrum | arbitrum | โ
| โ
|
| Polygon | matic | โ
| โ
|
| Morph | morph | โ
| โ
|
| From Chain | liqBridge | CCTP | |-----------|----------|------| | Ethereum | $1 โ $200,000 | $0.1 โ $500,000 | | Solana | $10 โ $200,000 | โ | | BNB Chain | $1 โ $200,000 | โ | | Base | $1 โ $200,000 | $0.1 โ $500,000 | | Arbitrum | $1 โ $200,000 | $0.1 โ $500,000 | | Polygon | $1 โ $50,000 | $0.1 โ $500,000 | | Morph | $5 โ $50,000 | โ |
Key principle: order-create before present, present before sign.
The order is a contract โ the user sees the actual order details, confirms, THEN the agent signs and submits. The agent MUST NOT sign or submit without explicit user confirmation.
1. security โ Check token safety (automatic, silent unless issues found)
2. order-quote โ Get price, market, check no_gas + eip7702Bindend
3. order-create โ Create order (auto-apply no_gas if available)
Returns orderId + unsigned tx/signature data
4. order-status โ Get order details (toAmount is more accurate than quote)
5. PRESENT โ Show confirmation summary to user (MANDATORY)
Use toAmount from order-status, NOT from quote
Include: order ID, amounts, fees, gas mode, signatures, safety
Include: EIP-712 verification (domain, msgSender, calls)
Include: small amount gasless warning if < $1
6. WAIT โ User must explicitly say "yes" / "confirm" / "ๆง่ก"
If user says "no" โ abort, do not sign
7. Sign + Submit โ Sign using API-provided hash fields, then order-submit
8. Poll once โ Wait 10s, then order-status once
If success โ show receiveAmount + txId + explorer link
If still processing โ show order ID + status, tell user to check later
DO NOT loop/block waiting for completion โ return control to user immediately
Why this order matters:
Completion message (same-chain):
โ
Swap Complete
โข Order: f347d76e...
โข 1 USDC โ 0.98382 USDT (Base)
โข Gas mode: Gasless
โข Tx: 0x786eff3d...
โข Explorer: https://basescan.org/tx/0x786eff3d...
Completion message (cross-chain):
โ
Swap Complete
โข Order: 861d8427...
โข 2 USDC (Base) โ 1.877485 USDT (Polygon)
โข Gas mode: Gasless
โข Source TX (Base): 0x2954bb0d...
https://basescan.org/tx/0x2954bb0d...
โข Target TX (Polygon): 0xd72483c8...
https://polygonscan.com/tx/0xd72483c8...
If failed:
โ Swap Failed
โข Order: f365ba3d...
โข 0.1 USDC โ USDT (Base)
โข Status: failed
โข Possible causes: relayer error, insufficient liquidity, expired
Block explorer URLs by chain:
| Chain | Explorer URL |
|-------|-------------|
| eth | https://etherscan.io/tx/{txId} |
| bnb | https://bscscan.com/tx/{txId} |
| base | https://basescan.org/tx/{txId} |
| arbitrum | https://arbiscan.io/tx/{txId} |
| matic | https://polygonscan.com/tx/{txId} |
| optimism | https://optimistic.etherscan.io/tx/{txId} |
| sol | https://solscan.io/tx/{txId} |
| trx | https://tronscan.org/#/transaction/{txId} |
Poll timing: ONE poll only.
success โ show completion message (receiveAmount + txId + explorer link).processing or init โ show "ๅทฒๆไบค" message with order ID and source TX if available. Do NOT keep polling. Return control to the user.Gas mode strategy: ALWAYS try gasless first.
1. Always pass --feature no_gas to order-create (regardless of quote features field)
2. Check response:
a. Returns `signatures` array โ Gasless โ
proceed with EIP-712 signing
b. Returns `txs` array (normal transactions) โ Gasless NOT supported on this chain
โ Warn user: "โ ๏ธ This chain does not support gasless. Need native token for gas."
โ Check if wallet has native token balance
โ If no balance: "โ Cannot execute: no [MATIC/ETH/...] for gas and gasless unavailable"
โ If has balance: proceed with normal tx signing, show "Gas mode: Normal"
Why always try gasless:
features field in order-quote is unreliable (often returns [] even when gasless works)eip7702Bindend / eip7702Contract fields are more reliable but still not definitiveno_gas and check if response has signatures or txsGasless support by chain (as of 2026-03-04):
| Chain | Gasless (EIP-7702) | Notes |
|-------|-------------------|-------|
| Base | โ
Supported | Tested, confirmed |
| Ethereum | โ
Supported | โ |
| BNB Chain | โ
Supported | โ |
| Polygon | โ
Supported | Same-chain confirmed; cross-chain requires 7702 binding first |
| Arbitrum | โ
Supported | โ |
| Morph | โ
Supported | โ |
| Solana | โ Not supported | Solana as source chain: no_gas not available (quote returns features: []). EVMโSol cross-chain works with gasless on the EVM source chain. |
โ ๏ธ Cross-chain gasless requires source chain 7702 binding. If the wallet has never done a gasless transaction on the source chain, the first cross-chain order will fall back to normal txs. Do a same-chain gasless swap first to bind 7702, then cross-chain gasless will work.
Only use gasless when order-quote returns "no_gas" in features. Do not blindly try โ the API accepts the flag but backend execution will fail if unsupported.
User override: If the user explicitly says to use their own gas (e.g., "use my gas", "user gas", "ไธ่ฆ gasless", "็จ่ชๅทฑ็ gas"), do NOT pass --feature no_gas to order-create. The order will use normal gas mode instead, and gas is paid from the wallet's native token balance. Show "Gas mode: User Gas (native token)" in the confirmation summary.
| Source | Field | When Available | Accuracy |
|--------|-------|---------------|----------|
| order-quote | toAmount | Before create | Rough estimate, pre-gas |
| order-status (init) | toAmount | After create, before submit | Better estimate โ use this for confirmation |
| order-status (success) | receiveAmount | After completion | Actual received amount |
Always use order-status.toAmount for the confirmation summary, not the quote's toAmount. The order-status value is calculated after actual routing and is more accurate.
no_gas mode, gas is still deducted from the input. Even the order-status toAmount may not fully reflect gas deduction.receiveAmount.toAmount as an estimate: use "~" prefix (e.g., "~1.94 USDT").Always default to gasless โ pass --feature no_gas to order-create on every trade. Do not check features field first, do not ask the user to choose.
How to detect gasless success vs fallback:
signatures array (non-empty) โ gasless mode active โ
txs array (non-empty) โ chain doesn't support gasless, fell back to normal modeRationale: Gasless mode eliminates the need for users/agents to maintain native token balances on every chain. The gas cost is minimal compared to convenience. Trying gasless has zero cost โ if the chain doesn't support it, the API silently falls back to normal txs.
โ ๏ธ MANDATORY: The agent MUST present the confirmation summary and wait for explicit user approval before signing and submitting. Never skip this step. No exceptions.
Confirmation summary (gasless, same-chain):
Order Created โ
โข Order: f347d76e4b7e434897c2c699b7a588b9
โข 0.1 USDC โ ~0.086 USDT (Base)
โข โ ๏ธ Gasless: gas ไป่พๅ
ฅ้้ขๆฃ้ค๏ผๅฐ้ขไบคๆ gas ๅ ๆฏ่พ้ซ
โข Market: bgwevmaggregator
โข Price impact: 0.009%
โข Fees: $0.0003 (app fee)
โข Gas mode: Gasless โ
(EIP-7702 ๅทฒ็ปๅฎ)
โข Signatures to sign: 1 (EIP-712)
โข Token safety: โ
Both verified
EIP-712 Verification:
โข domain: BW7702Admin @ 0x8C80e4d1... โ
โข msgSender: matches our wallet โ
โข calls: 1 (swap via router 0xBc1D9760...)
Confirm and sign? [yes/no]
Cross-chain gasless example:
Order Created โ
โข Order: 9c3f5bcab4a2449ea5e66a9770ea7169
โข 2 USDC (Base) โ ~1.94 USDT (Polygon)
โข โ ๏ธ Gasless: gas ไป่พๅ
ฅ้้ขๆฃ้ค
โข Market: bkbridgev3.liqbridge (cross-chain bridge)
โข Price impact: 0.024%
โข Fees: $0.014 (app $0.006 + platform $0.006 + gas $0.002)
โข Gas mode: Gasless โ
(EIP-7702 ๅทฒ็ปๅฎ)
โข Signatures to sign: 1 (EIP-712)
โข Token safety: โ
Both verified
Confirm and sign? [yes/no]
Normal gas example:
Order Created โ
โข Order: a1b2c3d4e5f6...
โข 2.0 USDC (Base) โ ~1.95 USDT (BNB Chain)
โข Market: bkbridgev3.liqbridge
โข Price impact: 0.057%
โข Fees: $0.114 total
โข Gas mode: Normal (native token)
โข Transactions to sign: 1
โข Token safety: โ
Both verified
Confirm and sign? [yes/no]
โ ๏ธ toAmount in confirmation uses order-status (init), not quote. This is more accurate because it reflects actual routing. However, gasless gas deduction may still reduce the final receiveAmount further.
Confirmation summary MUST include:
bgwAggregator, bkbridgev3.liqbridge)Gas mode display rules:
Small amount gasless warning: When input amount < $1 USD, show warning: gasless gas cost is fixed (~$0.01-0.02) regardless of trade size. For small trades this can be 10-15% of the input. For amounts > $10 the gas overhead is < 0.2% and negligible.
| Input Amount | Estimated Gas Overhead | |-------------|----------------------| | $0.10 | ~15% โ ๏ธ | | $1.00 | ~1.5% | | $10.00 | ~0.15% | | $100.00 | ~0.015% |
Mnemonic (12/24 words)
โโ Seed (512 bits via PBKDF2)
โโ Master Key
โโ Derivation Path (BIP-44)
โโ m/44'/60'/0'/0/0 โ EVM private key โ ETH/BNB/Base/Arbitrum/Polygon address
โโ m/44'/60'/0'/0/1 โ EVM account #2
โโ m/44'/501'/0'/0' โ Solana private key (Ed25519)
โโ m/44'/195'/0'/0/0 โ Tron private key
Critical facts:
m/44'/60'/0'/0/0.Principle: minimal privilege, no persistence.
Storage: 1Password only (never local files, env vars, or code)
Injection: Fetch โ use โ destroy in same script execution
Scope: Single private key, not full mnemonic
Derivation: Done once during setup, only the derived key is stored
Why agents hold a private key, not a mnemonic:
Key retrieval pattern (Python):
# Fetch from 1Password, use, discard
import subprocess
key = subprocess.run(
["python3.13", "scripts/op_sdk.py", "get", "Agent Wallet", "--field", "evm_key", "--reveal"],
capture_output=True, text=True
).stdout.strip()
# ... use key for signing ...
del key # explicit cleanup
| Type | Use Case | How to Sign |
|------|----------|-------------|
| Raw Transaction (type 0/2) | Normal transfers, swaps | Account.sign_transaction(tx_dict) โ full signed tx hex |
| EIP-191 (personal_sign) | Message signing, off-chain auth | Account.sign_message(encode_defunct(msg)) |
| EIP-712 (typed data) | Structured data (permits, orders) | Account.sign_message(encode_typed_data(...)) or unsafe_sign_hash(hash) |
| EIP-7702 (delegation auth) | Delegate EOA to smart contract | unsafe_sign_hash(keccak(0x05 \|\| rlp([chainId, addr, nonce]))) |
When to use which:
txs with kind: "transaction" โ Raw Transaction signingsignatures with signType: "eip712" โ EIP-712 (use API hash)signatures with signType: "eip7702_auth" โ EIP-7702 delegationโ ๏ธ unsafe_sign_hash vs sign_message:
sign_message adds the EIP-191 prefix (\x19Ethereum Signed Message:\n32)unsafe_sign_hash signs the raw hash directly (no prefix)unsafe_sign_hash โ the hash is already the final digestsign_message on a pre-computed hash produces a wrong signature| Chain Family | Curve | Signing Library | Address Format | |-------------|-------|----------------|----------------| | EVM (ETH/BNB/Base/...) | secp256k1 | eth-account | 0x... (20 bytes, checksummed) | | Solana | Ed25519 | solders / solana-py | Base58 (32 bytes) | | Tron | secp256k1 | Same as EVM, Base58Check address | T... |
EVM all-chain: Sign once, broadcast to any EVM chain. The chainId in the tx prevents replay across chains.
Type 0 (Legacy): {nonce, gasPrice, gasLimit, to, value, data}
Type 2 (EIP-1559): {nonce, maxFeePerGas, maxPriorityFeePerGas, gasLimit, to, value, data, chainId}
Type 4 (EIP-7702): {... + authorizationList: [{chainId, address, nonce, y_parity, r, s}]}
Key fields for swap transactions:
to: Router contract (not the destination token)data: Encoded swap calldata from APIvalue: Amount of native token to send (0 for ERC-20 swaps, >0 for native โ token)nonce: Must match account's current nonce (API provides this)gasLimit / gasPrice: API provides estimatesOn EVM chains (Ethereum, BNB Chain, Base, Arbitrum, Optimism), tokens require an approve transaction before the router contract can spend them. Without approval, the swap transaction will fail on-chain and still consume gas fees.
swap-calldata, check if the token has sufficient allowance for the BGW router (0xBc1D9760bd6ca468CA9fB5Ff2CFbEAC35d86c973).Include the approval status in the confirmation summary when relevant:
โข Token approval: โ ๏ธ USDC not yet approved for router (one-time gas ~$0.03)
Combine multiple signals to assess token risk. No single indicator is definitive:
| Signal | Source | Red Flag |
|--------|--------|----------|
| highRisk = true | security | Critical โ do not trade |
| cannotSellAll = true | security | Honeypot-like behavior |
| buyTax or sellTax > 5% | security | Hidden cost, likely scam |
| isProxy = true | security | Owner can change rules anytime |
| Holder count < 100 | token-info | Extremely early or abandoned |
| Single holder > 50% supply | token-info | Rug pull risk |
| LP lock = 0% | liquidity | Creator can pull all liquidity |
| Pool liquidity < $10K | liquidity | Any trade will cause massive slippage |
| Very high 5m volume, near-zero 24h volume | tx-info | Likely wash trading |
| Token age < 24h | token-info | Unproven, higher risk |
When multiple red flags appear together, strongly advise the user against trading.
Important: distinguish between slippage tolerance and actual price impact. These are different things:
Slippage tolerance (auto-calculated by BGW):
The swap-quote response includes a slippage field (e.g., "0.5" = 0.5%). This is the system's recommended tolerance, auto-calculated based on token volatility and liquidity.
In swap-calldata, you can override it:
--slippage <number> โ custom tolerance (1 = 1%). If omitted, uses system default.toMinAmount โ alternative: specify the exact minimum tokens to receive. More precise for advanced users.Slippage tolerance thresholds:
| Tolerance | Action | |-----------|--------| | โค 1% | Normal for major pairs. Show in summary. | | 1-3% | Acceptable for mid-cap tokens. Include in summary. | | 3-10% | Warn user. Suggest reducing trade size or setting a custom lower value. | | > 10% | Strongly warn. Low liquidity or high volatility. Suggest splitting into smaller trades. | | > 0.5% for stablecoin pairs | Abnormal. Flag to user โ stablecoin swaps should have minimal slippage. |
Price impact (calculated by agent):
token-infoswap-quote (= toAmount / fromAmount)(market_price - quote_price) / market_price ร 100%Price impact > 3% means the trade size is too large relative to available liquidity. The liquidity command can confirm โ if trade amount > 2% of pool size, expect significant impact.
Transaction costs vary by chain. Be aware of these when presenting swap quotes:
| Chain | Typical Gas | Notes | |-------|------------|-------| | Solana | ~$0.001-0.01 | Very cheap, rarely a concern | | BNB Chain | ~$0.05-0.30 | Low, but check during congestion | | Ethereum | ~$1-50+ | Highly variable. Small trades (<$100) may not be worth the gas. | | Base / Arbitrum / Optimism | ~$0.01-0.50 | L2s are cheap but not free |
Important considerations:
buyTax and sellTax from the security audit are on top of gas fees. A 5% sell tax on a $100 trade = $5 gone before gas.The swap-send command broadcasts a signed raw transaction via BGW's MEV-protected endpoint. This is the final step in the swap flow.
Command format:
python3 scripts/bitget_api.py swap-send --chain <chain> --txs "<id>:<chain>:<from_address>:<signed_raw_tx>"
Parameter breakdown:
--chain: Chain name (e.g., bnb, eth, sol)--txs: One or more transaction strings in format id:chain:from:rawTx
id: Transaction identifier (use a unique string, e.g., tx1 or a UUID)chain: Chain name again (must match --chain)from: The sender's wallet addressrawTx: The signed raw transaction hex (with 0x prefix for EVM)Complete swap flow using only CLI commands:
# Step 1: Get quote
python3 scripts/bitget_api.py swap-quote \
--from-chain bnb --from-contract 0x55d398326f99059fF775485246999027B3197955 \
--to-contract 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d \
--amount 0.1
# Step 2: Get calldata (use market value from step 1 response)
python3 scripts/bitget_api.py swap-calldata \
--from-chain bnb --from-contract 0x55d398326f99059fF775485246999027B3197955 \
--to-contract 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d \
--amount 0.1 --from-address <wallet> --to-address <wallet> \
--market bgwevmaggregator
# Step 3: Sign the calldata externally (wallet app, web3.py, etc.)
# This produces a signed raw transaction hex
# Step 4: Broadcast
python3 scripts/bitget_api.py swap-send --chain bnb \
--txs "tx1:bnb:<wallet_address>:<signed_raw_tx_hex>"
Key points:
:) is the delimiter in --txs. Since EVM raw transactions don't contain colons, this format is safe.--txs "tx1:..." "tx2:..."sol not solana, bnb not bsc. See the Chain Identifiers table below.batch-token-info uses --tokens "sol:<addr1>,eth:<addr2>" โ chain and address are colon-separated, pairs are comma-separated.liquidity command returns pool info including LP lock percentage. 100% locked LP is generally a positive signal; 0% means the creator can pull liquidity.All scripts are in scripts/ and use Python 3.11+. No external credential setup needed โ demo API keys are built in.
scripts/bitget_api.py โ Unified API Client# Token info (price, supply, holders, socials)
python3 scripts/bitget_api.py token-info --chain sol --contract <address>
# Token price only
python3 scripts/bitget_api.py token-price --chain sol --contract <address>
# Batch token info (comma-separated)
python3 scripts/bitget_api.py batch-token-info --tokens "sol:<addr1>,eth:<addr2>"
# K-line data
python3 scripts/bitget_api.py kline --chain sol --contract <address> --period 1h --size 24
# Token transaction info (5m/1h/4h/24h volume, buyers, sellers)
python3 scripts/bitget_api.py tx-info --chain sol --contract <address>
# Batch transaction info
python3 scripts/bitget_api.py batch-tx-info --tokens "sol:<addr1>,eth:<addr2>"
# Token rankings (topGainers / topLosers)
python3 scripts/bitget_api.py rankings --name topGainers
# Token liquidity pools
python3 scripts/bitget_api.py liquidity --chain sol --contract <address>
# Historical coins (discover new tokens)
python3 scripts/bitget_api.py historical-coins --create-time <datetime> --limit 20
# Security audit
python3 scripts/bitget_api.py security --chain sol --contract <address>
# Swap quote (amount is human-readable)
python3 scripts/bitget_api.py swap-quote --from-chain sol --from-contract <addr> --to-contract <addr> --amount 1
# Swap calldata (returns tx data for signing; --slippage is optional, system auto-calculates if omitted)
python3 scripts/bitget_api.py swap-calldata --from-chain sol --from-contract <addr> --to-contract <addr> --amount 1 --from-address <wallet> --to-address <wallet> --market <market> --slippage 2
# Swap send (broadcast signed transaction)
python3 scripts/bitget_api.py swap-send --chain sol --raw-transaction <signed_hex>
# --- Order Mode (cross-chain + gasless) ---
# Order quote (supports cross-chain: fromChain != toChain)
python3 scripts/bitget_api.py order-quote \
--from-chain base --from-contract 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \
--to-chain bnb --to-contract 0x55d398326f99059fF775485246999027B3197955 \
--amount 2.0 --from-address <wallet>
# Order create (returns unsigned tx data; use --feature no_gas for gasless)
python3 scripts/bitget_api.py order-create \
--from-chain base --from-contract 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \
--to-chain bnb --to-contract 0x55d398326f99059fF775485246999027B3197955 \
--amount 2.0 --from-address <wallet> --to-address <wallet> \
--market bkbridgev3.liqbridge --slippage 3.0 --feature no_gas
# Order submit (submit signed transaction)
python3 scripts/bitget_api.py order-submit \
--order-id <orderId> --signed-txs "0x<signed_hex>"
# Order status (poll order completion)
python3 scripts/bitget_api.py order-status --order-id <orderId>
| Chain | ID | Code | |-------|------|------| | Ethereum | 1 | eth | | Solana | 100278 | sol | | BNB Chain | 56 | bnb | | Base | 8453 | base | | Arbitrum | 42161 | arbitrum | | Tron | 6 | trx | | Ton | 100280 | ton | | Sui | 100281 | suinet | | Optimism | 10 | optimism | | Polygon | 137 | matic |
Use empty string "" for native tokens (ETH, SOL, BNB, etc.).
Partner-Code: bgw_swap_public header (hardcoded in script)โ ๏ธ Swap amounts are human-readable โ pass
0.1for 0.1 USDT, NOT100000000000000000. ThetoAmountin responses is also human-readable. This differs from most on-chain APIs.
Order Mode is the key upgrade in v2026.3.5. It enables two capabilities no other AI agent swap skill offers:
โฝ Gasless Transactions (EIP-7702)
๐ One-Step Cross-Chain Swaps
How it works:
1. order-quote โ Get price + check gasless support
2. order-create โ Create order, receive unsigned data
3. Sign โ Agent signs with wallet key (EIP-712 for gasless, raw tx for normal)
4. order-subm...