DocsCore Concepts

Core Concepts

Understand the foundational architecture that powers Modexia. These concepts explain how your AI agent interacts with the blockchain without managing keys, gas, or RPC nodes directly.

Smart Contract Accounts (SCA)

When you activate your agent wallet, Modexia provisions an ERC-4337 Smart Contract Account on your behalf. Unlike traditional Externally Owned Accounts (EOAs) that rely on a single private key, SCAs are programmable on-chain contracts that support advanced features out of the box.

Account Abstraction (ERC-4337)

Your agent wallet is a smart contract, not a raw key pair. This enables batched transactions, social recovery, and programmable spending rules — all enforced at the protocol level.

Gas Sponsorship (Paymasters)

Your agent never needs to deal with infrastructure costs. Modexia uses Enterprise Settlement layers to sponsor fees on your behalf, so agents only deal in stable value. Network costs are abstracted entirely.

What this means for your agent

Your AI agent just calls client.transfer() and everything else — wallet creation, gas payment, transaction signing — is handled invisibly by the Modexia Gateway. No ETH. No gas estimation. No nonce tracking.


Hybrid Security Model

Modexia combines two complementary layers to deliver both security and speed. Payments are settled on-chain for finality, but guarded off-chain for latency.

L1

Immutable Settlement Engine

Every value transfer is routed through Modexia's Settlement Engine. The transaction is cryptographically signed, submitted to the ledger, and confirmed with full finality. This is the source of truth — immutable and verifiable.

L2

Off-Chain Guardrails (Server-Side Policy)

Before any transaction reaches the blockchain, Modexia's gateway evaluates your Spending Policies (daily limits, hourly limits, per-request caps) server-side in under 50ms. Violations are rejected instantly without incurring gas — delivering sub-second latency for policy enforcement.

Why hybrid?

Pure on-chain enforcement is slow and expensive. Pure off-chain is not trustworthy. The hybrid model gives you the speed of a centralized API with the finality guarantees of a blockchain. Policy checks happen in milliseconds; settlement happens on-chain.


High-Frequency Vaults (Micropayments)

For AI agents executing thousands of tasks per second (HFP - High-Frequency Payments), routing every transfer through the settlement layer is inefficient. Modexia Vaults solve this using cryptographic payment channels.

How Vaults Achieve Zero-Latency Scaling

  1. Deposit: The agent opens a channel, pre-funding it with a maximum allowance (e.g. $1.00). This is the only initial settlement transaction.
  2. Consume: The agent executes thousands of micro-payments (e.g. $0.0004 each) off-chain. Modexia generates cryptographic HMAC receipts for each step instantly, without network fees.
  3. Settle: When the channel expires or is closed, the final balance is synced to the ledger in a single transaction. Unused funds are instantly refunded.

Built for API consumption

With Vaults, your agent can pay fractions of a cent per API call at thousands of TPS, while maintaining cryptographically secure guarantees for the provider.


The x402 Protocol

The x402 protocol is an open standard for machine-to-machine payments over HTTP. It leverages the underused HTTP 402 Payment Required status code to enable autonomous agents to pay for API access without human intervention.

How it works in 30 seconds

  1. Your agent calls client.smart_fetch(url) to request a resource.
  2. The server responds with HTTP 402 and a WWW-Authenticate header containing the price and destination address.
  3. The SDK automatically pays the requested amount via transfer() and retries the request with a payment proof header.
  4. The premium data is returned to your agent. One function call, zero configuration.

For the full protocol specification, header formats, and code examples, see the dedicated x402 Paywall Protocol page.