Multi-Launchpad Analytics Infrastructure
Complete guide to NAD.fun API and Monad WebSocket access. Real-time trading, WebSocket streams, and analytics for Monad blockchain
wss://monadtrenches.com/ws?api_key=YOUR_KEYExecute buy and sell transactions programmatically with full control over your wallet and transactions. You handle all RPC communication, transaction building, broadcasting, and receipt polling.
Essential information for automated trading systems
All NAD.fun tokens use 18 decimals (standard ERC20).
amount_mon_wei = amount_mon × 10¹⁸expected_tokens_wei is in wei, divide by 10¹⁸ for human-readableBefore selling tokens, you MUST approve the router contract to spend your tokens:
# Step 1: Check current allowance GET /api/router/approve/check/{token_address}/{owner_address} # Response: { "token_address": "0x9f22...", "owner_address": "0x6181...", "spender_address": "0x28F07093BEe80180080FCE4564A21487fDc4Ac46", // Router "current_allowance": "0", // In wei "needs_approval": true, "is_unlimited": false } # Step 2: Build approval transaction (if needed) POST /api/router/approve/build { "token_address": "0x9f22...", "owner_address": "0x6181...", "amount": "max" // or specific amount in wei } # Response: { "message": "Approval transaction built", "transaction": { "to": "0x9f22...", // Token contract "data": "0x095ea7b3...", // approve(spender, amount) "value": "0", "gas_estimate": "50000", "gas_price": "102000000000" }, "spender_address": "0x28F07093BEe80180080FCE4564A21487fDc4Ac46", "amount": "115792089237316195423570985008687907853269984665640564039457584007913129639935" }
Spender Address (Router): 0x28F07093BEe80180080FCE4564A21487fDc4Ac46
This address is intended to remain stable long-term. Any changes will be announced in advance.
Monad supports EIP-1559 gas pricing for better transaction ordering and refunds:
✅ Recommended: EIP-1559 (Better Performance)
⚠️ Legacy: gasPrice (Backward Compatible)
Common Fields:
gas_estimate is padded by 20% for safety. You can use it as-is.143 (Monad mainnet)| Limit Type | Limit | Notes |
|---|---|---|
| WebSocket Connections | 5 concurrent | Per API key |
Common Error Codes:
401 Unauthorized - Invalid or missing API key403 Forbidden - API key deactivated or expired429 Too Many Requests - WebSocket connection limit reached (max 5 concurrent per API key)400 Bad Request - Invalid parameters (check error field in response)404 Not Found - Token not indexed yet (see #5 below)500 Internal Server Error - Service temporarily unavailable (retry after a few seconds)New tokens may not be immediately available:
404 for brand new tokens404, wait a few seconds and retry. If errors persist, the token may not be tradeable yet.GET /api/router/allowlist/{token_address} to verify token is on NAD.fun404 errors gracefully in your code. Our service handles token indexing automatically—simply retry failed requests after a short delay.
from field: Pre-filled for convenience. Override this with your actual wallet addressnonce: Not included. Use GET /api/router/nonce/{address} to get latest noncegas_estimate: Already padded by 20% - safe to use as gas limitvalue (for buys): Total MON needed including our 0.5% fee. Send this exact amount.data: Pre-encoded calldata. Do not modify.{
"token_address": "0x9F22b83201C4Bb56aea8D20257594FD7A7AE7777",
"trade_amount_mon": 500, // Buy with 500 MON
"slippage_percent": 5.0, // 5% slippage protection
"user_address": "0xYourAddress..."
}
{
"success": true,
"message": "Buy transaction built successfully. Sign and broadcast this transaction.",
"transaction": {
"to": "0x9504b38d01186577d9ae100f4dd7c6e3c747f063", // Router contract
"from": "0x6181e387f1c162363fb5b91d62c318f4985bfcf2",
"data": "0x1622dbe4...", // Encoded calldata
"value": "502500000000000000000", // 502.5 MON (500 + 0.5% fee) in wei
"gas_estimate": "300000", // Recommended gas limit
"gas_price": "102000000000", // Legacy gas price (backward compatibility)
"max_fee_per_gas": "300000000000", // EIP-1559 max fee (recommended)
"max_priority_fee_per_gas": "100000000000", // EIP-1559 tip (100 gwei for snipes)
"base_fee_per_gas": "100000000000", // Base fee (reference)
"chain_id": "143" // Monad mainnet
},
"metadata": {
"token_address": "0x9f22b83201c4bb56aea8d20257594fd7a7ae7777",
"amount_mon": "500",
"amount_mon_wei": "500000000000000000000",
"expected_tokens_wei": "2183045795938762422810119", // ~2.18B tokens expected
"min_tokens_wei": "2073893506141824301669613", // Min tokens (with 5% slippage)
"fee_mon": "2.50", // 0.5% fee = 2.5 MON
"fee_wei": "2500000000000000000",
"slippage_percent": 5.0,
"timestamp": 1734715063
}
}
from web3 import Web3 import requests # Setup API_KEY = "your_api_key" PRIVATE_KEY = "0x..." USER_ADDRESS = "0x..." RPC_URL = "https://your-rpc.monad-mainnet.quiknode.pro/..." w3 = Web3(Web3.HTTPProvider(RPC_URL)) # Step 1: Get transaction data from API tx_data = requests.post( "https://monadtrenches.com/api/router/buy", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "token_address": "0x9F22b83201C4Bb56aea8D20257594FD7A7AE7777", "trade_amount_mon": 500, "slippage_percent": 5.0, "user_address": USER_ADDRESS } ).json() if not tx_data['success']: print(f"API Error: {tx_data.get('error', 'Unknown')}") exit() # Step 2: Sign and broadcast transaction # IMPORTANT: This example shows the conceptual flow only. # # You will need to: # 1. Get nonce from your RPC provider # 2. Build transaction object using fields from API response # 3. Sign transaction with your private key # 4. Broadcast to your RPC provider # 5. Wait for transaction receipt # # For production implementations, use Simple Mode API or contact us for integration support.
{
"token_address": "0x9F22b83201C4Bb56aea8D20257594FD7A7AE7777",
"amount_in_tokens": "1000000000000000000000", // Amount in wei (1000 tokens)
"slippage_percent": 5.0,
"user_address": "0xYourAddress..."
}
{
"success": true,
"message": "Sell transaction built successfully. Sign and broadcast this transaction.",
"transaction": {
"to": "0x9504b38d01186577d9ae100f4dd7c6e3c747f063",
"from": "0x6181e387f1c162363fb5b91d62c318f4985bfcf2",
"data": "0x6d1b229d...",
"value": "0", // No MON sent for sell
"gas_estimate": "300000",
"gas_price": "102000000000", // Legacy gas price (backward compatibility)
"max_fee_per_gas": "300000000000", // EIP-1559 max fee (recommended)
"max_priority_fee_per_gas": "100000000000", // EIP-1559 tip (100 gwei for snipes)
"base_fee_per_gas": "100000000000", // Base fee (reference)
"chain_id": "143"
},
"metadata": {
"token_address": "0x9f22b83201c4bb56aea8d20257594fd7a7ae7777",
"amount_in_tokens": "1000",
"amount_in_wei": "1000000000000000000000",
"expected_mon_wei": "245000000000000000000", // ~245 MON expected
"min_mon_wei": "232750000000000000000", // Min MON (with 5% slippage)
"expected_mon_after_fee": "243.78", // After 0.5% fee
"fee_mon": "1.22",
"slippage_percent": 5.0,
"timestamp": 1734715123
}
}
/api/router/approve/check and /api/router/approve/build endpoints.
Get buy quote without building transaction
{
"token_address": "0x9F22b83201C4Bb56aea8D20257594FD7A7AE7777",
"amount_mon": 500,
"slippage_percent": 5.0
}
{
"success": true,
"quote": {
"expected_tokens": "2183045795.938762422810119", // Human-readable (billions)
"expected_tokens_wei": "2183045795938762422810119",
"min_tokens": "2073893506.141824301669613",
"min_tokens_wei": "2073893506141824301669613",
"price_per_token_mon": "0.000000229",
"slippage_percent": 5.0,
"fee_mon": "2.50",
"total_cost_mon": "502.50" // Including 0.5% fee
}
}
Get sell quote without building transaction
{
"token_address": "0x9F22b83201C4Bb56aea8D20257594FD7A7AE7777",
"amount_tokens": "1000000000000000000000", // Wei (1000 tokens)
"slippage_percent": 5.0
}
{
"success": true,
"quote": {
"expected_mon": "245.00",
"expected_mon_wei": "245000000000000000000",
"min_mon": "232.75",
"min_mon_wei": "232750000000000000000",
"expected_mon_after_fee": "243.78", // After 0.5% fee
"fee_mon": "1.22",
"slippage_percent": 5.0
}
}
// Invalid token { "success": false, "error": "Token does not exist or has not been indexed yet" } // Brand new token (< 1 second old) { "success": false, "error": "Unable to calculate slippage protection for this token. This can happen for brand new tokens (< 1 second old) or during RPC issues. Please retry in 1-2 seconds." } // Invalid address format { "success": false, "error": "Invalid token address format" } // Missing required field { "success": false, "error": "Missing required field: trade_amount_mon" }
Advanced Mode returns transaction data that you must sign and broadcast yourself. You are responsible for:
💡 Recommendation: For production bots, use Simple Mode API to reduce complexity and ensure reliability.
Beginner-friendly buy and sell endpoints that automatically handle nonces, gas prices, and transaction assembly. Perfect for quick integrations!
Purchase tokens using MON. The API handles nonce and gas price lookup automatically.
POST /api/router/simple/buy Headers: X-API-Key: your_api_key Request Body: { "wallet_address": "0xYourWalletAddress...", "token_address": "0x9F22b83201C4Bb56aea8D20257594FD7A7AE7777", "amount_mon": 10.5, // Amount in MON (human-readable) "slippage_bps": 50 // Optional, defaults to 50 (0.5%) } Response: { "success": true, "message": "Transaction ready! Sign and broadcast this transaction with your wallet.", "transaction": { "to": "0x28F07093BEe80180080FCE4564A21487fDc4Ac46", // Router address "from": "0xYourWalletAddress...", "data": "0x...", // Transaction calldata "value": "10500000000000000000", // Amount in wei "gas": "180000", // Gas limit (padded 20%) "gas_price": "102000000000", // Gas price in wei (from RPC) "nonce": 42, // Nonce (from RPC) "chain_id": 143 // Monad mainnet }, "metadata": { "action": "buy", "amount_mon": "10.50000000", "fee_bps": 50 } }
Sell tokens back to MON. Important: You must approve the router to spend your tokens first (see Approve Flow below).
POST /api/router/simple/sell Headers: X-API-Key: your_api_key Request Body: { "wallet_address": "0xYourWalletAddress...", "token_address": "0x9F22b83201C4Bb56aea8D20257594FD7A7AE7777", "amount_tokens": "1000000000000000000", // Amount in wei (18 decimals) "slippage_bps": 50 // Optional, defaults to 50 (0.5%) } Response: { "success": true, "message": "Transaction ready! Make sure you've approved the router to spend your tokens first (see /approve endpoint).", "transaction": { "to": "0x28F07093BEe80180080FCE4564A21487fDc4Ac46", // Router address "from": "0xYourWalletAddress...", "data": "0x...", // Transaction calldata "value": "0", "gas": "200000", // Gas limit (padded 20%) "gas_price": "102000000000", // Gas price in wei (from RPC) "nonce": 43, // Nonce (from RPC) "chain_id": 143 // Monad mainnet }, "metadata": { "action": "sell", "amount_tokens": "1000000000000000000", "fee_bps": 50 } }
Before selling tokens, you must approve the router contract to spend your tokens. Use the same approve endpoints as in Buy/Sell API:
# Step 1: Check current allowance GET /api/router/approve/check/{token_address}/{owner_address} # Step 2: Build approval transaction (if needed) POST /api/router/approve/build { "token_address": "0x9f22...", "owner_address": "0x6181...", "amount": "max" // or specific amount in wei } # Router Address (Spender): 0x28F07093BEe80180080FCE4564A21487fDc4Ac46
Real-time Monad WebSocket stream of all token creations and trades on NAD.fun. Connect to our NAD.fun WebSocket for live trading data on the Monad blockchain.
wss://monadtrenches.com/ws?api_key=YOUR_API_KEY
{
"type": "token",
"trade_type": "create",
"token_address": "0x9F22b83201C4Bb56aea8D20257594FD7A7AE7777",
"token_symbol": "SYMBOL",
"token_name": "Token Name",
"amount_mon": 26795.57, // Creator's initial liquidity
"market_cap_usd": 3847.82, // Initial market cap in USD
"price_mon": 0.000003848, // Initial price per token
"trader": "0xCreatorAddress...", // Token creator's wallet
"creator_token_count": 5, // Number of tokens created by this creator
"tx_hash": "0x...",
"timestamp": "2025-12-21T10:30:45.123Z"
}
{
"type": "trade",
"trade_type": "buy", // or "sell"
"token_address": "0x9F22b83201C4Bb56aea8D20257594FD7A7AE7777",
"token_symbol": "SYMBOL",
"token_name": "Token Name",
"amount_mon": 30.0, // Trade size in MON
"market_cap_usd": 4278.02, // Market cap after trade
"price_mon": 0.000004278, // Price per token after trade
"trader": "0xTraderAddress...", // Wallet who made the trade
"tx_hash": "0x...",
"timestamp": "2025-12-21T10:31:12.456Z"
}
import websocket import json API_KEY = "your_api_key" WS_URL = f"wss://monadtrenches.com/ws?api_key={API_KEY}" def on_message(ws, message): data = json.loads(message) if data['type'] == 'token': print(f"🎉 NEW TOKEN: {data['token_symbol']}") elif data['type'] == 'trade': print(f"📊 {data['trade_type'].upper()}: {data['amount_mon']} MON") ws = websocket.WebSocketApp(WS_URL, on_message=on_message) ws.run_forever(ping_interval=30)
ping_interval=30.