Package Logo
x402-base-pulse
x402-base-pulse@v3.0.0
Total Downloads
4
Published
4 hours ago
Network
base base
Publisher
User Avatar PaulieB14

Readme

x402 Base Pulse

Real-time payment protocol analytics for Coinbase x402 on Base

Track every x402 payment settlement on Base. This Substreams detects when facilitators call transferWithAuthorization on USDC to settle HTTP 402 payments, extracting payer, recipient, amount, and facilitator data from each settlement.

v3.0.0 — Now gates EIP-3009 settlements through the on-chain FacilitatorRegistry, matching the x402-subgraph. Facilitator names, URLs, and active status are resolved from registry events.


How It Works

The x402 protocol enables internet-native payments using the HTTP 402 status code. When a client wants to access a paid resource:

  1. Server responds with HTTP 402 + payment requirements
  2. Client signs an EIP-3009 authorization
  3. Facilitator calls transferWithAuthorization on USDC to settle payment on-chain
  4. USDC emits AuthorizationUsed + Transfer events
  5. This Substreams captures those events and extracts settlement data
  6. FacilitatorRegistry gates EIP-3009 settlements — only registered facilitators are indexed

Modules

Module Kind Description
map_facilitator_registry_events Map Extracts FacilitatorAdded / FacilitatorRemoved events from the on-chain registry
store_facilitator_registry Store Maintains the set of registered facilitators with names and URLs
map_x402_settlements Map Pairs AuthorizationUsed + Transfer events, gated by facilitator registry
store_payer_volume Store Accumulates total USDC spent per payer
store_payer_count Store Counts payments per payer
store_recipient_volume Store Accumulates total USDC received per resource server
store_recipient_count Store Counts payments per recipient
store_facilitator_volume Store Accumulates total USDC volume per facilitator
store_facilitator_count Store Counts settlements per facilitator
store_facilitator_gas Store Tracks gas costs per facilitator
store_first_seen Store Records first-seen timestamp per payer, recipient, and facilitator
map_payer_stats Map Computes payer leaderboards and averages
map_recipient_stats Map Computes resource server revenue stats
map_facilitator_stats Map Computes facilitator economics with name, URL, and active status from registry
db_out Map Outputs DatabaseChanges for PostgreSQL sink

Contracts Indexed

Contract Address Events
USDC (Base) 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 AuthorizationUsed, Transfer
FacilitatorRegistry 0x67C75c4FD5BbbF5f6286A1874fe2d7dF0024Ebe8 FacilitatorAdded, FacilitatorRemoved
x402ExactPermit2Proxy 0x4020615294c913F045dc10f0a5cdEbd86c280001 Settled, SettledWithPermit
x402UptoPermit2Proxy 0x4020633461b2895a48930Ff97eE8fCdE8E520002 Settled, SettledWithPermit

Quick Start

# Stream settlements
substreams run x402-base-pulse map_x402_settlements \
  -e base-mainnet.streamingfast.io:443 \
  -s 29000000 -t +1000

# GUI mode
substreams gui x402-base-pulse map_x402_settlements \
  -e base-mainnet.streamingfast.io:443 \
  -s 29000000

# Sink to PostgreSQL
substreams-sink-sql run "psql://localhost/x402" \
  x402-base-pulse-v3.0.0.spkg \
  -e base-mainnet.streamingfast.io:443

SQL Output

Tables

Table Key Description
settlements tx_hash-log_index Every settlement with payer, recipient, amount, facilitator, gas
payers payer_address Aggregated spend and payment count per payer
recipients recipient_address Revenue and payment count per resource server
facilitators facilitator_address Name, URL, active status, volume settled, settlement count, total gas spent

Views

View Description
daily_stats Daily protocol-wide volume, unique participants, gas
top_payers Ranked by total USDC spent
top_recipients Ranked by total USDC received
facilitator_economics Name, active status, volume settled vs gas cost per facilitator
whale_payments Payments > $100 USDC
recent_settlements Latest 100 settlements

Build

cargo build --target wasm32-unknown-unknown --release
substreams pack substreams.yaml

References

Network

  • Chain: Base
  • Start Block: 25,000,000 (settlements), 30,011,612 (FacilitatorRegistry)
  • Endpoint: base-mainnet.streamingfast.io:443

Documentation

Modules

Maps icon
Maps

map
map_facilitator_registry_events

ce18b8477935fcefe9ad364e282f069b04e4dbf1
map map_facilitator_registry_events (
blocksf.ethereum.type.v2.Block
)  -> x402.v1.FacilitatorRegistryEvents

Extracts FacilitatorAdded and FacilitatorRemoved events from the on-chain FacilitatorRegistry contract. These events define which addresses are authorized x402 facilitators.

substreams gui x402-base-pulse@v3.0.0 map_facilitator_registry_events

map
map_x402_settlements

3f5f7de9c87faf94512469dca8a46f558aacd737
map map_x402_settlements (
)  -> x402.v1.Settlements

Extracts x402 payment settlements on Base by detecting EIP-3009 AuthorizationUsed events on the USDC contract. Filters EIP-3009 settlements to only include transactions where tx.from is a registered facilitator in the on-chain FacilitatorRegistry. Permit2 proxy settlements are self-identifying and not gated.

substreams gui x402-base-pulse@v3.0.0 map_x402_settlements

map
map_payer_stats

