Onchain OS Security
5 commands for token risk analysis, DApp phishing detection, transaction pre-execution security, signature safety, and approval management.
Pre-flight Checks
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 proceed to run the command (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 command — macOS/Linux:
shasum -a 256 ~/.local/bin/onchainos; Windows: INLINECODE41
- 4. Check for skill version drift (once per session): If
onchainos --version is newer
than this skill's
metadata.version, display a one-time notice that the skill may be
outdated and suggest the user re-install skills via their platform's method. Do not block.
- 5. Do NOT auto-reinstall on command failures. Report errors and suggest
onchainos --version or manual reinstall from https://github.com/okx/onchainos-skills.
- 6. Rate limit errors. If a command hits rate limits, the shared API key may
be throttled. Suggest creating a personal key at the
OKX Developer Portal. If the
user creates a
.env file, remind them to add
.env to
.gitignore.
Fail-safe Principle (CRITICAL)
Scan completed — risk detected
If a security scan completes successfully and returns action: "block" or action: "warn", follow the Risk Action Priority Rule below. The Agent MUST NOT override risk verdicts.
Scan failed — infrastructure error
If a security scan fails to complete (network error, API timeout, rate limiting, malformed response), the Agent MUST:
- - Report the error clearly to the user.
- Ask the user whether to retry the scan or proceed without scan results.
- If the user chooses to proceed, display a warning:
> "⚠️ Security scan could not be completed. Proceeding without verification — please ensure you trust this operation."
- - Log the skipped scan for auditability.
A security scan that fails to complete is NOT a "pass". Always inform the user and let them make an explicit decision.
Risk Action Priority Rule
INLINECODE50 > warn > safe (empty). The top-level action field reflects the highest priority from riskItemDetail.
| INLINECODE54 value | Risk Level | Agent Behavior |
|---|
| (empty/null) | Low risk | Safe to proceed |
| INLINECODE55 |
Medium risk | Show risk details, ask for explicit user confirmation |
|
block | High risk | Do NOT proceed, show risk details, recommend cancel |
- - Risk scan result is still valid even if simulation fails (
simulator.revertReason may contain the revert reason). - If
warnings field is populated, the scan completed but some data may be incomplete. Still present available risk information. - An empty/null
action in a successful API response means "no risk detected". But if the API call failed, the absence of action does NOT mean safe — apply the fail-safe principle.
Security commands do not require wallet login. They work with any address.
Chain Name Support
The CLI accepts human-readable chain names and resolves them automatically.
| Chain | Name | chainIndex |
|---|
| XLayer | INLINECODE61 | INLINECODE62 |
| Ethereum |
ethereum or
eth |
1 |
| Solana |
solana or
sol |
501 |
| BSC |
bsc or
bnb |
56 |
| Polygon |
polygon or
matic |
137 |
| Arbitrum |
arbitrum or
arb |
42161 |
| Base |
base |
8453 |
| Avalanche |
avalanche or
avax |
43114 |
| Optimism |
optimism or
op |
10 |
| zkSync Era |
zksync |
324 |
| Linea |
linea |
59144 |
| Scroll |
scroll |
534352 |
Address format note: EVM addresses (0x...) work across Ethereum/BSC/Polygon/Arbitrum/Base etc. Solana addresses (Base58) and Bitcoin addresses (UTXO) have different formats. Do NOT mix formats across chain types.
Command Index
| # | Command | Description |
|---|
| 1 | INLINECODE93 | Token risk / honeypot detection (all chains) |
| 2 |
onchainos security dapp-scan | DApp / URL phishing detection (chain-agnostic) |
| 3 |
onchainos security tx-scan | Transaction pre-execution security (EVM + Solana) |
| 4 |
onchainos security sig-scan | Message signature security (EVM only) |
| 5 |
onchainos security approvals | Token approval / Permit2 authorization query (EVM only) |
Reference Loading Rules (MANDATORY)
Before executing ANY security command, you MUST read the corresponding reference document from skills/okx-security/references/. Do NOT rely on prior knowledge — always load the reference first.
| User intent | Read this file FIRST |
|---|
| Token safety, honeypot, is this token safe, 代币安全, 蜜罐检测, 貔貅盘 | INLINECODE99 |
| DApp/URL phishing, is this site safe, 钓鱼网站 |
references/risk-domain-detection.md |
| Transaction safety, tx pre-execution, signature safety, approve safety, 交易安全, 签名安全 |
references/risk-transaction-detection.md |
| Approvals, allowance, Permit2, revoke, 授权管理, 授权查询, 风险授权 |
references/risk-approval-monitoring.md |
When a workflow involves multiple commands (e.g., token-scan then tx-scan), load each reference before executing that command.
Integration with Other Skills
Security scanning is often a prerequisite for other wallet operations:
- - Before
wallet send with a contract token: run token-scan to verify token safety - Before
wallet contract-call with approve calldata: run tx-scan to check spender - Before interacting with any DApp URL: run INLINECODE107
- Before signing any EIP-712 message: run INLINECODE108
Use okx-agentic-wallet skill for the subsequent send/contract-call operations.
Onchain OS 安全
5个用于代币风险分析、DApp钓鱼检测、交易预执行安全、签名安全和授权管理的命令。
前置检查
每次运行任何 onchainos 命令前,请按顺序执行以下步骤。不要向用户回显常规命令输出;仅在安装、更新或处理失败时提供简短的状态更新。
- 1. 获取最新稳定版本:从GitHub API获取最新的稳定版本标签:
curl -sSL https://api.github.com/repos/okx/onchainos-skills/releases/latest
提取 tagname 字段(例如 v1.0.5)到 LATESTTAG。
如果API调用失败且 onchainos 已本地安装,跳过步骤2-3并继续运行命令(用户可能处于离线或速率限制状态;使用旧版本二进制文件比阻塞更好)。如果 onchainos 未安装,则停止并告知用户检查网络连接或从 https://github.com/okx/onchainos-skills 手动安装。
- 2. 安装或更新:如果未找到 onchainos,或者 ~/.onchainos/lastcheck(Windows上为 $env:USERPROFILE\.onchainos\lastcheck)中的缓存超过12小时:
- 从最新版本标签下载安装程序及其校验和文件:
-
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
- 将安装程序的SHA256与 installer-checksums.txt 进行比对。如果不匹配,
停止并发出警告——安装程序可能已被篡改。
- 执行:sh /tmp/onchainos-install.sh(Windows上为 & $env:TEMP\onchainos-install.ps1)。
安装程序内部处理版本比较,仅在需要时下载二进制文件。
- 其他失败情况,请指向 https://github.com/okx/onchainos-skills。
- 3. 验证二进制文件完整性(每个会话一次):运行 onchainos --version 获取已安装版本(例如 1.0.5 或 2.0.0-beta.0)。将已安装标签构造为 v。
下载
已安装版本标签(不一定是LATEST_TAG)的 checksums.txt:
curl -sSL https://github.com/okx/onchainos-skills/releases/download/v
/checksums.txt -o /tmp/onchainos-checksums.txt
查找平台目标并将已安装二进制文件的SHA256与校验和进行比对。
如果不匹配,重新安装(步骤2)并重新验证。如果仍然不匹配,停止并发出警告。
- 平台目标——macOS:arm64->aarch64-apple-darwin,x8664->x8664-apple-darwin;Linux:x8664->x8664-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
- 哈希命令——macOS/Linux:shasum -a 256 ~/.local/bin/onchainos;Windows:(Get-FileHash $env:USERPROFILE\.local\bin\onchainos.exe -Algorithm SHA256).Hash.ToLower()
- 4. 检查技能版本漂移(每个会话一次):如果 onchainos --version 比本技能的 metadata.version 更新,显示一次性通知,说明技能可能已过时,并建议用户通过其平台的方法重新安装技能。不要阻止操作。
- 命令失败时不要自动重新安装。 报告错误并建议使用 onchainos --version 或从 https://github.com/okx/onchainos-skills 手动重新安装。
- 速率限制错误。 如果命令遇到速率限制,共享API密钥可能已被限制。建议在 OKX开发者门户 创建个人密钥。如果用户创建了 .env 文件,提醒他们将 .env 添加到 .gitignore。
故障安全原则(关键)
扫描完成——检测到风险
如果安全扫描成功完成并返回 action: block 或 action: warn,请遵循下面的风险操作优先级规则。代理不得覆盖风险判定。
扫描失败——基础设施错误
如果安全扫描未能完成(网络错误、API超时、速率限制、响应格式错误),代理必须:
- - 向用户清晰报告错误。
- 询问用户是否重试扫描或继续执行而不使用扫描结果。
- 如果用户选择继续,显示警告:
> ⚠️ 安全扫描无法完成。未经验证继续执行——请确保您信任此操作。
未能完成的安全扫描不等于通过。始终告知用户并让他们做出明确决定。
风险操作优先级规则
block > warn > 安全(空)。顶层的 action 字段反映来自 riskItemDetail 的最高优先级。
| action 值 | 风险等级 | 代理行为 |
|---|
| (空/null) | 低风险 | 可以安全继续 |
| warn |
中风险 | 显示风险详情,请求用户明确确认 |
| block | 高风险 | 不要继续,显示风险详情,建议取消 |
- - 即使模拟失败,风险扫描结果仍然有效(simulator.revertReason 可能包含回退原因)。
- 如果 warnings 字段有内容,扫描已完成但某些数据可能不完整。仍然呈现可用的风险信息。
- 在成功的API响应中,空/null的 action 表示未检测到风险。但如果API调用失败,缺少 action 并不表示安全——请应用故障安全原则。
安全命令不需要钱包登录。它们适用于任何地址。
链名称支持
CLI接受人类可读的链名称并自动解析。
| 链 | 名称 | chainIndex |
|---|
| XLayer | xlayer | 196 |
| Ethereum |
ethereum 或 eth | 1 |
| Solana | solana 或 sol | 501 |
| BSC | bsc 或 bnb | 56 |
| Polygon | polygon 或 matic | 137 |
| Arbitrum | arbitrum 或 arb | 42161 |
| Base | base | 8453 |
| Avalanche | avalanche 或 avax | 43114 |
| Optimism | optimism 或 op | 10 |
| zkSync Era | zksync | 324 |
| Linea | linea | 59144 |
| Scroll | scroll | 534352 |
地址格式说明:EVM地址(0x...)适用于Ethereum/BSC/Polygon/Arbitrum/Base等。Solana地址(Base58)和Bitcoin地址(UTXO)具有不同格式。不要在不同链类型之间混用格式。
命令索引
| # | 命令 | 描述 |
|---|
| 1 | onchainos security token-scan | 代币风险/蜜罐检测(所有链) |
| 2 |
onchainos security dapp-scan | DApp/URL钓鱼检测(与链无关) |
| 3 | onchainos security tx