My Agent buys services#

Buyers don't need any complex setup — just install the Onchain OS Skill on your AI Agent, and it can initiate dialogue with Sellers and sign payments autonomously, with no human intervention throughout.

The Skill automatically handles:

  • Payment request detection: Auto-detects HTTP 402 responses or payment URLs in messaging channels
  • Amount verification: Checks whether the amount is reasonable and the recipient is trustworthy
  • Signing authorization: Invokes Agentic Wallet to sign (one-time payment signs per call; Batch payment uses a pre-authorized Session Key)
  • Status tracking: Monitors payment status and retrieves the Receipt

Prerequisites#

  • AI Agent: An AI tool that supports Skills, e.g. Claude Desktop
  • Agentic Wallet: Created via Onchain OS Skill (email login, no seed phrase required); the private key is generated and kept inside a TEE. See Agentic Wallet installation for setup steps
  • On-chain balance: Sufficient USDG / USD₮0 on X Layer

Setup#

Send the following prompt to your AI to install Onchain OS Skills and configure Agentic Wallet for your Agent:

text
Run npx skills add okx/onchainos-skills to install Onchain OS skills
Note: please install into the skill directory of the current Agent
Also, help me install the latest CLI based on this document: https://github.com/okx/onchainos-skills

Verification#

The following uses "weather lookup" as an example; please test against the actual online x402 paid service you need to call.

Login:

onchainos wallet login

Request the Seller's service/resource:

// Not a live service, for reference only
Access this service: http://localhost:4021/weather

Receiving the payment info means the request succeeded:

The service returned an x402 payment-required response (HTTP 402). Contents:

  - x402 version: 2
  - Resource: /weather — get current weather data for any location, returns application/json
  - Payment methods (two schemes):
    - exact — one-time payment
    - aggr_deferred — post-pay
  - Network: eip155:196 (OKX X Layer)
  - Token: USD₮0 (0x779ded0c9e1022225f8e0630b35a9b54be713736)
  - Amount: 1000 (smallest unit)
  - Recipient: 0xb483abdb92f8061e9a3a082a4aaaa6b88c381308
  - Timeout: 600,000 seconds

Confirm the payment, sign the transaction data, and replay the request to the Seller:

bash
PAYMENT_PAYLOAD=$(python3 -c "
      import json, base64
      payload = {
          'x402Version': 2,
          'resource': {'url': '/weather', 'description': 'Get current weather data for any location', 'mimeType':
      'application/json'},
          'accepted': {'scheme': 'exact', 'network': 'eip155:196', 'asset':
      '0x779ded0...4be713736', 'amount': '1000', 'payTo':
      '0xb483abd....aa6b88c381308', 'maxTimeoutSeconds': 600000, 'extra': {'name': 'USD₮0',
      'version': '1'}},
          'payload': {
              'signature': '0x3d1907a6ba9f592c...35868ea11b',
              'authorization': {'from': '0xbda9fde...99763', 'nonce':
              '0x20862cc...06e48', 'to':
              '0xb483abd...81308', 'validAfter': '0', 'validBefore': '1775837508', 'value': '1000'}
          }
      }
      print(base64.b64encode(json.dumps(payload, separators=(',', ':')).encode()).decode())
      ")
curl -s -D - http://localhost:4021/weather -H "PAYMENT-SIGNATURE: $PAYMENT_PAYLOAD"

You receive the resource returned by the Seller:

⏺ Payment successful! Weather data returned:

  {"report": {"temperature": 70, "weather": "sunny"}}

  - Temperature: 70°F
  - Weather: Sunny ☀️

FAQ#

Is it safe for the Agent to sign automatically?

Safe. The Agentic Wallet's private key is held inside a TEE (Trusted Execution Environment) and cannot be exported; the Skill validates amount and recipient before invoking the signature (see above); every signature includes nonce and validity window, so it cannot be replayed. For batch payment, a Session Key signature alone cannot go on-chain — it must be re-signed inside the TEE and aggregated, so even if intercepted it cannot directly trigger a charge.

Which wallets are supported?

One-time payment supports any EIP-3009-compatible EVM wallet. Batch payment requires Agentic Wallet.

What if payment fails?

When payment fails (e.g., KYT check fails, insufficient balance), the Seller does not deliver the service and the Buyer is not charged. The specific error code is returned to the Agent, and the reason is visible in the logs.

Can I use it without Agentic Wallet?

Yes, but features will be limited. Any EIP-3009 wallet can complete one-time payment; batch payment requires Agentic Wallet.

Innehållsförteckning