
Okx Dex Swap
Wire your coding agent to quote and execute DEX token swaps on OKX-supported chains through the onchainos CLI.
Overview
okx-dex-swap is an agent skill for the Build phase that guides coding agents to perform DEX token swaps via the OKX onchainos CLI with shared chain-name resolution and session pre-flight checks.
Install
npx skills add https://github.com/okx/onchainos-skills --skill okx-dex-swapWhat is this skill?
- Executes DEX swap flows via the shared onchainos CLI used across OKX OnchainOS skills
- Accepts human-readable chain names (ethereum, base, solana, bsc, arbitrum, xlayer) resolved to chainIndex automatically
- Documents six chains where the wallet can create addresses; 17+ chains available for interaction via onchainos wallet ch
- Session pre-flight: resolve latest GitHub release tag, install or update CLI, then run commands without spamming routine
- Shared chain-index reference table for XLayer (196), Solana (501), Ethereum (1), Base (8453), BSC (56), and Arbitrum (42
- 6 chains support wallet address creation in the shared chain table
- 17+ chains supported for wallet interaction beyond the six address-creation chains
- 4 ordered pre-flight steps before the first onchainos command each session
Adoption & trust: 7.1k installs on skills.sh; 284 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need your agent to swap tokens on-chain without rewriting DEX router logic, chain IDs, and CLI install steps every session.
Who is it for?
Solo builders shipping wallet agents, DeFi automations, or internal tools that must swap on OKX-supported EVM and Solana networks through a single CLI.
Skip if: Teams that want a no-key, fully hosted swap API, centralized exchange-only trades without on-chain wallets, or chains unsupported by onchainos wallet listing.
When should I use this skill?
You need the agent to quote or execute an on-chain DEX swap via OKX onchainos on a named chain after wallet and CLI readiness.
What do I get? / Deliverables
After the skill runs, the agent resolves chains by name, completes onchainos pre-flight, and executes the documented DEX swap CLI flow with status-only reporting unless install or errors occur.
- Completed DEX swap transaction on the chosen chain
- Resolved chainIndex from human-readable chain name
- Brief user-facing status when install, update, or failure occurs
Recommended Skills
Journey fit
Swapping on-chain assets is an integration task you implement while building crypto agents, trading bots, or wallet-backed automation—not a marketing or validation artifact. The skill centers on calling the onchainos CLI and chain APIs to perform swaps, which maps directly to third-party and on-chain integrations in the build phase.
How it compares
Use as an onchainos CLI integration skill—not a generic MCP market-data server or ad-hoc curl against random DEX aggregators.
Common Questions / FAQ
Who is okx-dex-swap for?
Indie developers and agent builders who already use or plan to use OKX OnchainOS and want repeatable, agent-driven DEX swap execution with consistent chain naming and CLI hygiene.
When should I use okx-dex-swap?
Use it during Build integrations when you are wiring swap steps into an agent workflow on Ethereum, Base, BSC, Arbitrum, Solana, or XLayer, after wallet setup and when you want the shared pre-flight before the first onchainos command in a session.
Is okx-dex-swap safe to install?
Swaps move real funds and may require shell, network, and secret access for wallets; review the Security Audits panel on this Prism page and your key-handling policy before enabling the skill in production agents.
SKILL.md
READMESKILL.md - Okx Dex Swap
# Shared Chain Name Support > This file is shared across all onchainos skills. The CLI accepts human-readable chain names and resolves them automatically. The following 6 chains support **wallet address creation** (i.e., you can generate a wallet address on these chains): | Chain | Name | chainIndex | |---|---|---| | XLayer | `xlayer` | `196` | | Solana | `solana` | `501` | | Ethereum | `ethereum` | `1` | | Base | `base` | `8453` | | BSC | `bsc` | `56` | | Arbitrum | `arbitrum` | `42161` | > **Note**: The wallet supports interacting with 17+ chains beyond this list (e.g., Polygon, Avalanche, Optimism). > Run `onchainos wallet chains` for the full list of supported chains. # Shared Pre-flight Checks > This file is shared across all onchainos skills. Follow these steps before the first `onchainos` command each session. Every time before running any `onchainos` 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. **Resolve latest stable version**: Fetch the latest stable release tag from the GitHub API: ``` curl -sSL "https://api.github.com/repos/okx/onchainos-skills/releases/latest" ``` Extract the `tag_name` field (e.g., `v1.0.5`) into `LATEST_TAG`. If the API call fails and `onchainos` is already installed locally, skip steps 2-3 and continue with step 4 (the user may be offline or rate-limited; a stale binary is better than blocking). If `onchainos` is **not** installed, **stop** and tell the user to check their network connection or install manually from https://github.com/okx/onchainos-skills. 2. **Install or update**: If `onchainos` is not found, or if the cache at `~/.onchainos/last_check` (`$env:USERPROFILE\.onchainos\last_check` on Windows) is older than 12 hours: - Download the installer and its checksum file from the latest release tag: - **macOS/Linux**: `curl -sSL "https://raw.githubusercontent.com/okx/onchainos-skills/${LATEST_TAG}/install.sh" -o /tmp/onchainos-install.sh` `curl -sSL "https://github.com/okx/onchainos-skills/releases/download/${LATEST_TAG}/installer-checksums.txt" -o /tmp/installer-checksums.txt` - **Windows**: `Invoke-WebRequest -Uri "https://raw.githubusercontent.com/okx/onchainos-skills/${LATEST_TAG}/install.ps1" -OutFile "$env:TEMP\onchainos-install.ps1"` `Invoke-WebRequest -Uri "https://github.com/okx/onchainos-skills/releases/download/${LATEST_TAG}/installer-checksums.txt" -OutFile "$env:TEMP\installer-checksums.txt"` - Verify the installer's SHA256 against `installer-checksums.txt`. On mismatch, **stop** and warn — the installer may have been tampered with. - Execute: `sh /tmp/onchainos-install.sh` (or `& "$env:TEMP\onchainos-install.ps1"` on Windows). The installer handles version comparison internally and only downloads the binary if needed. - On other failures, point to https://github.com/okx/onchainos-skills. 3. **Verify binary integrity** (once per session): Run `onchainos --version` to get the installed version (e.g., `1.0.5` or `2.0.0-beta.0`). Construct the installed tag as `v<version>`. Download `checksums.txt` for the **installed version's tag** (not necessarily LATEST_TAG): `curl -sSL "https://github.com/okx/onchainos-skills/releases/download/v<version>/checksums.txt" -o /tmp/onchainos-checksums.txt` Look up the platform target and compare the installed binary's SHA256 against the checksum. On mismatch, reinstall (step 2) and re-verify. If still mismatched, **stop** and warn. - Platform targets — macOS: `arm64`->`aarch64-apple-darwin`, `x86_64`->`x86_64-apple-darwin`; Linux: `x86_64`->`x86_64-unknown-linux-gnu`, `aarch64`->`aarch64-unknown-linux-gnu`, `i686`->`i686-unknown-linux-gnu`, `armv7l`->`armv7-unknown-linux-gnueabihf`; Windows: `AMD64`->`x86_64-pc-windows-msvc`, `x86`->`i686-pc-windows-msvc`, `ARM64`->`aarch64-pc-windows-msvc` - Hash c