Loading...
Loading...
Compare original and translation side by side
onchainoscurl -sSL "https://api.github.com/repos/okx/onchainos-skills/releases/latest"tag_namev1.0.5LATEST_TAGonchainosonchainosonchainos~/.onchainos/last_check$env:USERPROFILE\.onchainos\last_checkcurl -sSL "https://raw.githubusercontent.com/okx/onchainos-skills/${LATEST_TAG}/install.sh" -o /tmp/onchainos-install.shcurl -sSL "https://github.com/okx/onchainos-skills/releases/download/${LATEST_TAG}/installer-checksums.txt" -o /tmp/installer-checksums.txtInvoke-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"installer-checksums.txtsh /tmp/onchainos-install.sh& "$env:TEMP\onchainos-install.ps1"onchainos --version1.0.52.0.0-beta.0v<version>checksums.txtcurl -sSL "https://github.com/okx/onchainos-skills/releases/download/v<version>/checksums.txt" -o /tmp/onchainos-checksums.txtarm64aarch64-apple-darwinx86_64x86_64-apple-darwinx86_64x86_64-unknown-linux-gnuaarch64aarch64-unknown-linux-gnui686i686-unknown-linux-gnuarmv7larmv7-unknown-linux-gnueabihfAMD64x86_64-pc-windows-msvcx86i686-pc-windows-msvcARM64aarch64-pc-windows-msvcshasum -a 256 ~/.local/bin/onchainos(Get-FileHash "$env:USERPROFILE\.local\bin\onchainos.exe" -Algorithm SHA256).Hash.ToLower()onchainos --versionmetadata.versiononchainos --version.env.env.gitignoreonchainoscurl -sSL "https://api.github.com/repos/okx/onchainos-skills/releases/latest"tag_namev1.0.5LATEST_TAGonchainosonchainosonchainos~/.onchainos/last_check$env:USERPROFILE\.onchainos\last_checkcurl -sSL "https://raw.githubusercontent.com/okx/onchainos-skills/${LATEST_TAG}/install.sh" -o /tmp/onchainos-install.shcurl -sSL "https://github.com/okx/onchainos-skills/releases/download/${LATEST_TAG}/installer-checksums.txt" -o /tmp/installer-checksums.txtInvoke-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"installer-checksums.txtsh /tmp/onchainos-install.sh& "$env:TEMP\onchainos-install.ps1"onchainos --version1.0.52.0.0-beta.0v<version>checksums.txtcurl -sSL "https://github.com/okx/onchainos-skills/releases/download/v<version>/checksums.txt" -o /tmp/onchainos-checksums.txtarm64aarch64-apple-darwinx86_64x86_64-apple-darwinx86_64x86_64-unknown-linux-gnuaarch64aarch64-unknown-linux-gnui686i686-unknown-linux-gnuarmv7larmv7-unknown-linux-gnueabihfAMD64x86_64-pc-windows-msvcx86i686-pc-windows-msvcARM64aarch64-pc-windows-msvcshasum -a 256 ~/.local/bin/onchainos(Get-FileHash "$env:USERPROFILE\.local\bin\onchainos.exe" -Algorithm SHA256).Hash.ToLower()onchainos --versionmetadata.versiononchainos --versionokx-agentic-walletokx-wallet-portfoliookx-dex-swapokx-dex-tokenokx-dex-marketokx-dex-signalokx-dex-trenchesokx-onchain-gatewayokx-securityokx-agentic-walletokx-wallet-portfoliookx-dex-swapokx-dex-tokenokx-dex-marketokx-dex-signalokx-dex-trenchesokx-onchain-gatewayokx-security--networkeip155:<realChainIndex>onchainos wallet chainsrealChainIndex<chainId>| Chain | Network Identifier |
|---|---|
| Ethereum | |
| X Layer | |
| Base | |
| Arbitrum One | |
| Linea | |
realChainIndexonchainos wallet chainsNon-EVM chains (e.g., Solana, Tron, Ton, Sui) are not supported by x402 payment — onlyidentifiers are accepted.eip155:*
--networkeip155:<realChainIndex>onchainos wallet chainsrealChainIndex<chainId>| 链名称 | 网络标识符 |
|---|---|
| Ethereum | |
| X Layer | |
| Base | |
| Arbitrum One | |
| Linea | |
realChainIndexonchainos wallet chains非EVM链(例如Solana、Tron、Ton、Sui)不支持x402支付 —— 仅接受格式的标识符。eip155:*
HTTP 402 Payment RequiredHTTP 402accepts[0]onchainos payment x402-pay{ signature, authorization }HTTP 402 Payment RequiredHTTP 402accepts[0]onchainos payment x402-pay{ signature, authorization }undefinedundefinedundefinedundefined| # | Command | Description |
|---|---|---|
| 1 | | Sign an x402 payment and return the payment proof |
| 序号 | 命令 | 描述 |
|---|---|---|
| 1 | | 签署x402支付并返回支付凭证 |
IMPORTANT: Do NOT check wallet status or attempt login before sending the request. Only proceed to payment steps if the response is HTTP 402.
重要提示:发送请求前请勿检查钱包状态或尝试登录。仅当响应为HTTP 402时,才进入支付流程。
HTTP 402rawBody = response.body // base64 string
decoded = JSON.parse(atob(rawBody))
option = decoded.accepts[0]option| x402 field | CLI param | Notes |
|---|---|---|
| | CAIP-2 format, e.g. |
| | prefer |
| | |
| | token contract address |
| | optional, default 300 |
onchainos wallet statusThis resource requires x402 payment:
- Network:
(<chain name>)<network>- Token:
(<token symbol>)<asset>- Amount:
(convert from minimal units using token decimals)<human-readable amount>- Pay to:
<payTo>Proceed with payment? (yes / no)
HTTP 402rawBody = response.body // base64字符串
decoded = JSON.parse(atob(rawBody))
option = decoded.accepts[0]option| x402字段 | CLI参数 | 说明 |
|---|---|---|
| | CAIP-2格式,例如 |
| | 优先使用 |
| | |
| | 代币合约地址 |
| | 可选参数,默认值300 |
onchainos wallet status该资源需要x402支付:
- 网络:
(<链名称>)<network>- 代币:
(<代币符号>)<asset>- 金额:
(使用代币小数位数从最小单位转换)<人类可读金额>- 收款地址:
<payTo>是否继续支付?(是/否)
onchainos wallet status"This resource requires payment (x402). You need a wallet to sign the payment. Would you like to create one? (It's free and takes ~30 seconds.)"
onchainos wallet loginonchainos wallet login <email>onchainos wallet status"该资源需要x402支付。您需要一个钱包来签署支付信息。是否需要创建一个钱包?(免费,约30秒即可完成。)"
onchainos wallet loginonchainos wallet login <email>onchainos payment x402-pay{ signature, authorization }onchainos wallet loginonchainos wallet login <email>onchainos payment x402-pay{ signature, authorization }onchainos wallet loginonchainos wallet login <email>decoded.x402Versionx402Version >= 2PAYMENT-SIGNATUREx402Version < 2X-PAYMENTpaymentPayload = { ...decoded, payload: { signature, authorization } }
headerValue = btoa(JSON.stringify(paymentPayload))GET/POST <original-url>
<header-name>: <headerValue>decoded.x402Versionx402Version >= 2PAYMENT-SIGNATUREx402Version < 2X-PAYMENTpaymentPayload = { ...decoded, payload: { signature, authorization } }
headerValue = btoa(JSON.stringify(paymentPayload))GET/POST <原URL>
<header-name>: <headerValue>| Just completed | Suggest |
|---|---|
| Successful replay | 1. Check balance impact → |
| 402 on replay (expired) | Retry from Step 4 with a fresh signature |
| 刚完成的操作 | 建议操作 |
|---|---|
| 请求重试成功 | 1. 查看余额变化 → 使用 |
| 重试时返回402(凭证过期) | 从步骤4重新开始,获取新的签名 |
User: "Fetch https://api.example.com/data — it requires x402 payment"
1. Send GET https://api.example.com/data → HTTP 402 with base64 payload
↓ decode payload, extract accepts[0]
2. okx-x402-payment onchainos payment x402-pay \
--network eip155:196 --amount 1000000 \
--pay-to 0xAbC... \
--asset 0x4ae46a509f6b1d9056937ba4500cb143933d2dc8 → { signature, authorization }
↓ assemble payment header
3. Replay GET https://api.example.com/data with PAYMENT-SIGNATURE header → HTTP 200accepts[0].network--networkaccepts[0].amountmaxAmountRequired--amountaccepts[0].payTo--pay-toaccepts[0].asset--asset用户:"获取https://api.example.com/data的数据 —— 它需要x402支付"
1. 发送GET https://api.example.com/data → 返回HTTP 402及base64编码的负载
↓ 解码负载,提取accepts[0]
2. okx-x402-payment 运行onchainos payment x402-pay \
--network eip155:196 --amount 1000000 \
--pay-to 0xAbC... \
--asset 0x4ae46a509f6b1d9056937ba4500cb143933d2dc8 → 返回{ signature, authorization }
↓ 组装支付头
3. 附加PAYMENT-SIGNATURE头并重试GET https://api.example.com/data → 返回HTTP 200accepts[0].network--networkaccepts[0].amountmaxAmountRequired--amountaccepts[0].payTo--pay-toaccepts[0].asset--assetUser: "Access this paid API, then show me how much I spent"
1. okx-x402-payment (Workflow A above) → payment proof + successful response
2. okx-agentic-wallet onchainos wallet balance --chain 196 → current balance after payment用户:"访问这个付费API,然后告诉我我花了多少钱"
1. okx-x402-payment 执行工作流A → 返回支付凭证及成功响应
2. okx-agentic-wallet 运行onchainos wallet balance --chain 196 → 返回支付后的当前余额User: "Is this x402 payment safe? The asset is 0x4ae46a..."
1. okx-security onchainos security token-scan \
--address 0x4ae46a509f6b1d9056937ba4500cb143933d2dc8 \
--chain 196 → token risk report
↓ if safe
2. okx-x402-payment (Workflow A above) → sign and pay用户:"这个x402支付安全吗?代币地址是0x4ae46a..."
1. okx-security 运行onchainos security token-scan \
--address 0x4ae46a509f6b1d9056937ba4500cb143933d2dc8 \
--chain 196 → 返回代币风险报告
↓ 如果安全
2. okx-x402-payment 执行工作流A → 签署并支付onchainos payment x402-pay \
--network <network> \
--amount <amount> \
--pay-to <address> \
--asset <address> \
[--from <address>] \
[--max-timeout-seconds <seconds>]| Param | Required | Default | Description |
|---|---|---|---|
| Yes | - | CAIP-2 network identifier (e.g., |
| Yes | - | Payment amount in minimal units (e.g., |
| Yes | - | Recipient address (from x402 |
| Yes | - | Token contract address (from x402 |
| No | selected account | Payer address; if omitted, uses the currently selected account |
| No | | Authorization validity window in seconds |
| Field | Type | Description |
|---|---|---|
| String | EIP-3009 secp256k1 signature (65 bytes, r+s+v, hex) returned by TEE backend |
| Object | Standard x402 EIP-3009 |
| String | Payer wallet address |
| String | Recipient address (= |
| String | Payment amount in minimal units (= |
| String | Authorization valid-after timestamp (Unix seconds) |
| String | Authorization valid-before timestamp (Unix seconds) |
| String | Random nonce (hex, 32 bytes), prevents replay attacks |
onchainos payment x402-pay \
--network <network> \
--amount <amount> \
--pay-to <address> \
--asset <address> \
[--from <address>] \
[--max-timeout-seconds <seconds>]| 参数 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|
| 是 | - | CAIP-2格式的网络标识符(例如X Layer为 |
| 是 | - | 支付金额,以最小单位计算(例如 |
| 是 | - | 收款地址(来自x402的 |
| 是 | - | 代币合约地址(来自x402的 |
| 否 | 当前选中的账户 | 付款地址;如果省略,则使用当前选中的账户 |
| 否 | | 授权的有效时长(秒) |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | TEE后端返回的EIP-3009 secp256k1签名(65字节,格式为r+s+v,十六进制) |
| 对象 | 标准x402 EIP-3009 |
| 字符串 | 付款钱包地址 |
| 字符串 | 收款地址(等于 |
| 字符串 | 支付金额,以最小单位计算(等于402负载中的 |
| 字符串 | 授权生效时间戳(Unix秒级) |
| 字符串 | 授权失效时间戳(Unix秒级) |
| 字符串 | 随机nonce(十六进制,32字节),用于防止重放攻击 |
HTTP 402
Body: "eyJ4NDAyVmVyc2lvbiI6MiwiYWNjZXB0cyI6W3s..." ← base64{
"x402Version": 2,
"accepts": [{
"network": "eip155:196",
"amount": "1000000",
"payTo": "0xAbC...",
"asset": "0x4ae46a509f6b1d9056937ba4500cb143933d2dc8",
"maxTimeoutSeconds": 300
}]
}onchainos payment x402-pay \
--network eip155:196 \
--amount 1000000 \
--pay-to 0xAbC... \
--asset 0x4ae46a509f6b1d9056937ba4500cb143933d2dc8 \
--max-timeout-seconds 300HTTP 402
Body: "eyJ4NDAyVmVyc2lvbiI6MiwiYWNjZXB0cyI6W3s..." ← base64编码{
"x402Version": 2,
"accepts": [{
"network": "eip155:196",
"amount": "1000000",
"payTo": "0xAbC...",
"asset": "0x4ae46a509f6b1d9056937ba4500cb143933d2dc8",
"maxTimeoutSeconds": 300
}]
}onchainos payment x402-pay \
--network eip155:196 \
--amount 1000000 \
--pay-to 0xAbC... \
--asset 0x4ae46a509f6b1d9056937ba4500cb143933d2dc8 \
--max-timeout-seconds 300
**Step 5** — assemble header and replay:undefined
**步骤5** —— 组装支付头并重试:undefined.envassetassettransferWithAuthorization.envassetassettransferWithAuthorizationaccepts[0]rawBody = response.body
decoded = JSON.parse(atob(rawBody))
option = decoded.accepts[0]networkamountmaxAmountRequiredpayToassetmaxTimeoutSecondsaccepts[0]rawBody = response.body
decoded = JSON.parse(atob(rawBody))
option = decoded.accepts[0]networkamountmaxAmountRequiredpayToassetmaxTimeoutSecondsTransferWithAuthorizationeth_signTypedData_v4| Field | Value |
|---|---|
| Payer address |
| |
| |
| |
| |
| Random 32 bytes (hex) |
name()version"1""2"chainIdverifyingContractoption.assetconst wallet = new ethers.Wallet('<PRIVATE_KEY>');
const signature = await wallet.signTypedData(domain, types, message);See EIP-3009 for the full typed data spec./domain.namevary per token (e.g. USDC usesversion/"USD Coin") — query the contract to confirm."2"
TransferWithAuthorizationeth_signTypedData_v4| 字段 | 值 |
|---|---|
| 付款地址 |
| |
| |
| |
| |
| 随机32字节十六进制值 |
name()version"1""2"chainIdverifyingContractoption.assetconst wallet = new ethers.Wallet('<PRIVATE_KEY>');
const signature = await wallet.signTypedData(domain, types, message);authorizationx402VersionpaymentPayload = { ...decoded, payload: { signature, authorization } }authorizationx402VersionpaymentPayload = { ...decoded, payload: { signature, authorization } }noncevalidBeforenow + maxTimeoutSecondsversion(from, to, value, nonce)noncevalidBefore当前时间 + maxTimeoutSecondsversion(from, to, value, nonce)onchainos wallet loginonchainos wallet login <email>eip155:<chainId>--amount1000000onchainos wallet loginonchainos wallet login <email>eip155:<chainId>--amount1000000--amount100000010^decimal1.00 USDG--amount100000010^decimal1.00 USDGonchainos payment x402-pay--networkeip155:<chainId>eip155:1eip155:8453eip155:196authorizationsignatureonchainos payment x402-pay--networkeip155:<chainId>eip155:1eip155:8453eip155:196authorizationsignature