Docs/ERC-1066-x402/Core Concepts

Core Concepts

Understand the fundamental concepts behind ERC-1066-x402: status codes, intent validation, policies, and the overall architecture.

Overview

ERC-1066-x402 provides a standardized way to validate and execute intents across multiple blockchain networks. It combines three key components:

Status Codes

Machine-readable codes that indicate validation results

Intent Validation

Pre-flight checks before executing transactions

Policies

Configurable rules for access control

Status Codes

ERC-1066-x402 uses standardized status codes based on the ERC-1066 specification. These codes map to HTTP status codes and provide machine-readable results for AI agents and autonomous systems.

Key Insight

The 0x54 → HTTP 402 mapping enables standardized payment flows. When an agent receives HTTP 402 with X-Payment-Required, it knows to request payment before retrying.
CodeNameCategoryHTTPDescriptionAgent Action
0x01SUCCESSSuccess200Intent validated or executed successfullyExecute immediately
0x11ALLOWEDSuccess200Intent is allowed by policyExecute immediately
0x10DISALLOWEDPolicy403Intent explicitly disallowed by policyDeny, inform user
0x54INSUFFICIENT_FUNDSPayment402Insufficient funds for transactionRequest payment
0x20TOO_EARLYTiming202Intent is valid but too early to executeRetry later
0x21TOO_LATETiming410Intent has expiredReject, expired
0x22NONCE_USEDReplay409Nonce already usedReject, replay detected
0x50TRANSFER_FAILEDExecution500Transfer execution failedRetry or investigate
0xA0INVALID_FORMATValidation400Invalid intent formatFix intent structure
0xA2UNSUPPORTED_CHAINNetwork421Unsupported chain or networkUse different chain
Showing 10 of 10 status codes

Intent Validation

Intent validation is the process of checking whether an intent can be executed before actually executing it. This pre-flight validation saves gas and provides clear feedback to agents.

Validation Flow

  1. 1Agent creates intent with sender, target, data, value, and nonce
  2. 2Intent is sent to gateway for validation
  3. 3Gateway calls validator contract with intent parameters
  4. 4Validator checks policy, balance, timing, and format
  5. 5Status code is returned and mapped to HTTP response
  6. 6Agent makes decision based on status code
validation_example.py
# Pre-flight validation
result = client.validate_intent(intent, chain_id=133717)

# Agent decision logic
if result.status == "0x01":  # SUCCESS
    client.execute_intent(intent, chain_id=133717)
elif result.status == "0x54":  # INSUFFICIENT_FUNDS
    request_payment()
elif result.status == "0x20":  # TOO_EARLY
    schedule_retry(result.retry_after)

Policies

Policies define the rules for intent validation. They can restrict spending limits, allowed chains, permitted assets, and other parameters.

Spending Limits

Set maximum amounts that can be transferred per transaction or per time period

Allowed Chains

Restrict intents to specific blockchain networks

Permitted Assets

Control which tokens or assets can be used in transactions

Time Windows

Define when intents are valid (validAfter, validBefore)

Architecture

ERC-1066-x402 follows a layered architecture with clear separation between on-chain and off-chain components.

On-Chain Components

  • IntentExecutor - Executes validated intents
  • BaseIntentValidator - Base contract for validation logic
  • PolicyRegistry - Stores and manages policies
  • StatusCodes - Library of standardized status codes

Off-Chain Components

  • Gateway Service - HTTP API for intent validation and execution
  • TypeScript SDK - Client library for TypeScript/JavaScript
  • Python SDK - Client library for Python
  • AI Agents - Autonomous systems using the SDKs