🧠 AI-Powered Onchain Agent — Execute Trades, Bridges, Intelligence & DeFi via Natural Language
- Overview
- Architecture
- Tech Stack
- AI Models & Orchestration
- Blockchain Tools
- x402 Crypto Payment Protocol
- Security
- Project Structure
- Development
- API Documentation
- Deployment
- License
Barzakh AI is a full-stack AI-powered onchain agent that combines real-time blockchain data with multi-model AI orchestration. Built as a Turborepo monorepo with pnpm workspaces, it enables users to execute cross-chain swaps, bridge assets, analyze wallets, and interact with DeFi protocols — all through natural language conversation.
| Feature | Description |
|---|---|
| AI Onchain Agent | Natural language → real onchain transactions (swaps, bridges, trades) |
| Autonomous Token Launches | 4-step end-to-end launch on Four.meme with automated logo resolution and tax config |
| Scheduled Agent Workflows | Background monitoring for subscriptions and automated task execution via api/cron |
| Cross-Chain Execution | 85+ chains via Relay Protocol (BSC, Base, Ethereum, Arbitrum, Solana, etc.) |
| Arkham Intelligence | 43 tools for whale tracking, entity investigation, fund flow analysis across 20+ chains |
| Decentralized Storage | Upload text, images, PDFs, videos to Shelby Protocol (Aptos Testnet) with optional NFT minting |
| Sui & Walrus | 19 tools for SUI portfolio, whale activity, BlockVision, Walrus storage, agent wallets & DeFi strategies |
| Azure Multi-Model AI | GPT-4o/4.1/5.x, Grok, Kimi, DeepSeek, and BZKH model-router deployments with intelligent routing |
| Smart Chain Inference | Auto-detects which chain a token belongs to — no need to specify |
| 120+ Blockchain Tools | Chain-specific analyzers for Sui, Monad, Cronos, Mantle, EVM, Aptos, Solana, Flow, SEI, Creditcoin |
| Enterprise Security | 2FA (TOTP), wallet signature auth, prompt injection defense, Cloudflare API Shield |
| Crypto Payments | x402 protocol with EIP-3009/EIP-712 USDC payments on Base |
| Guest Access | Anonymous trial with device fingerprinting — 5 free messages/day without sign-up |
Turborepo Monorepo with pnpm workspaces for optimal DX and build performance
┌──────────────────────────────────────────────────────────────────────────────────────┐
│ EDGE LAYER │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Cloudflare │ │ API Shield │ │ Rate Limiter │ │ R2 Storage │ │
│ │ WAF + DDoS │ │ OpenAPI 3.0 Spec│ │ Token Bucket │ │ Object Store │ │
│ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │
└───────────┼────────────────────┼────────────────────┼────────────────────┼───────────┘
│ │ │ │
└────────────────────┴────────────────────┴────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────────────────────────────────┐
│ APPLICATION LAYER (Vercel) │
│ ┌─────────────────────────────────────────────────────────────────────────────────┐ │
│ │ Next.js 16.2 (App Router + RSC) │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │ │
│ │ │ React 19 │ │ Server │ │ API Routes │ │ Middleware Chain │ │ │
│ │ │ RSC │ │ Components │ │ (Edge) │ │ Auth → Rate → Validate │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────────────┐
│ CORE SERVICES │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Chat Engine │ │ AI Orchestrator │ │ Tool Executor │ │ Stream Processor│ │
│ │ Vercel AI SDK │ │ Multi-Model │ │ 100+ Tools │ │ SSE/Chunks │ │
│ │ v4.3.19 │ │ Intent Router │ │ 12+ Chains │ │ Transfer-Enc │ │
│ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │
└───────────┼────────────────────┼────────────────────┼────────────────────┼──────────┘
│ │ │ │
└────────────────────┴────────────────────┴────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────────────┐
│ AI LAYER │
│ ┌───────────────────────────────────────────────────────────────────────────────┐ │
│ │ LLM Provider Abstraction │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────┐ │ │
│ │ │ Azure │ │ Model │ │ OpenAI │ │ xAI │ │ Moonshot/Kimi │ │
│ │ │ Foundry │ │ Router │ │ GPT-4/5 │ │ Grok │ │ DeepSeek/Zhipu │ │ │
│ │ │Endpoint │ │ BZKH v1 │ │ GPT-Image│ │ 4.x/4.20 │ │ via Azure │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────────────┘ │ │
│ └───────────────────────────────────────────────────────────────────────────────┘ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────────────────┐ │
│ │ Prompt Engineer │ │ Input Sanitizer │ │ Response Streamer │ │
│ │ 100KB+ System │ │ Injection Guard │ │ Token-by-Token SSE Output │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────────────────────────────────┐
│ BLOCKCHAIN TOOLS LAYER │
│ ┌─────────────────────────────────────────────────────────────────────────────────┐ │
│ │ Chain-Specific Tool Modules │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────┐ │ │
│ │ │ Cronos │ │ EVM │ │ Aptos │ │ Flow │ │ SEI │ │ │
│ │ │ VVS DEX │ │ Ethereum │ │ Move │ │ Cadence │ │ Cosmos SDK │ │ │
│ │ │ Explorer │ │ Polygon │ │ Names │ │ NFTs │ │ IBC Protocol │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────────────┘ │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────┐ │ │
│ │ │ Solana │ │ Zeta │ │ Monad │ │ Walrus │ │ Mantle L2 │ │ │
│ │ │ RPC │ │ ZetaVM │ │ Mainnet │ │ Storage │ │ MNT Balance │ │ │
│ │ │ DeFi │ │ Testnet │ │ nad.fun │ │ Protocol │ │ Portfolio │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────────────────────────────────────────┐ │
│ │ Intelligence & Utility Tool Modules │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────┐ │ │
│ │ │ Arkham │ │DeFi Llama│ │Web Search│ │ News │ │ X/Twitter │ │ │
│ │ │ Intel │ │ TVL │ │ Tavily │ │ Search │ │ Search │ │ │
│ │ │ 43 Tools │ │ API │ │ Search │ │ API │ │ API │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────────────┘ │ │
│ │ ┌──────────┐ ┌──────────┐ │ │
│ │ │Creditcoin│ │ Image Gen│ │ │
│ │ │Blockscout│ │Azure GPT │ │ │
│ │ │ API │ │Image 2 │ │ │
│ │ └──────────┘ └──────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────────────────────────┐
│ DATA LAYER │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ PostgreSQL │ │ Cloudflare R2 │ │ Drizzle ORM │ │ Connection │ │
│ │ (Neon/Turso) │ │ Object Storage │ │ Type-Safe │ │ Pooling │ │
│ │ v0.45.2 │ │ File Upload │ │ Migrations │ │ Prepared │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
└──────────────────────────────────────────────────────────────────────────────────────┘
sequenceDiagram
autonumber
participant Client as 🖥️ Client
participant CF as 🛡️ Cloudflare Edge
participant MW as ⚙️ Middleware
participant Auth as 🔐 NextAuth
participant API as 📡 API Route
participant Orchestrator as 🧠 AI Orchestrator
participant LLM as 🤖 LLM Provider
participant Tools as 🔧 Tool Executor
participant RPC as ⛓️ Blockchain RPC
participant DB as 💾 PostgreSQL
Client->>CF: POST /api/chat (TLS 1.3)
CF->>CF: WAF Rules + Bot Detection
CF->>CF: API Shield Schema Validation
CF->>CF: Rate Limit Check (Token Bucket)
CF->>MW: Forward Request
MW->>Auth: Validate Session Cookie
Auth->>DB: Verify Session + Get User
DB-->>Auth: User Context + Subscription Tier
Auth-->>MW: Authenticated User
Note over MW: x402 Subscription Expiry Check
MW->>DB: Check x402PeriodEnd
MW->>API: Process Chat Request
API->>Orchestrator: Initialize Chat Stream
Orchestrator->>Orchestrator: Build Context (History + System Prompt)
Orchestrator->>Orchestrator: Sanitize Input (Injection Defense)
Orchestrator->>LLM: Stream Completion Request
loop Agentic Tool Loop
LLM-->>Orchestrator: Tool Call Request
Orchestrator->>Tools: Execute Tool
Tools->>RPC: Query Blockchain
RPC-->>Tools: On-Chain Data
Tools-->>Orchestrator: Structured Result
Orchestrator->>LLM: Continue with Tool Result
end
LLM-->>Orchestrator: Final Response Tokens
Orchestrator-->>API: SSE Stream
API-->>Client: Transfer-Encoding: chunked
API->>DB: Persist Chat Message (async)
| Layer | Technology | Version | Purpose |
|---|---|---|---|
| Runtime | Node.js | 18+ | Server runtime |
| Package Manager | pnpm | 10.11.0 | Fast, disk-efficient |
| Monorepo | Turborepo | 2.8.0 | Build orchestration |
| Framework | Next.js | 16.2.6 | Full-stack React framework |
| UI Library | React | 19.2.0 | UI components (RSC enabled) |
| Language | TypeScript | 5.6.3 | Type safety |
| Category | Technologies |
|---|---|
| Styling | TailwindCSS 3.4, CSS Variables, Tailwind Merge |
| Components | Radix UI primitives, Lucide React icons, Framer Motion |
| State | React hooks, useSWR, TanStack Query 5.90 |
| Forms | Zod 3.25 validation, React Hook Form patterns |
| Editor | Prosemirror, CodeMirror 6 |
| Animations | Framer Motion 11.3, Lottie React |
| Category | Technologies |
|---|---|
| API | Next.js API Routes (Edge + Node), Vercel Functions |
| AI SDK | Vercel AI SDK 4.3.19 |
| Database | PostgreSQL 15, Drizzle ORM 0.45.2 |
| Auth | NextAuth.js 5.0.0-beta.30 |
| Payments | Stripe 18.5, x402 Protocol (EIP-3009) |
| Nodemailer 6.10 |
| Category | Technologies |
|---|---|
| Wallet | Wagmi 2.19, Dynamic SDK 4.x |
| Ethereum | Viem 2.41, ethers.js v6 |
| Chains | Monad, Cronos, Mantle, Ethereum, Polygon, Aptos, Solana, Flow, SEI, Creditcoin + 85 via Relay |
| Protocols | EIP-3009 (TransferWithAuthorization), EIP-712, EIP-191 |
| Category | Technologies |
|---|---|
| Hosting | Vercel (Frontend), Cloudflare (Edge) |
| Database | Neon PostgreSQL (Serverless) |
| Storage | Cloudflare R2 (S3-compatible) |
| CDN | Vercel Edge Network, Cloudflare |
| Monitoring | Sentry 9.11, Vercel Analytics |
| Provider | Model IDs | Strength |
|---|---|---|
| Azure Model Router | model-router / BZKH v1 |
Auto-selects the best Azure-hosted model for the task |
| OpenAI via Azure | gpt-4o-mini, gpt-4o, gpt-4.1, gpt-5.3-chat, gpt-5.3-codex, gpt-5.4*, gpt-5.5 |
General chat, reasoning, coding, and premium intelligence |
| xAI via Azure | grok-4-1-fast-*, grok-4-20-*, grok-4.3 |
Fast and reasoning variants for real-time answers |
| Moonshot via Azure | kimi-k2.5, kimi-k2.6 |
Long-context knowledge-heavy workflows |
| DeepSeek via Azure | deepseek-v3.2, deepseek-v4-flash |
High-throughput reasoning and responsive generation |
The imagine route now uses OpenRouter GPT-Image-2 directly through the OpenAI-compatible /images/generations and /images/edits endpoints. Legacy third-party image generation has been removed from the active image path.
| Model ID | Display Name | Provider | Description |
|---|---|---|---|
gpt-image-2 |
GPT-Image-2 | OpenRouter | High-fidelity PNG image generation, multi-image batches, and image editing |
| Capability | Implementation |
|---|---|
| Prompt-to-image | createImage posts JSON to ${OPENROUTER_ENDPOINT}/images/generations |
| Image editing | input_images are fetched/proxied, converted to multipart image[], then sent to /images/edits |
| Persistence | Base64/data URLs from Azure are uploaded through /api/persist-image into Cloudflare R2 |
| Batch size | numberOfImages supports 1-10 images in a single Azure request |
| Resolution | size supports GPT-Image-2-valid WIDTHxHEIGHT multiples of 16, default 1024x1024 |
| Quality | `OPENROUTER_IMAGE_QUALITY=low |
| Streaming | Optional OPENROUTER_IMAGE_STREAM=true with OPENROUTER_IMAGE_PARTIAL_IMAGES=0..3 |
flowchart LR
subgraph Input["📥 User Input"]
Query["User Query"]
Context["Chat Context"]
ChainMention["Chain Mentions"]
end
subgraph Classifier["🔀 Intent Classifier"]
Pattern["Pattern Matching"]
ChainContext["Chain Context Extraction"]
LLMFallback["LLM Fallback"]
end
subgraph Routes["🎯 Route Categories"]
Cronos["Cronos Tools"]
EVM["EVM Generic"]
Aptos["Aptos/Move"]
Solana["Solana DeFi"]
SEI["SEI Cosmos"]
General["General Chat"]
end
Query --> Pattern
Context --> ChainContext
ChainMention --> ChainContext
Pattern --> |"cronos, cro, vvs"| Cronos
Pattern --> |"eth, erc, ens"| EVM
Pattern --> |"apt, move"| Aptos
Pattern --> |"sol, spl"| Solana
Pattern --> |"sei, ibc"| SEI
ChainContext --> |"Preserve context"| Routes
LLMFallback --> |"Ambiguous"| General
Barzakh AI features a dual-mode execution engine that allows users to choose between granular control and full autonomy.
| Mode | Trigger | Signing Method | Best For |
|---|---|---|---|
| Manual | Default | User signs each transaction via Dynamic SDK / Extension Wallet | New users, large trades, high-stakes DeFi |
| Autonomous | Settings Enabled | Agent signs instantly using a backend-delegated MPC wallet | High-frequency trading, auto-launching, background tasks |
When Agent Automation is enabled in settings, the system sets up a dedicated embedded wallet powered by the Dynamic SDK.
- Delegated Access: The agent is granted permission to sign specific types of transactions within user-defined limits.
- Backend Signing: Transactions are prepared by the
agent-executor.tsand signed using thegetAgentPrivateKeyutility, allowing for "Zero-Click" execution. - Instant Response: Perfect for multi-step flows like Four.meme launches where multiple transactions (Logo Storage + Metadata + Launch) are executed in a single natural language session.
Barzakh AI uses deferred background workers for non-blocking tasks, located in api/cron:
- Protocol Monitoring: Continuously checks for cross-chain bridge completions to update chat UI state.
- Subscription Engine: Automatically monitors and manages user tiers and billing cycles.
| Chain | Tools | Key Capabilities |
|---|---|---|
| Arkham Intelligence | 43 | Whale tracking, entity investigation, fund flow analysis, portfolio, transfers, DEX swaps, token data, market metrics, address labels — across 20+ chains (Ethereum, Bitcoin, Solana, BSC, Tron, TON, Dogecoin, etc.) |
| Cronos EVM | 12 | Balance, tokens, transactions, gas, market data, VVS swaps, pool info, internal tx, logs |
| Cronos zkEVM | 11 | zkCRO balance, tx history, token transfers, internal tx, contract ABI/source, token supply, block info |
| Mantle Network | 12 | MNT balance, blocks, transactions, tokens, gas, tx history, token transfers, token list, portfolio, contract ABI/source, L2 rollup info |
| EVM (Generic) | 6 | Etherscan, Zerion portfolio, ENS resolution, multi-chain wallet |
| Aptos + Shelby | 13 | Coin balance, resources, modules, ANS names, transactions, Shelby blob upload, retrieval, pricing, NFT minting |
| Solana | 4 | Token balances, portfolio, market data |
| Flow | 3 | Cadence scripts, NFT collections |
| SEI | 4 | Cosmos queries, IBC transfers |
| Zeta | 3 | ZetaVM testnet, cross-chain messaging |
| Monad | 10 | MON balance, tx details, gas, portfolio, DeFi positions, NFTs, token positions, stats, nad.fun search |
| Sui & Walrus | 19 | RPC queries, BlockVision address activity, checkpoints, whale tracker, entity intelligence, DeFi & MCP directory, Walrus decentralized storage (upload, retrieve, pricing), embedded Sui agent wallet, transfers, DeFi strategy planner, native bridge |
| Creditcoin | 2 | Blockchain data via Blockscout API, network statistics |
| Utility | 8 | Web search, news, X/Twitter, DeFi Llama, image generation |
Direct API access to Cronos zkEVM (Chain ID 388) block range for reliability:
// Available zkEVM Tools
const zkevmTools = {
getZkEVMBalance, // Native zkCRO balance (with RPC fallback)
getZkEVMTransactionHistory, // Transaction history
getZkEVMTransaction, // Transaction status by hash
getZkEVMTokenBalance, // ERC-20 token balance
getZkEVMGasPrice, // zkCRO price
getZkEVMTokenTransfers, // ERC-20 transfer history
getZkEVMInternalTxList, // Internal transactions
getZkEVMContractABI, // Contract ABI (verified)
getZkEVMContractSource, // Contract source code
getZkEVMTokenSupply, // Token total supply
getZkEVMBlockInfo, // Block information
};
// API: https://explorer-api.zkevm.cronos.org/api/v1
// Requires: ZKEVM_CRONOS_EXPLORER_API_KEY| Chain | SDK | Network | RPC Provider | Capabilities |
|---|---|---|---|---|
| Arkham Intelligence | REST API | All chains | api.arkm.com |
Entity intel, whale tracking, fund flows, 20+ chains |
| Cronos EVM | viem + ethers.js v6 |
Mainnet + Testnet | Cronos RPC | EVM tx, CRC-20, Relay Swaps |
| Cronos zkEVM | Native fetch | Mainnet (388) | zkEVM Explorer API | zkCRO, ERC-20, internal tx |
| Mantle | viem + Etherscan V2 |
Mainnet (5000) | Mantle RPC | MNT, portfolio, L2 rollup, contracts |
| Ethereum | viem + ethers.js v6 |
Mainnet | Infura/Alchemy | ENS, ERC-20/721/1155 |
| Polygon | viem |
PoS Mainnet | QuickNode | Low-cost tx, NFTs |
| Aptos | @aptos-labs/ts-sdk |
Mainnet | Aptos Fullnode | Move, ANS names |
| Shelby (Aptos) | @shelby-protocol/sdk |
Testnet | Shelby RPC | Blob storage, NFT minting, pricing |
| Flow | @onflow/fcl |
Mainnet | Flow Access Node | Cadence, NFTs |
| SEI | @sei-js/core |
Pacific-1 | SEI RPC | Cosmos SDK, IBC |
| Solana | Native JSON-RPC | Mainnet | Helius/QuickNode | SPL tokens, DeFi |
| Monad | viem + Zerion API |
Mainnet (143) | Monad RPC | MON, portfolio, DeFi, NFTs, nad.fun |
| Sui & Walrus | @mysten/sui + fetch |
Mainnet + Testnet | Sui Fullnode RPC + Walrus APIs | RPC read, Walrus blob storage, embedded wallet, DeFi planning, official bridge |
| Creditcoin | Blockscout API | Mainnet | Blockscout RPC | CTC balance, tx, stats |
Barzakh AI integrates Relay Protocol for seamless cross-chain token swaps with optimized routes:
// Available Relay Tools
const relayTools = {
getRelaySwapQuote, // Get optimal swap quote across chains
executeRelaySwap, // Execute approved cross-chain swap
getRelaySupportedTokens // List supported tokens per chain
};
// Example: Cross-Chain Swap to BNB Chain
{
fromChainId: 8453, // Base
toChainId: 56, // BNB Chain (BSC)
fromToken: "USDC", // Auto-resolved to contract address
toToken: "native", // BNB
amount: "100",
// Returns: quote, route, fees, estimated time
}Features:
- 85+ Supported Chains: BNB Chain (BSC), Ethereum, Monad, Base, Optimism, Arbitrum, Polygon, Solana, and more
- BNB Chain Support: Full BSC support (Chain ID 56) — swap, bridge, trade any BSC token
- Swap Completion Tracking: Prevents duplicate swaps with server-side persistence
- Optimized Routing: Best rates via Relay's solver network
- MEV Protection: Protected transactions via Relay infrastructure
- Smart Token Decimals: Automatic decimal resolution via API + hardcoded fallbacks for safety
Barzakh AI features a deep, technical integration with Four.meme, allowing for the fully autonomous creation and launch of meme tokens on the BNB Chain (BSC). This integration is designed for high reliability and "Zero-Click" execution.
- DEX Authentication: The agent autonomously generates a nonce and signs a login challenge using the agent's delegated wallet to obtain a secure JWT session from the Four.meme backend.
- Metadata & Logo Upload: Multi-modal attachments (PNG, JPG, WEBP, GIF) are intercepted from the chat, proxied through Cloudflare R2 for optimization, and uploaded to the Four.meme secure storage.
- Smart Contract Preparation: The agent constructs the
TokenCreatetransaction payload, auto-configuring complex bonding curve parameters and tax distributions. - On-Chain Execution: Transactions are signed and broadcast via the embedded agent wallet (Chain ID 56).
To provide the user with the instant contract address and project URL, the agent implements a multi-ABI fallback strategy for decoding logs:
- Primary Method: Standard ABI decoding of the
TokenCreateevent. - Secondary Method: Topic0 Signature Matching. The agent specifically scans for the unique hash:
0x396d5e902b675b032348d3d2e9517ee8f0c4a926603fbc075d3d282ff00cad20 - Deductive Fallback: In high-traffic periods, the agent cross-references log topics against the user's wallet address to isolate and extract the newly generated token address with 100% accuracy.
Supports professional-grade distribution models at launch:
- Burn Rate: Deflationary supply reduction.
- Dividends: Automated sharing with token holders.
- Liquidity: Auto-feeding the bonding curve liquidity.
- Custom Recipients: Specific dev/fund recipient wallets with automated percentage splits.
[User attaches image/gif] + prompt:
Launch a token named 'Testing Tokens' with symbol 'TEST'
Description: 'ur description here'
Use the image I just uploaded and add:
- 5% Total Tax
- 10% Funds Recipient Wallet (0x15b263cdCf21bb9cba53D12275CD66b05FCE14B8)
- Burn 20%
- Divide To Holders 20% (min 5000000 balance)
- Add to Liquidity 50%
Barzakh AI provides native BNB Chain (BSC) support:
| Operation | Example Prompt | What Happens |
|---|---|---|
| Swap to BNB | "Trade 100 USDC on Base for BNB" | Cross-chain swap via Relay, tx on BSC |
| Swap from BNB | "Swap 0.5 BNB to ETH on Ethereum" | Bridge + swap from BSC |
| BSC Token Swaps | "Swap 50 USDT for BNB on BSC" | Same-chain swap on BSC |
| Cross-chain Bridge | "Bridge 1 ETH from Ethereum to BNB Chain" | Native token bridge to BSC |
| Portfolio Check | "Show my portfolio on BNB Chain" | Wallet analysis via Zerion |
| USD Amounts | "Trade $50 worth of BNB to USDC" | Auto price conversion + swap |
Live at chat.barzakh.tech — paste any prompt below to test.
Trade 100 USDC on Base for BNB
Swap 0.1 BNB to USDC on BSC
Launch a token on four.meme named 'Testing' with symbol 'TEST'. Burn 10%, add 90% to liquidity.
Bridge $20 of ETH from Ethereum to BNB Chain
What chains does Relay support?
Get a quote to swap 500 USDT on Arbitrum for BNB
flowchart LR
A["User: Trade 100 USDC for BNB"] --> B["Intent Classifier"]
B --> C["Smart Chain Inference\nBNB → Chain 56"]
C --> D["Relay Protocol Quote\n(Best route, fees, time)"]
D --> E["In-Chat Approval UI"]
E --> F["Wallet Signs TX"]
F --> G["Onchain Execution\nTX Hash on BSC"]
Barzakh AI provides 10 dedicated Monad tools for comprehensive interaction with the Monad blockchain (Chain ID 143), a high-performance parallelized EVM L1:
| Tool | Function |
|---|---|
getMonadBalance |
Native MON balance for any wallet |
getMonadTransaction |
Transaction details by hash |
getMonadGasPrice |
Current gas price estimation |
getMonadTransactionHistory |
Full transaction history (Zerion API) |
getMonadPortfolio |
Complete portfolio: tokens, DeFi, NFTs |
getMonadDefiPositions |
DeFi positions (lending, staking, LP) |
getMonadNFTs |
NFT holdings and collections |
getMonadTokenPositions |
All token balances with USD values |
getMonadStats |
Blockchain statistics via MonadScan |
searchNadFunTokens |
Search nad.fun tokens by name/symbol/address |
Native integration with nad.fun, Monad's bonding curve token launchpad:
flowchart LR
A["User: Buy Penguin"] --> B["searchNadFunTokens"]
B --> C["Present Results\n(Name, Price, Address)"]
C --> D["User Confirms Token"]
D --> E["Relay Protocol\n(toChainId: 143)"]
E --> F["In-Chat Approval UI"]
F --> G["Sign & Execute"]
- Search First: The AI queries
api.nadapp.netto find tokens matching the user's query - Smart Chain Routing: All nad.fun tokens are automatically routed to Monad (Chain ID 143)
- Relay Execution: Trades execute via Relay Protocol with cross-chain support
- Monad Meme Token Support: MOLANDAK, EMO, MOXY, CHOG, MOYAKI, DAK, and more are pre-mapped for instant chain inference
Live at chat.barzakh.tech — paste any prompt below to test.
What is the MON balance of 0x96973F7B83A3c785d94e0a6d8712174aBb81b748?
Show me the full portfolio for 0x96973F7B83A3c785d94e0a6d8712174aBb81b748 on Monad
Swap 1000 MON to USDC on Monad
Swap 1 ETH from Ethereum to MON on Monad
Get a quote to swap MON to MOLANDAK
Search for Penguin tokens on nad.fun
Buy Nietzschean Penguin on nad.fun
What are the trending tokens on nad.fun?
Bridge 1000 USDC from Base to Monad
What chains does Relay support?
Show me the latest transactions on Monad
What is the current gas price on Monad?
Tell me about the Monad ecosystem and upcoming events
Barzakh AI integrates Arkham Intelligence with 43 dedicated tools for deep blockchain investigation, whale tracking, and entity intelligence across 20+ chains (Ethereum, Bitcoin, Solana, BSC, Tron, TON, Dogecoin, Polygon, Arbitrum, Base, and more).
| Category | Tools | Key Functions |
|---|---|---|
| Intelligence | 10 | Search entities, address enrichment, batch lookup, entity info, predictions, entity types, balance changes, contract intel, token intel, intel updates |
| Transfers & Transactions | 3 | Whale transfer tracking (filter by USD, entity, chain, time), transfer histograms, transaction lookup |
| Balances & Portfolio | 4 | Multi-chain balances, Solana subaccounts, portfolio snapshots, portfolio time series |
| Flow & Analytics | 5 | USD flow history, top counterparties, volume analysis, activity history, DeFi loan positions |
| Token Data | 12 | Top/trending tokens, market data, holders, balances, addresses, price history, price changes, top flows, volume, exchange tokens |
| DEX Swaps | 1 | DEX trade history across Uniswap, Sushiswap, and more |
| Networks & Infra | 4 | Supported chains, network status, network history, cluster analysis |
| Market Data | 2 | Altcoin index, ARKM circulating supply |
| Tags & Labels | 2 | Tag info/summary, user custom labels |
ethereum · bitcoin · solana · bsc · polygon · arbitrum · optimism · base
tron · ton · dogecoin · avalanche · fantom · blast · linea · manta
mantle · sonic · flare · zcash
Live at chat.barzakh.tech — paste any prompt below to test.
Show me the largest transfers on Ethereum in the last 24 hours over $1M
Track fund flows for Binance in the last 7 days
Who are the top counterparties of Jump Trading?
Search Arkham for Wintermute
Get intelligence on address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
What entities are accumulating Bitcoin?
Show me trending tokens on Arkham
Who are the top holders of Ethereum?
Get price history for Bitcoin from Arkham
Show Binance's portfolio on Ethereum
Get the Arkham Altcoin Index
What are the DeFi loans for this address?
Barzakh AI provides 12 dedicated Mantle tools for comprehensive interaction with Mantle Network (Chain ID 5000), a high-performance L2 on Ethereum with ultra-low gas fees.
| Tool | Function |
|---|---|
getMantleBalance |
Native MNT balance for any wallet |
getMantleBlockInfo |
Block details (number, hash, timestamp, gas) |
getMantleTransaction |
Transaction details by hash (with receipt) |
getMantleTokenBalance |
ERC-20 token balance on Mantle |
getMantleGasPrice |
Current gas price with fee estimates |
getMantleTransactionHistory |
Full tx history via Zerion API |
getMantleTokenTransfers |
ERC-20 transfer events |
getMantleTokenList |
All token holdings for a wallet |
getMantlePortfolio |
Complete portfolio: MNT + tokens + DeFi |
getMantleContractABI |
Verified contract ABI |
getMantleContractSource |
Contract source code |
getMantleRollupInfo |
L2 rollup & batch data |
Live at chat.barzakh.tech — paste any prompt below to test.
What is the MNT balance of 0x1234...?
Show my portfolio on Mantle
What is the current gas price on Mantle?
Get transaction history for 0x1234... on Mantle
Barzakh AI integrates Creditcoin via the Blockscout API for real-time blockchain data and network statistics.
| Tool | Function |
|---|---|
getCreditcoinApiData |
AI-driven query routing to Blockscout API endpoints |
getCreditcoinStats |
Network statistics screenshot from Blockscout |
Barzakh AI integrates Shelby Protocol for decentralized blob storage on the Aptos Testnet blockchain. The AI autonomously uploads, retrieves, and anchors files as Aptos Token V2 Digital Asset NFTs.
flowchart LR
A["User: 'Store this on Shelby'"] --> B["AI Agent"]
B --> C{"Text or File?"}
C -->|Text| D["Buffer.from(text)"]
C -->|Image/PDF/Video| E["fetchImageAsBase64\n(proxy pipeline)"]
D --> F["ShelbyNodeClient.upload()"]
E --> F
F --> G["Blob on shelbynet"]
G --> H{"mintAsNFT?"}
H -->|Yes| I["Ensure Collection\n'Barzakh AI Storage'"]
I --> J["mintDigitalAsset"]
J --> K["NFT anchored on-chain"]
H -->|No| L["Return Explorer URL"]
K --> L
| Tool | Parameters | Description |
|---|---|---|
uploadToShelby |
content, fileUrl, fileName, mintAsNFT |
Upload text/files to Shelby; optionally mint as NFT |
getShelbyBlob |
address, name |
Retrieve blob content by owner address + blob name |
getShelbyStoragePrice |
sizeInBytes |
Estimate storage cost for a given data size |
| Type | Extensions | Max Size | Notes |
|---|---|---|---|
| Text | .txt, .json, .md, .csv |
25 MB | Stored as raw bytes |
| Images | .jpg, .png, .webp, .gif |
25 MB | Fetched via R2 proxy pipeline |
| Documents | .pdf, .doc, .docx |
25 MB | Binary-safe upload |
| Video | .mp4, .mov, .webm |
25 MB | Binary-safe upload |
| Audio | .mp3, .wav, .ogg |
25 MB | Binary-safe upload |
- Collection: All uploads mint into a unified "Barzakh AI Storage" collection
- Auto-Provisioning: Collection is created automatically on first mint; subsequent mints detect
ECOLLECTION_ALREADY_EXISTSand proceed - Asset URI: Each NFT's
uripoints to the ShelbypublicUrl, making content directly accessible - Network: Aptos Testnet
- Signer: Ed25519 key from
SHELBY_APTOS_PRIVATE_KEY(server-side only)
Live at chat.barzakh.tech — paste any prompt below to test.
Store "Hello World" on Shelby Protocol
Store this image on Shelby and mint it as an NFT
(attach any image to the chat)
Store this PDF on Shelby Protocol
(attach any PDF to the chat)
How much does it cost to store 1MB on Shelby?
Barzakh AI features a deep integration with the Sui Blockchain and Walrus Protocol (Sui Overflow 2026). It offers 19 dedicated tools covering RPC queries, whale tracking, exchange/entity intelligence, DeFi/MCP directories, decentralized storage (Walrus), and secure autonomous write operations using an embedded Sui agent wallet.
| Category | Tool | Function |
|---|---|---|
| Core RPC & Queries | getSuiNetworkStatus |
Returns live Sui network status, latest checkpoint, reference gas price, and protocol version. |
getSuiBalance |
Gets the native SUI balance (in SUI and MIST) for any wallet address. | |
getSuiPortfolio |
Fetches the full wallet portfolio from live RPC: trusted coin balances, metadata, and filters out spam/scam airdrop tokens. | |
getSuiAddressActivity |
Retrieves recent transaction activity (Send, Swap, Stake, Claim, etc.) with detailed coin/NFT changes, powered by BlockVision indexer. | |
getSuiObject |
Inspects owner, content, and type of any Sui Object ID. | |
getSuiTransaction |
Fetches full transaction details, execution effects, events, and balance changes for any transaction digest. | |
searchSuiCheckpoints |
Searches and inspects recent checkpoint data. | |
| Whale & Entity Intel | trackSuiWhaleActivity |
Scans checkpoint-sampled large SUI flows to alert on whale and exchange movements. |
getSuiExchangeAndEntityIntelligence |
Maps Sui network entities and exchanges, linking to Arkham intelligence profiles. | |
| Ecosystem Directories | getSuiDefiEcosystem |
Maps major Sui DeFi protocols (Cetus, Navi, Suilend, Aftermath, Scallop, etc.) for LP & lending options. |
getSuiMcpEcosystem |
Directory of Sui Model Context Protocol (MCP) servers and Agentic Web integration plans. | |
getSuiNativeBridgeInfo |
Documents official Sui Native Bridge parameters and safety constraints. | |
| Walrus Storage | uploadToWalrus |
Uploads raw text, structured JSON, or downloadable file URLs to Walrus Protocol decentralized storage. |
getWalrusBlob |
Retrieves blob data from Walrus using a Blob ID. | |
getWalrusStoragePrice |
Estimates storage costs (in SUI/MIST) on Walrus for a given size and duration in epochs. | |
| Embedded Agent Wallet | getSuiAgentWalletInfo |
Inspects the user's embedded Sui agent wallet, delegation status, network, and SUI balance. |
executeSuiTransfer |
Signs and broadcasts a native SUI transfer autonomously from the embedded agent wallet (if automation is enabled). | |
planSuiDeFiAgentStrategy |
Formulates LP, bridge, or Walrus memory strategies, checking blockers, budget caps, and risk levels. | |
prepareSuiBridgeDeposit |
Prepares or executes Ethereum -> Sui deposits using the official Sui Native Bridge via the embedded EVM wallet. |
flowchart LR
A["User: 'Store this JSON on Walrus'"] --> B["AI Agent"]
B --> C{"Text or File URL?"}
C -->|Text| D["JSON/Raw Bytes"]
C -->|File URL| E["fetchImageAsBase64\n(Download helper)"]
D --> F["HTTP PUT /v1/blobs\n(Walrus Publisher)"]
E --> F
F --> G["Walrus Storage Node"]
G --> H["Return Blob ID &\nSui Certified Object ID"]
flowchart TD
A["User request"] --> B["planSuiDeFiAgentStrategy"]
B --> C{"Are blockers present?\n(Wallet funded? Enabled? Network correct?)"}
C -->|Yes| D["Present blockers to user for resolution"]
C -->|No| E["Formulate plan & suggest next tool"]
E --> F{"Strategy Type?"}
F -->|Bridge| G["prepareSuiBridgeDeposit\n(Ethereum -> Sui)"]
F -->|Transfer/Swap| H["executeSuiTransfer\n(Sui network tx)"]
F -->|Memory/Logs| I["uploadToWalrus\n(Store state snapshot)"]
Live at chat.barzakh.tech — paste any prompt below to test.
What is the SUI balance of 0x6605abfdbfbf98c09c7bc072abb0781103231a2a8dff28c33a5faaed5aaf081e?
Show my recent transaction history on Sui testnet
Check the network status of Sui mainnet
Inspect the Sui object 0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7
Are there any large SUI transactions in the latest checkpoints?
Check Arkham intelligence for Binance entity on Sui
Store the text "Barzakh AI + Walrus Protocol Integration" on Walrus
Estimate the cost to store 5MB for 3 epochs on Walrus
Download and retrieve the Walrus blob with ID 4Q_qjT...
The x402 implementation uses EIP-3009 TransferWithAuthorization for USDC payments on Base:
sequenceDiagram
autonumber
participant User as 👤 User
participant Frontend as 🖥️ Frontend
participant API as 📡 Backend API
participant Wallet as 🔐 Wallet
participant Facilitator as ⚡ x402 Facilitator
participant Chain as ⛓️ Blockchain
Note over User,Chain: Step 1: Wallet Verification
User->>Frontend: Connect Wallet
Frontend->>API: GET /api/billing/x402/verify-wallet?address=0x...
API-->>Frontend: Nonce Message (EIP-191)
Frontend->>Wallet: Sign Message Request
User->>Wallet: Approve Signature
Wallet-->>Frontend: Signature (65 bytes)
Frontend->>API: POST /api/billing/x402/verify-wallet
Note over API: ecrecover(hash, sig) == address
API-->>Frontend: Wallet Verified ✓
Note over User,Chain: Step 2: Payment Initialization
Frontend->>API: POST /api/billing/x402/subscribe
API-->>Frontend: 402 Payment Required<br/>{amount, recipient, paymentRequirements}
Note over User,Chain: Step 3: EIP-712 Signature (Gasless)
Frontend->>Frontend: Build EIP-712 TypedData<br/>(TransferWithAuthorization)
Frontend->>Wallet: signTypedData_v4
User->>Wallet: Approve Signature
Wallet-->>Frontend: EIP-712 Signature
Note over User,Chain: Step 4: Settlement
Frontend->>API: POST /api/billing/x402/settle<br/>{paymentHeader, paymentRequirements}
API->>Facilitator: Verify + Submit Transaction
Facilitator->>Chain: transferWithAuthorization()
Chain-->>Facilitator: TX Receipt
Facilitator-->>API: {txHash, blockNumber}
API->>API: Activate Subscription<br/>Set x402PeriodEnd
API-->>Frontend: 200 OK - Subscription Active
// EIP-712 Domain for USDC on Base
const domain = {
name: "USD Coin",
version: "2",
chainId: 8453,
verifyingContract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
};
// EIP-3009 TransferWithAuthorization Types
const types = {
TransferWithAuthorization: [
{ name: "from", type: "address" },
{ name: "to", type: "address" },
{ name: "value", type: "uint256" },
{ name: "validAfter", type: "uint256" },
{ name: "validBefore", type: "uint256" },
{ name: "nonce", type: "bytes32" },
],
};| Event | Action |
|---|---|
| Payment Success | Set tier, x402PeriodEnd, reset dailyMessageRemaining |
| Real-time Check | Chat route checks x402PeriodEnd on every request |
| Cron Job | Every 6 hours, downgrade expired subscriptions |
| Cancel at Period End | Set x402CancelAtPeriodEnd = true, keep benefits until expiry |
| Cancel Immediately | Downgrade to free tier instantly |
flowchart TB
subgraph Entry["🌐 Entry Points"]
Email["Email + Password"]
Google["Google OAuth 2.0"]
Wallet["Wallet Connect<br/>(EIP-4361 SIWE)"]
end
subgraph Verification["🔐 Multi-Factor Verification"]
Password["Password<br/>(bcrypt, 12 rounds)"]
TOTP["TOTP 2FA<br/>(RFC 6238, 30s window)"]
EmailOTP["Email OTP<br/>(6-digit, 10min TTL)"]
WalletSig["Wallet Signature<br/>(EIP-191)"]
end
subgraph Session["🎫 Session Management"]
JWT["JWT Token<br/>(HS256, httpOnly)"]
Cookie["Secure Cookie<br/>(SameSite=Lax)"]
Refresh["Session Refresh<br/>(sliding window)"]
end
subgraph Protected["🛡️ Protected Operations"]
Normal["Normal Ops<br/>(Session Only)"]
Sensitive["Sensitive Ops<br/>(Re-auth Required)"]
end
subgraph SensitiveOps["Re-authentication Required"]
Delete["Account Deletion"]
WalletBind["Wallet Bind/Unbind"]
EmailChange["Email Change"]
PasswordChange["Password Change"]
end
Email --> Password --> TOTP
Google --> JWT
Wallet --> WalletSig --> JWT
Password --> EmailOTP
TOTP --> JWT
EmailOTP --> JWT
JWT --> Cookie --> Session
Session --> Normal
Session --> Sensitive --> SensitiveOps
style Sensitive fill:#ff6b6b
style SensitiveOps fill:#ff8787
┌──────────────────────────────────────────────────────────────────────────────────────┐
│ AI SECURITY DEFENSE LAYERS │
├──────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
│ │ LAYER 1: INPUT SANITIZATION │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌──────────────────────┐ │ │
│ │ │ Homoglyph │ │ Invisible │ │ RTL/LTR │ │ Unicode │ │ │
│ │ │ Detection │ │ Char Strip │ │ Override │ │ Normalization │ │ │
│ │ │ (Lookalikes)│ │ (U+200B,etc)│ │ Removal │ │ (NFC/NFKC) │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └──────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
│ │ LAYER 2: PROMPT INJECTION DEFENSE │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌──────────────────────┐ │ │
│ │ │ Direct │ │ Indirect │ │ Jailbreak │ │ Role/Context │ │ │
│ │ │ Injection │ │ Injection │ │ Pattern │ │ Manipulation │ │ │
│ │ │ Detection │ │ (via URLs) │ │ Matching │ │ Prevention │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └──────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
│ │ LAYER 3: MEDIA & FILE PROTECTION │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌──────────────────────┐ │ │
│ │ │ Polyglot │ │ EXIF/Meta │ │Steganography│ │ File Type │ │ │
│ │ │ File │ │ Data Strip │ │ Detection │ │ Validation │ │ │
│ │ │ Detection │ │ │ │ │ │ (Magic Bytes) │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └──────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
│ │ LAYER 4: MODEL PROTECTION │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌──────────────────────┐ │ │
│ │ │ Sponge │ │ Model │ │ Model │ │ Output │ │ │
│ │ │ Attack │ │ Extraction │ │ Inversion │ │ Filtering │ │ │
│ │ │ Prevention │ │ Defense │ │ Guard │ │ (PII, Secrets) │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └──────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
│ │ LAYER 5: RUNTIME MONITORING │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌──────────────────────┐ │ │
│ │ │ Rate │ │ Anomaly │ │ x402 Expiry │ │ Audit │ │ │
│ │ │ Limiting │ │ Detection │ │ Check │ │ Logging │ │ │
│ │ │ (Tier-based)│ │ (Pattern) │ │ (Real-time) │ │ (Compliance) │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └──────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────┘
| Threat Category | Attack Vector | Defense Mechanism |
|---|---|---|
| Prompt Injection | Direct system prompt override | Pattern matching, input boundary enforcement |
| Indirect Injection | Malicious content via URLs/files | Content isolation, sandboxed parsing |
| Jailbreak Attempts | Role manipulation, DAN prompts | System prompt hardening, output monitoring |
| Homoglyph Attacks | Lookalike Unicode characters | Character normalization, visual similarity detection |
| Invisible Characters | Zero-width chars (U+200B, U+FEFF) | Whitespace stripping, control char removal |
| Polyglot Files | Images containing executable code | Magic byte validation, metadata stripping |
| Sponge Attacks | DoS via expensive computations | Token limits, complexity analysis, timeouts |
| Data Exfiltration | PII/secrets in AI outputs | Output filtering, regex-based redaction |
| Unauthorized Access | Direct object access | Private R2 buckets + Short-lived (15m) Signed URLs |
barzakh-ai/
├── apps/
│ ├── frontend/ # Next.js 16.2 Application
│ │ ├── app/
│ │ │ ├── (auth)/ # Auth pages (login, register, 2FA)
│ │ │ ├── (chat)/ # Chat interface + API routes
│ │ │ │ └── api/ # Protected API endpoints
│ │ │ │ └── chat/ # AI chat with tool execution
│ │ │ └── api/ # Public API routes
│ │ │ ├── 2fa/ # TOTP setup & verification
│ │ │ ├── auth/ # NextAuth handlers
│ │ │ ├── billing/ # Stripe + x402 payments
│ │ │ │ └── x402/ # Crypto payment endpoints
│ │ │ │ ├── subscribe/ # Get payment requirements
│ │ │ │ ├── settle/ # Execute settlement
│ │ │ │ ├── verify/ # Verify transaction
│ │ │ │ └── verify-wallet/ # Wallet signature verification
│ │ │ ├── cron/ # Scheduled jobs
│ │ │ │ └── check-subscriptions/ # x402 expiry check (every 6h)
│ │ │ └── settings/ # User preferences
│ │ ├── components/
│ │ │ ├── message.tsx # Chat message component
│ │ │ ├── settings/ # Settings UI
│ │ │ │ └── plans/
│ │ │ │ └── x402-payment-modal.tsx # Crypto payment modal
│ │ │ └── ui/ # Radix UI primitives
│ │ └── lib/
│ │ ├── db/ # Drizzle ORM
│ │ │ ├── schema.ts # Database schema
│ │ │ └── migrations/ # SQL migrations
│ │ ├── stripe.ts # Stripe configuration
│ │ └── wagmi.ts # Web3 configuration
│ │
│ └── backend/ # Supplementary backend services
│
├── packages/
│ └── shared/ # Shared utilities (@barzakh/shared)
│ └── src/lib/
│ ├── ai/
│ │ ├── models.ts # Model configurations
│ │ ├── prompts.ts # System prompts (100KB+)
│ │ ├── intent-classifier.ts # Chain-aware routing
│ │ └── tools/ # 100+ blockchain tools
│ │ ├── onchain/ # Arkham Intelligence (43 tools)
│ │ ├── cronos/ # Cronos EVM + zkEVM + VVS DEX
│ │ │ ├── cronos-tools.ts # Cronos EVM (12 tools)
│ │ │ ├── cronos-zkevm-tools.ts # Cronos zkEVM (11 tools)
│ │ │ ├── vvs-swap.ts # VVS Finance DEX
│ │ │ └── ai-agent-sdk.ts # AI Agent SDK wrapper
│ │ ├── aptos/ # Aptos + Shelby Protocol
│ │ │ └── shelby-tools.ts # Blob upload, retrieval, pricing, NFT minting
│ │ ├── solana/ # Solana-specific
│ │ ├── evm/ # EVM chains
│ │ ├── flow/ # Flow blockchain
│ │ ├── sei/ # SEI chain
│ │ ├── zeta/ # Zeta chain
│ │ ├── monad/ # Monad mainnet
│ │ ├── mantle/ # Mantle L2 (12 tools)
│ │ ├── creditcoin/ # Creditcoin (Blockscout)
│ │ └── relay/ # Relay Protocol cross-chain swaps
│ ├── payments/
│ │ └── x402-facilitator.ts # x402 protocol implementation
│ ├── security/ # Input sanitization
│ └── utils/ # Shared utilities
│
├── docs/
│ ├── cloudflare-api-schema.yaml # OpenAPI 3.0 spec (source)
│ └── cloudflare-api-schema.json # OpenAPI 3.0 spec (generated)
│
├── turbo.json # Turborepo configuration
├── pnpm-workspace.yaml # pnpm workspace config
└── package.json # Root package.json
| Requirement | Version | Install |
|---|---|---|
| Node.js | 18+ | nodejs.org |
| pnpm | 10+ | npm install -g pnpm |
| PostgreSQL | 15+ | neon.tech (free serverless) or local install |
# Install dependencies
pnpm install
# Configure environment
cp apps/frontend/.env.example apps/frontend/.env.local
# Edit .env.local with your API keys (see below)
# Run database migrations
pnpm --filter frontend db:migrate
# Start development server
pnpm devCreate apps/frontend/.env.local:
# ── Database (Required) ──────────────────────────────────────────────────
DATABASE_URL=postgresql://user:password@host:5432/database?sslmode=require
# ── Auth (Required) ──────────────────────────────────────────────────────
NEXTAUTH_SECRET=your-secret-key # Generate: openssl rand -base64 32
NEXTAUTH_URL=http://localhost:3000
GOOGLE_CLIENT_ID=... # Google OAuth (optional)
GOOGLE_CLIENT_SECRET=...
# ── AI Providers (Required) ───────────────────────────────────────────
OPENROUTER_ENDPOINT=https://...services.ai.azure.com/openai/v1
OPENROUTER_API_KEY=... # OpenRouter API key or bearer token
OPENROUTER_CONNECT_ATTEMPT_TIMEOUT_MS=5000
# ── Azure GPT-Image-2 Imagine Tool ───────────────────────────────────
OPENROUTER_IMAGE_MODEL=gpt-image-2
OPENROUTER_IMAGE_QUALITY=low # low | medium | high
OPENROUTER_IMAGE_SIZE=1024x1024 # any GPT-Image-2-valid WIDTHxHEIGHT
OPENROUTER_IMAGE_TIMEOUT_MS=600000
OPENROUTER_IMAGE_STREAM=false
OPENROUTER_IMAGE_PARTIAL_IMAGES=2
# ── Blockchain / Relay Protocol ──────────────────────────────────────────
# No API key needed for Relay Protocol — it's open and permissionless!
# ── External APIs (Optional) ─────────────────────────────────────────────
ZERION_API_KEY=... # Wallet portfolio analysis
TAVILY_API_KEY=... # Web search tool
ARKHAM_API_KEY=... # Arkham Intelligence (whale tracking, entity intel)
ETHERSCAN_API_KEY=... # Etherscan V2 (Mantle, multi-chain)
# ── Payments (Optional) ──────────────────────────────────────────────────
STRIPE_SECRET_KEY=sk_...
STRIPE_WEBHOOK_SECRET=whsec_...
# ── Storage (Required for persistent generated/edited images) ───────────
R2_ACCOUNT_ID=...
R2_ACCESS_KEY_ID=...
R2_SECRET_ACCESS_KEY=...
R2_BUCKET_NAME=...
R2_PUBLIC_URL=https://... # Public/custom R2 URL used in chat results
# ── Security ─────────────────────────────────────────────────────────────
CRON_SECRET=your-cron-secret| Command | Description |
|---|---|
pnpm dev |
Start all apps in dev mode |
pnpm dev:frontend |
Run frontend only |
pnpm build |
Build all apps |
pnpm lint |
Lint all packages |
pnpm --filter frontend db:generate |
Generate migration files |
pnpm --filter frontend db:migrate |
Run migrations |
pnpm --filter frontend db:studio |
Open Drizzle Studio |
pnpm --filter frontend db:push |
Push schema changes (dev) |
Full OpenAPI 3.0 specification available in /docs/cloudflare-api-schema.yaml.
| Endpoint | Method | Description |
|---|---|---|
/api/auth/* |
* | NextAuth handlers |
/api/2fa/* |
POST | Two-factor authentication |
/api/billing/subscription |
GET | Subscription status |
/api/billing/x402/subscribe |
POST | Initiate x402 payment |
/api/billing/x402/verify-wallet |
GET/POST | Wallet signature verification |
/api/billing/x402/settle |
POST | Settle x402 payment |
/api/billing/x402/verify |
POST | Verify transaction |
/api/relay/swap-tracking |
GET/POST | Track swap completion status |
/api/zerion/positions |
GET | Token positions by chain |
/api/zerion/nft-collections |
GET | NFT collections (public) |
/api/zerion/nft-portfolio |
GET | NFT portfolio overview |
/api/wallet/verify-signature |
GET/POST | Unified wallet verification |
/api/settings |
GET/PATCH | User settings |
/api/settings/wallet/* |
* | Wallet binding/unbinding |
/api/cron/check-subscriptions |
GET | x402 expiry check (cron) |
| Endpoint Category | Limit | Window |
|---|---|---|
| Authentication | 10 requests | 1 minute |
| Chat API | Tier-based | Daily |
| Billing | 20 requests | 1 minute |
| Settings | 30 requests | 1 minute |
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod{
"framework": "nextjs",
"buildCommand": "cd ../.. && pnpm run build --filter=barzakh",
"crons": [
{
"path": "/api/messagelimitcron",
"schedule": "0 0 * * *"
},
{
"path": "/api/cron/check-subscriptions",
"schedule": "0 */6 * * *"
}
]
}| Environment | URL | Branch |
|---|---|---|
| Production | chat.barzakh.tech | main |
| API | staging.barzakh.tech | main |
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- TypeScript strict mode
- Biome for linting and formatting
- ESLint + Prettier integration
- Conventional Commits
MIT License - see LICENSE
Built by Sirath Network
🚀 AI Agent that executes onchain | ⛓️ 85+ chains via Relay | 🕵️ 43 Arkham Intel tools | 🔒 Security First