53afc89e7067b5c39177b7d2a6d6dac0b125969f
map map_payer_stats (
store_payer_volumeDELTAS<add,bigint>
store_payer_countGET<add,int64>
store_first_seenGET<set_if_not_exists,int64>
)  -> x402.v1.PayerStats

Computes real-time payer statistics by combining settlement data with accumulated store values.

substreams gui x402-base-pulse@v3.0.0 map_payer_stats

map
map_recipient_stats

6ed46f4c4ff48b3117e097fa44a7129263eadb03
map map_recipient_stats (
store_recipient_volumeDELTAS<add,bigint>
store_recipient_countGET<add,int64>
store_first_seenGET<set_if_not_exists,int64>
)  -> x402.v1.RecipientStats

Computes real-time recipient (resource server) revenue statistics.

substreams gui x402-base-pulse@v3.0.0 map_recipient_stats

map
map_facilitator_stats

5588164ac96df4798b3c7507efb31cd36bc4a927
map map_facilitator_stats (
store_facilitator_volumeDELTAS<add,bigint>
store_facilitator_gasGET<add,bigint>
store_first_seenGET<set_if_not_exists,int64>
)  -> x402.v1.FacilitatorStats

Computes facilitator economics: volume processed, gas spent, settlement count. Enriches with name and active status from the FacilitatorRegistry.

substreams gui x402-base-pulse@v3.0.0 map_facilitator_stats

map
db_out

aa132d7926dd16e1028c6f2dde74f3b946c66984
Default param : min_amount=0

Outputs database changes for PostgreSQL sink. Tables: settlements, payers, recipients, facilitators

substreams gui x402-base-pulse@v3.0.0 db_out

map
ethcommon:all_events

963652a247fd23d0823dde62d21ae54c783b6073
map ethcommon:all_events (
)  -> sf.substreams.ethereum.v1.Events

all_events gives you all the events in a block (from successful transactions), with basic block hash/number/timestamp and transaction hash

substreams gui x402-base-pulse@v3.0.0 ethcommon:all_events
Stores icon
Stores

store
store_facilitator_registry

04a24163f158cb3004962ca937043d459975c6ab
store <set,string> store_facilitator_registry (
)

Maintains the set of registered facilitators with their names. Key: facilitator address (lowercase). Value: "name|url" or empty if removed. Uses set policy — FacilitatorRemoved overwrites with empty string.

substreams gui x402-base-pulse@v3.0.0 store_facilitator_registry

store
store_payer_volume

074dfdbec39a378a3fd50b51de6754d5991581c3
store <add,bigint> store_payer_volume (
)

Accumulates total payment volume per payer address. Key: {payer_address}

substreams gui x402-base-pulse@v3.0.0 store_payer_volume

store
store_payer_count

5367bbbf7b3a53a028e67c101710ab1d7e3065e8
store <add,int64> store_payer_count (
)

Counts total payments per payer address. Key: {payer_address}

substreams gui x402-base-pulse@v3.0.0 store_payer_count

store
store_recipient_volume

79b3d815a2cf35b047c6023fe92ce0bbe0908ffd
store <add,bigint> store_recipient_volume (
)

Accumulates total revenue per recipient (resource server). Key: {recipient_address}

substreams gui x402-base-pulse@v3.0.0 store_recipient_volume

store
store_recipient_count

7f1e5d21da76353c887f5a4c480d5aeeca6aaddb
store <add,int64> store_recipient_count (
)

Counts total payments per recipient. Key: {recipient_address}

substreams gui x402-base-pulse@v3.0.0 store_recipient_count

store
store_facilitator_volume

c2c6d251080b113437efb8bb1c94de4af46d5e6b
store <add,bigint> store_facilitator_volume (
)

Accumulates total volume settled per facilitator. Key: {facilitator_address}

substreams gui x402-base-pulse@v3.0.0 store_facilitator_volume

store
store_facilitator_count

f4033c04e4bc6a0a03cfe110e470121e1a17670e
store <add,int64> store_facilitator_count (
)

Counts total settlements per facilitator. Key: {facilitator_address}

substreams gui x402-base-pulse@v3.0.0 store_facilitator_count

store
store_facilitator_gas

0c34d73d874de5f42f001aefd68ac76ed94b4248
store <add,bigint> store_facilitator_gas (
)

Accumulates total gas spent per facilitator. Key: {facilitator_address}

substreams gui x402-base-pulse@v3.0.0 store_facilitator_gas

store
store_first_seen

c0e686aec97caade1fc3feac35be36d0e0262975
store <set_if_not_exists,int64> store_first_seen (
)

Records first-seen block timestamp per entity. Key: payer:{addr}, recipient:{addr}, facilitator:{addr}

substreams gui x402-base-pulse@v3.0.0 store_first_seen
Block Indexes icon
Block Indexes

blockIndex
ethcommon:index_events

87255243f80f5d4755cd826ec57bf70696a4d7b6

index_events sets the following keys on the block:

  • Event signatures evt_sig:0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef (signature in hex, prefixed by 0x)
  • Event address evt_addr:0x0123456789abcdef0123456789abcdef01234567 (address in hex, prefixed by 0x)
substreams gui x402-base-pulse@v3.0.0 ethcommon:index_events
Protobuf

Protobuf Docs Explorer

sf.ethereum.type.v2
sf.ethereum.substreams.v1
x402.v1