命令 Meirei
meirei命令
X Layer Mandate Agent
DEVELOPER & PROTOCOL GUIDE

Meirei Documentation

Comprehensive guide to conversational mandates, the cryptographic 2FA authorization barrier, and on-chain execution on X Layer.

1. Introduction

Meirei (命令) is an autonomous, AI-native investment mandate agent built for X Layer (EVM Chain 196). It accepts natural-language directives from everyday chat platforms (WhatsApp, Telegram, Web Terminal) and calculates minimal-slippage rebalancing plans across tokenized equities.

Unlike conventional bots that demand full custodial control over user funds, Meirei strictly enforces an isolated computation model: preview quotes are generated freely, but on-chain settlement strictly requires a cryptographically verified 2FA OTP challenge.

2. Conversational Syntax Examples

Querying Spot Prices:

"What is the price of NVDAx?" or "Price of AAPLx"

Checking Live Wallet Holdings:

"Check balance" or "My portfolio"

Direct Stock Buy / Sell Orders:

"Buy 250 USDG of NVDAx" or "Sell 1 AAPLx" or "Exit TSLAx"

Multi-Asset Rebalancing Mandate:

"60% mag7, 20% USDG, max 8% single asset"

3. Allowlisted xStocks & Stablecoins

20 Equities + 2 Cash · Chain 196

Meirei strictly restricts trade execution to verified tokenized stocks and settlement stablecoins deployed on OKX X Layer (Chain ID 196). Non-allowlisted assets are rejected at intent parsing before quote generation:

SymbolNameDecimalsContract Address
AAPLxApple xStock180x9d275685dc284c8eb1c79f6aba7a63dc75ec890a
MSFTxMicrosoft xStock180x5621737f42dae558b81269fcb9e9e70c19aa6b35
NVDAxNVIDIA xStock180xc845b2894dbddd03858fd2d643b4ef725fe0849d
GOOGLxAlphabet xStock180xe92f673ca36c5e2efd2de7628f815f84807e803f
AMZNxAmazon.com xStock180x3557ba345b01efa20a1bddc61f573bfd87195081
METAxMeta xStock180x96702be57cd9777f835117a809c7124fe4ec989a
TSLAxTesla xStock180x8ad3c73f833d3f9a523ab01476625f269aeb7cf0
COINxCoinbase xStock180x1d5338302f3dd78f7aa9580bc53c4d445ec6ba25
SPYxS&P 500 ETF xStock180x42f7461c360980ff62c3e1db6aa5229c15d48721
QQQxInvesco QQQ xStock180x71c50b69107cc6ea56795f54070a7f1a8c9e5033
AMDxAMD xStock180x89e13b8602b9ff9b867cfae4f8d55d71fa8430e2
CRWDxCrowdStrike xStock180x3a4b69c5819772bf258b3506c74ad64a787965df
MSTRxMicroStrategy xStock180x7b58c9320b92f72bc97e79391ab1a457492c13fa
TSMxTaiwan Semiconductor180x2a946b5d92e8c614efabcf6e1598da4c4e7926b1
AVGOxBroadcom xStock180x6f31b87a912852643a6d71ec9103cba7e48df528
INTCxIntel Corporation180x18c4b726ae0d4f5b2f67ea9a36729a571c8901eb
MUxMicron Technology180x91d3e74a812b704c356da7fe63098514ef1a52fc
MRVLxMarvell Technology180x48e1c67d301ba593fa88d5e4905cf71286b24a35
IWMxRussell 2000 ETF180x3c71a54b9d0263f1ec78b4a8e0380c5984cf7632
DELLxDell Technologies180x83e5fa62d908e234bc5719ab4c5770df594e9b7a
USDGGlobal Dollar (Settlement)60x4ae46a509f6b1d9056937ba4500cb143933d2dc8
USDCUSD Coin (Secondary)60xb6ceceab302e2e4948951ee7843fc24e92933061

4. 2FA Cryptographic Authorization Barrier

Every trade confirmation requires passing an ephemeral challenge. The workflow operates as follows:

  1. Preview Request: Client receives price quote and price impact estimate.
  2. Challenge Minting: Upon confirming order, server emits type: "otp_required" and creates a 6-digit challenge in memory (5-minute TTL, max 3 attempts).
  3. Verification: Client submits code to /api/auth/otp. When valid, a signed authorization token is issued.
  4. Atomic Broadcast: Client sends authorization token with confirm request. Execution runs via OKX DEX Aggregator on X Layer (chain 196).

5. HMAC-SHA256 Token Validation

Authorization tokens granted by /api/auth/otp use HMAC-SHA256 signatures to prevent replay and forgery. Each token is strictly bound to the specific wallet address, timestamp, and challenge ID:

// Token Structure

token = base64Url(payload) + "." + hex(hmacSha256(payload, secret))

// Invariants & Security Checks

• Constant-time timingSafeEqual comparison prevents timing side-channels.

• Strict 5-minute validity window (expired tokens rejected with HTTP 401).

• Challenge IDs are single-use and invalidated immediately upon successful redemption.

6. API Reference

POST /api/chat

Process natural language prompts, quotes, or trade executions.

// Request body
{
  "message": "Buy 250 USDG of NVDAx",
  "walletAddress": "0x7f17d6224e7d48606598732c3f511412b5c1e922",
  "confirm": true,
  "otpToken": "<HMAC_SIGNED_TOKEN>" // Optional for preview, required for execution
}

POST /api/auth/otp

Generate and verify 6-digit 2FA authorization challenges.

// Step 1: Request Challenge
{ "action": "request", "identifier": "0x7f17..." }

// Response: { "ok": true, "challengeId": "otp_...", "expiresAt": 1789633747479 }

// Step 2: Verify Code
{ "action": "verify", "challengeId": "otp_...", "code": "313987" }

// Response: { "ok": true, "otpToken": "eyJhbGci..." }

GET /api/news

Fetch live market catalysts and AI impact analyses for tokenized equities.

// Response
{
  "catalysts": [
    {
      "id": "cat_1",
      "ticker": "NVDAx",
      "headline": "Blackwell Architecture Production Ramps...",
      "impact": "Bullish",
      "marketEffectAnalysis": "Strong spot demand catalyst on X Layer...",
      "suggestedAction": { "label": "Accumulate NVDAx", "tradePrompt": "Buy 250 USDG of NVDAx" }
    }
  ]
}