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. 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).
4. 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" }
}
]
}