All packages

x402-base-pulse

PaulieB14
This is not the latest version — go to v3.3.0
v3.0.0/94 downloads/Repository

Package ref

x402-base-pulse@v3.0.0

Run package

CLI

Run db_out from the command line.

substreams run x402-base-pulse@v3.0.0 db_out -e base
Authenticate by running substreams auth or directly on thegraph.market (see docs).

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

ModuleKindDescription
map_facilitator_registry_eventsMapExtracts FacilitatorAdded / FacilitatorRemoved events from the on-chain registry
store_facilitator_registryStoreMaintains the set of registered facilitators with names and URLs
map_x402_settlementsMapPairs AuthorizationUsed + Transfer events, gated by facilitator registry
store_payer_volumeStoreAccumulates total USDC spent per payer
store_payer_countStoreCounts payments per payer
store_recipient_volumeStoreAccumulates total USDC received per resource server
store_recipient_countStoreCounts payments per recipient
store_facilitator_volumeStoreAccumulates total USDC volume per facilitator
store_facilitator_countStoreCounts settlements per facilitator
store_facilitator_gasStoreTracks gas costs per facilitator
store_first_seenStoreRecords first-seen timestamp per payer, recipient, and facilitator
map_payer_statsMapComputes payer leaderboards and averages
map_recipient_statsMapComputes resource server revenue stats
map_facilitator_statsMapComputes facilitator economics with name, URL, and active status from registry
db_outMapOutputs DatabaseChanges for PostgreSQL sink

Contracts Indexed

ContractAddressEvents
USDC (Base)0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913AuthorizationUsed, Transfer
FacilitatorRegistry0x67C75c4FD5BbbF5f6286A1874fe2d7dF0024Ebe8FacilitatorAdded, FacilitatorRemoved
x402ExactPermit2Proxy0x4020615294c913F045dc10f0a5cdEbd86c280001Settled, SettledWithPermit
x402UptoPermit2Proxy0x4020633461b2895a48930Ff97eE8fCdE8E520002Settled, 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

TableKeyDescription
settlementstx_hash-log_indexEvery settlement with payer, recipient, amount, facilitator, gas
payerspayer_addressAggregated spend and payment count per payer
recipientsrecipient_addressRevenue and payment count per resource server
facilitatorsfacilitator_addressName, URL, active status, volume settled, settlement count, total gas spent

Views

ViewDescription
daily_statsDaily protocol-wide volume, unique participants, gas
top_payersRanked by total USDC spent
top_recipientsRanked by total USDC received
facilitator_economicsName, active status, volume settled vs gas cost per facilitator
whale_paymentsPayments > $100 USDC
recent_settlementsLatest 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

Modules

Execution graph

17 modules
map

map_facilitator_registry_events

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

from #30011612
map

map_x402_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.

from #25000000
store

store_facilitator_count

Counts total settlements per facilitator. Key: {facilitator_address}

from #25000000

Store value

int64

Update policy

add

store

store_facilitator_gas

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

from #25000000

Store value

bigint

Update policy

add

store

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.

from #30011612

Store value

string

Update policy

set

store

store_facilitator_volume

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

from #25000000

Store value

bigint

Update policy

add

store

store_first_seen

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

from #25000000

Store value

int64

Update policy

set_if_not_exists

store

store_payer_count

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

from #25000000

Store value

int64

Update policy

add

store

store_payer_volume

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

from #25000000

Store value

bigint

Update policy

add

store

store_recipient_count

Counts total payments per recipient. Key: {recipient_address}

from #25000000

Store value

int64

Update policy

add

store

store_recipient_volume

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

from #25000000

Store value

bigint

Update policy

add

Show 2 dependencies
map

ethcommon:all_events

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

Output

sf.substreams.ethereum.v1.Events

blockIndex

ethcommon:index_events

`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)

Output

sf.substreams.index.v1.Keys