Skip to main content
The State Machine defines how an ad moves through verified stages of engagement — exposure, click, and conversion.
It ensures each serve_token transitions in one direction only, making billing and verification deterministic.

1. TL;DR

The AIP state machine controls how an ad progresses from exposure to conversion, ensuring no event is double-counted or reversed.

2. Why it matters

In legacy ad systems, duplicate impressions, repeated clicks, or delayed conversions often lead to inaccurate billing.
AIP eliminates this by applying finite state logic — each serve token can only exist in one state at a time, with defined transitions.
This makes every transaction:
  • Verifiable
  • Reproducible
  • Auditable

3. State diagram

Each state represents a billing condition. Once a token moves forward, it cannot regress (e.g., a converted ad cannot revert to “clicked”).

4. State transitions

FromToTriggerVerified By
PENDINGEXPOSEDcpx_exposure eventPlatform
EXPOSEDCLICKEDcpc_click eventPlatform + Ad Network
CLICKEDCONVERTEDcpa_conversion eventBrand Agent + Ad Network
EXPOSEDFINALIZEDTimeout (no click)Ad Network
CLICKEDFINALIZEDTimeout (no conversion)Ad Network
CONVERTEDFINALIZEDLedger processedAd Network
Any StateREFUNDEDRefund requestAd Network
AIP defines strict expiration windows:
  • Exposure → Click: 30 minutes
  • Click → Conversion: 24 hours
  • Settlement: Once per billing cycle

5. Example lifecycle

  1. Auction completes, serve_token generated → state = PENDING
  2. Platform logs an exposure → state = EXPOSED
  3. User clicks the ad → state = CLICKED
  4. User completes signup → state = CONVERTED
  5. At the end of the billing cycle → state = FINALIZED
Each transition is timestamped and recorded in the ledger.

6. How it prevents double billing

Because every event must follow a defined transition:
  • Two exposures for the same token are ignored.
  • A click without prior exposure is invalid.
  • A conversion without a verified click is rejected.
This guarantees billing integrity and logical consistency across all participants.

7. Ledger integration

Every final state is logged to the Ad Network ledger, ensuring:
  • Immutable event chains
  • Deterministic reconciliation
  • Verified payout records
{
  "serve_token": "stk_abcxyz123",
  "session_id": "s_001",
  "platform_id": "pf_chatapp",
  "agent_id": "ag_123",
  "auction_id": "auc_981",
  "state": "FINALIZED",
  "final_unit": "CPA",
  "final_charge": "10.00",
  "currency": "USD",
  "timestamps": {
    "auction": "2025-11-11T18:00:00Z",
    "exposure": "2025-11-11T18:00:00Z",
    "click": "2025-11-11T18:02:00Z",
    "conversion": "2025-11-11T18:30:00Z",
    "finalized": "2025-11-11T19:00:00Z"
  }
}
For complete ledger schema, see: Ledger Record Schema

8. Guarantees

  • State transitions are one-directional and irreversible.
  • Each transition is signed by at least one verifier.
  • Expired states auto-close for settlement.
  • Finalized ledgers are immutable and audit-safe.

Summary

The AIP state machine enforces a single source of truth for every ad — preventing duplicates, enforcing fairness, and keeping the ecosystem financially clean.