All packages

x402_solana_pulse

PaulieB14
v1.1.0/1 downloads/Repository

Package ref

x402-solana-pulse@v1.1.0

Run package

CLI

Run db_out from the command line.

substreams run x402-solana-pulse@v1.1.0 db_out -e solana
Authenticate by running substreams auth or directly on thegraph.market (see docs).

README

x402 Solana Pulse

Real-time payment protocol analytics for Coinbase x402 on Solana

Track every x402 payment settlement on Solana. This Substreams detects when facilitators sponsor SPL Token TransferChecked settlements for HTTP 402 payments, extracting payer, recipient, mint, amount, facilitator, and memo from each transaction.

Companion to x402-base-pulse — same model, Solana native.


How It Works

The x402 protocol enables internet-native payments using the HTTP 402 status code. The Solana settlement path is defined by the SVM exact scheme:

  1. Server responds with HTTP 402 + payment requirements (mint, payTo, amount, feePayer)
  2. Client constructs a transaction containing a TransferChecked to the resource server's ATA, signs it, and returns the partially-signed tx
  3. Facilitator verifies the transaction, provides the final feePayer signature, and submits it to Solana
  4. Solana executes an SPL Token (or Token-2022) TransferChecked + SPL Memo instruction
  5. This Substreams captures those transactions by looking for the x402 SVM settlement shape

Detection heuristic

Solana has no on-chain FacilitatorRegistry. Instead, x402 settlements are identified by three signals observed together in a transaction:

  • Contains an SPL Token or Token-2022 TransferChecked instruction
  • Contains an SPL Memo instruction (payment reference / nonce)
  • Transaction fee_payer is distinct from the TransferChecked authority — i.e. the facilitator sponsors, the payer signs

Modules

ModuleKindDescription
map_x402_settlementsMapDetects x402 settlements in each Solana block and extracts payer / recipient / mint / amount / facilitator / memo
store_payer_volumeStoreAccumulates total amount spent per payer pubkey
store_payer_countStoreCounts payments per payer
store_recipient_volumeStoreAccumulates total received per resource server (ATA owner)
store_recipient_countStoreCounts payments per recipient
store_facilitator_volumeStoreAccumulates volume settled per facilitator
store_facilitator_countStoreCounts settlements per facilitator
store_facilitator_feesStoreAccumulates tx fees (lamports) paid per facilitator
store_first_seenStoreRecords first-seen block timestamp per payer / recipient / facilitator
map_payer_statsMapComputes payer leaderboards and averages
map_recipient_statsMapComputes resource server revenue stats
map_facilitator_statsMapComputes facilitator economics (volume, fees, counts)
db_outMapOutputs DatabaseChanges for the PostgreSQL sink

Programs Indexed

ProgramPubkey
SPL TokenTokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
SPL Token-2022TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
SPL Memo v2MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr
SPL Memo v1Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo

Quick Start

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

# GUI mode
substreams gui x402-solana-pulse map_x402_settlements \
  -e mainnet.sol.streamingfast.io:443 \
  -s 280000000

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

SQL Output

Tables

TableKeyDescription
settlementssignature-instruction_indexEvery settlement with payer, recipient, mint, amount, facilitator, fee, memo
payerspayer_addressAggregated spend and payment count per payer pubkey
recipientsrecipient_addressRevenue and payment count per resource server
facilitatorsfacilitator_addressVolume settled, settlement count, lamport fees per facilitator

Views

ViewDescription
daily_statsDaily protocol-wide volume, unique participants, fees
top_payersRanked by total spend
top_recipientsRanked by total revenue
facilitator_economicsVolume settled vs fee cost per facilitator
whale_paymentsPayments ≥ 100 USDC (atomic units)
recent_settlementsLatest 100 settlements

Build

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

References

Network

  • Chain: Solana mainnet
  • Endpoint: mainnet.sol.streamingfast.io:443
  • Initial block: 280,000,000 (adjustable)

Modules

Execution graph

13 modules
map

map_x402_settlements

Extracts x402 payment settlements on Solana by detecting the SVM `exact` scheme settlement shape: a transaction that contains an SPL Token (or Token-2022) TransferChecked instruction paired with an SPL Memo instruction, where the transaction fee payer is distinct from the TransferChecked authority (the facilitator sponsors, the payer signs). Per the x402 SVM exact scheme: https://github.com/coinbase/x402/blob/main/specs/schemes/exact/scheme_exact_svm.md

from #280000000
store

store_facilitator_count

Counts total settlements per facilitator. Key: {facilitator_pubkey}

from #280000000

Store value

int64

Update policy

add

store

store_facilitator_fees

Accumulates total tx fees (lamports) spent per facilitator. Key: {facilitator_pubkey}

from #280000000

Store value

bigint

Update policy

add

store

store_facilitator_volume

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

from #280000000

Store value

bigint

Update policy

add

store

store_first_seen

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

from #280000000

Store value

int64

Update policy

set_if_not_exists

store

store_payer_count

Counts total payments per payer. Key: {payer_pubkey}

from #280000000

Store value

int64

Update policy

add

store

store_payer_volume

Accumulates total payment volume per payer. Key: {payer_pubkey}

from #280000000

Store value

bigint

Update policy

add

store

store_recipient_count

Counts total payments per recipient. Key: {recipient_pubkey}

from #280000000

Store value

int64

Update policy

add

store

store_recipient_volume

Accumulates total revenue per recipient. Key: {recipient_pubkey}

from #280000000

Store value

bigint

Update policy

add