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 196Meirei 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:
| Symbol | Name | Decimals | Contract Address |
|---|---|---|---|
| AAPLx | Apple xStock | 18 | 0x9d275685dc284c8eb1c79f6aba7a63dc75ec890a |
| MSFTx | Microsoft xStock | 18 | 0x5621737f42dae558b81269fcb9e9e70c19aa6b35 |
| NVDAx | NVIDIA xStock | 18 | 0xc845b2894dbddd03858fd2d643b4ef725fe0849d |
| GOOGLx | Alphabet xStock | 18 | 0xe92f673ca36c5e2efd2de7628f815f84807e803f |
| AMZNx | Amazon.com xStock | 18 | 0x3557ba345b01efa20a1bddc61f573bfd87195081 |
| METAx | Meta xStock | 18 | 0x96702be57cd9777f835117a809c7124fe4ec989a |
| TSLAx | Tesla xStock | 18 | 0x8ad3c73f833d3f9a523ab01476625f269aeb7cf0 |
| COINx | Coinbase xStock | 18 | 0x1d5338302f3dd78f7aa9580bc53c4d445ec6ba25 |
| SPYx | S&P 500 ETF xStock | 18 | 0x42f7461c360980ff62c3e1db6aa5229c15d48721 |
| QQQx | Invesco QQQ xStock | 18 | 0x71c50b69107cc6ea56795f54070a7f1a8c9e5033 |
| AMDx | AMD xStock | 18 | 0x89e13b8602b9ff9b867cfae4f8d55d71fa8430e2 |
| CRWDx | CrowdStrike xStock | 18 | 0x3a4b69c5819772bf258b3506c74ad64a787965df |
| MSTRx | MicroStrategy xStock | 18 | 0x7b58c9320b92f72bc97e79391ab1a457492c13fa |
| TSMx | Taiwan Semiconductor | 18 | 0x2a946b5d92e8c614efabcf6e1598da4c4e7926b1 |
| AVGOx | Broadcom xStock | 18 | 0x6f31b87a912852643a6d71ec9103cba7e48df528 |
| INTCx | Intel Corporation | 18 | 0x18c4b726ae0d4f5b2f67ea9a36729a571c8901eb |
| MUx | Micron Technology | 18 | 0x91d3e74a812b704c356da7fe63098514ef1a52fc |
| MRVLx | Marvell Technology | 18 | 0x48e1c67d301ba593fa88d5e4905cf71286b24a35 |
| IWMx | Russell 2000 ETF | 18 | 0x3c71a54b9d0263f1ec78b4a8e0380c5984cf7632 |
| DELLx | Dell Technologies | 18 | 0x83e5fa62d908e234bc5719ab4c5770df594e9b7a |
| USDG | Global Dollar (Settlement) | 6 | 0x4ae46a509f6b1d9056937ba4500cb143933d2dc8 |
| USDC | USD Coin (Secondary) | 6 | 0xb6ceceab302e2e4948951ee7843fc24e92933061 |
4. 2FA Cryptographic Authorization Barrier
Every trade confirmation requires passing an ephemeral challenge. The workflow operates as follows:
- Preview Request: Client receives price quote and price impact estimate.
- Challenge Minting: Upon confirming order, server emits
type: "otp_required"and creates a 6-digit challenge in memory (5-minute TTL, max 3 attempts). - Verification: Client submits code to
/api/auth/otp. When valid, a signed authorization token is issued. - 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" }
}
]
}