Architecture

Technical architecture and design principles of the Molt402 transaction infrastructure.

System overview

Molt402 implements a layered architecture that separates concerns between agent intent, transaction construction, and protocol execution.

┌─────────────────────────────────────────────────────────────┐
│                 Application Layer                           │
│         (Agent frameworks, custom applications)             │
└────────────────────────┬────────────────────────────────────┘

                         │ SDK / REST API

┌────────────────────────▼────────────────────────────────────┐
│                   Molt402 Engine                            │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐     │
│  │   Intent     │  │  Transaction │  │  Execution   │     │
│  │   Parser     │→ │   Builder    │→ │   Monitor    │     │
│  └──────────────┘  └──────────────┘  └──────────────┘     │
│                                                             │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐     │
│  │     Gas      │  │    State     │  │   Security   │     │
│  │  Optimizer   │  │   Manager    │  │   Validator  │     │
│  └──────────────┘  └──────────────┘  └──────────────┘     │
└────────────────────────┬────────────────────────────────────┘

                         │ Protocol Adapter

┌────────────────────────▼────────────────────────────────────┐
│                    x402 Protocol                            │
│              (Blockchain network layer)                     │
└─────────────────────────────────────────────────────────────┘

Core components

Intent parser

Translates high-level instructions into structured transaction intents.

Input formats:

  • Natural language: "Transfer 50 USDC to 0xabcd...ef01"

  • Structured JSON: { action: "transfer", asset: "USDC", amount: "50", recipient: "0xabcd..." }

Processing pipeline:

  1. Tokenization: Extract entities (amounts, addresses, assets)

  2. Semantic analysis: Map tokens to protocol operations

  3. Validation: Verify intent completeness and coherence

  4. Normalization: Convert to standardized internal format

Output: Validated transaction intent object

Transaction builder

Constructs protocol-compliant transactions from parsed intents.

Responsibilities:

  • ABI encoding for contract calls

  • Parameter validation and type checking

  • Calldata optimization

  • Multi-step workflow orchestration

Transaction types:

Simple transfer:

Contract interaction:

Execution monitor

Tracks transaction lifecycle from submission to finalization.

State transitions:

Monitoring operations:

  • Mempool tracking (pending state)

  • Block inclusion detection

  • Confirmation depth counting

  • Reorg handling

  • Automatic resubmission on failure

Gas optimizer

Calculates optimal gas parameters using network analysis.

Data sources:

  • Last 100 blocks for base fee analysis

  • Mempool pending transactions for priority fees

  • Historical confirmation times

Prediction models:

EIP-1559 base fee:

Exponential weighted moving average:

Priority fee percentiles:

State manager

Maintains consistent view of transaction state across asynchronous operations.

State storage:

Nonce management:

  • Pessimistic locking: Reserve nonce before transaction construction

  • Sequential allocation: Ensure no gaps in nonce sequence

  • Recovery: Handle dropped transactions and nonce reuse

Concurrency handling:

Security validator

Validates transactions before submission to prevent failures and exploits.

Validation checks:

Balance verification:

Allowance checking:

Simulation:

Policy evaluation:

Protocol adapter

Standardized interface for blockchain protocol integration.

Adapter interface

x402 adapter implementation

Data flow

Transaction execution flow

State synchronization

Scalability

Horizontal scaling

Multiple Molt402 instances can run concurrently:

Coordination:

  • Distributed nonce locks via Redis

  • Shared transaction state in PostgreSQL

  • Leader election for monitoring tasks

Performance characteristics

Latency targets:

  • Intent validation: <100ms

  • Transaction construction: <200ms

  • Simulation: <500ms

  • Submission to network: <1000ms

  • End-to-end (standard priority): <60s

Throughput:

  • Sequential execution: 30-50 tx/minute

  • Parallel execution: 200-300 tx/minute

  • Batch operations: 1000+ recipients/batch

Security architecture

Non-custodial design

Defense in depth

Layer 1: Input validation

  • Intent structure validation

  • Parameter type checking

  • Address format verification

Layer 2: Policy enforcement

  • Declarative approval rules

  • Spending limits

  • Rate limiting

Layer 3: Simulation

  • Pre-flight execution

  • Balance verification

  • Reversion detection

Layer 4: Monitoring

  • Anomaly detection

  • Alert thresholds

  • Audit logging

Technology stack

Core infrastructure

Runtime: Node.js 20 LTS Language: TypeScript 5.3+ Protocol library: ethers.js v6

Database: PostgreSQL 15 Time-series: TimescaleDB extension Cache: Redis 7

Queue: BullMQ for async jobs Logging: Winston with JSON format Metrics: Prometheus

Agent integration

SDK: TypeScript/JavaScript (@molt402/sdk) Python bindings: molt402-python MCP server: Model Context Protocol support REST API: HTTP/2 with OpenAPI spec

Deployment

Container: Docker Orchestration: Kubernetes Service mesh: Istio (optional) Monitoring: Grafana + Prometheus Alerting: PagerDuty integration

Next steps

Support

Questions about architecture?

Last updated