Skip to content

Commit ab5a584

Browse files
Gaurav agarwalGaurav agarwal
authored andcommitted
Add Solana payment queries to x402 Data API documentation
1 parent 17edaa9 commit ab5a584

File tree

1 file changed

+168
-1
lines changed

1 file changed

+168
-1
lines changed

docs/examples/x402/x402-data-apis.md

Lines changed: 168 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ When you query the x402 Bazaar discovery endpoint, you receive detailed informat
181181
"totalRequests": 991
182182
}
183183
},
184-
"resource": "https://x402.lucyos.ai/x402/tools/analyze_token",
184+
"resource": "x402.lucyos.ai/x402/tools/analyze_token",
185185
"type": "http",
186186
"x402Version": 1
187187
}
@@ -416,15 +416,182 @@ where: {
416416
}
417417
```
418418

419+
## x402 Queries on Solana
420+
421+
x402 protocol also operates on Solana network. The following queries demonstrate how to query x402 payment data on Solana using Bitquery's GraphQL API. Solana uses a different address format and query structure compared to EVM chains.
422+
423+
### Example x402 Server on Solana
424+
425+
For the following Solana examples, we'll use this x402 server address:
426+
427+
**Server Address**: `DevFFyNWxZPtYLpEjzUnN1PFc9Po6PH7eZCi9f3tTkTw`
428+
429+
This is the Dexter • Crypto agent server address that accepts payments on Solana.
430+
431+
## Latest Payment to x402 Server on Solana
432+
433+
This query retrieves the most recent payments made to a specific x402 server on Solana. It's useful for monitoring server activity and tracking payment transactions.
434+
435+
You can run this query [here](https://ide.bitquery.io/Latest-Payment-to-specific-x402-server-taking-solana-payments).
436+
437+
```graphql
438+
{
439+
Solana {
440+
Transfers(
441+
limit: {count: 100}
442+
orderBy: {descending: Block_Time}
443+
where: {Transfer: {Receiver: {Owner: {is: "DevFFyNWxZPtYLpEjzUnN1PFc9Po6PH7eZCi9f3tTkTw"}}}}
444+
) {
445+
Transfer {
446+
Amount
447+
AmountInUSD
448+
Sender {
449+
Address
450+
Owner
451+
}
452+
Receiver {
453+
Address
454+
Owner
455+
}
456+
Currency {
457+
Symbol
458+
Name
459+
MintAddress
460+
}
461+
}
462+
Instruction {
463+
Program {
464+
Method
465+
}
466+
}
467+
Block {
468+
Time
469+
}
470+
Transaction {
471+
Signature
472+
}
473+
}
474+
}
475+
}
476+
```
477+
478+
### Query Explanation
479+
480+
- **`Solana`**: Specifies the Solana network schema
481+
- **`Receiver: {Owner: {is: "..."}}`**: Filters transfers to the specific server owner address (Solana uses owner addresses instead of contract addresses)
482+
- **`orderBy: {descending: Block_Time}`**: Returns the most recent payments first
483+
- **`limit: {count: 100}`**: Retrieves up to 100 payment transactions
484+
- **`AmountInUSD`**: Shows the payment amount in USD equivalent
485+
- **`Instruction`**: Provides details about the Solana program instruction that executed the transfer
486+
487+
## Real-Time Payment Monitoring on Solana
488+
489+
You can monitor payments to a specific x402 server on Solana in real-time using GraphQL WebSocket subscriptions. This enables live tracking of payment activity without polling.
490+
491+
You can run this subscription [here](https://ide.bitquery.io/Real-Time---Solana-transfers-stream).
492+
493+
```graphql
494+
subscription {
495+
Solana {
496+
Transfers(
497+
where: {Transfer: {Receiver: {Owner: {is: "DevFFyNWxZPtYLpEjzUnN1PFc9Po6PH7eZCi9f3tTkTw"}}}}
498+
) {
499+
Transfer {
500+
Amount
501+
AmountInUSD
502+
Sender {
503+
Address
504+
Owner
505+
}
506+
Receiver {
507+
Address
508+
Owner
509+
}
510+
Currency {
511+
Symbol
512+
Name
513+
MintAddress
514+
}
515+
}
516+
Instruction {
517+
Program {
518+
Method
519+
}
520+
}
521+
Block {
522+
Time
523+
}
524+
Transaction {
525+
Signature
526+
}
527+
}
528+
}
529+
}
530+
```
531+
532+
### Subscription Explanation
533+
534+
- **`subscription`**: Uses [GraphQL subscription](https://docs.bitquery.io/docs/subscriptions/subscription) for real-time updates
535+
- **`Solana`**: Monitors the Solana network
536+
- **`Transfers`**: Listens for new transfer events matching the filter
537+
- The subscription will automatically push new payment transactions as they occur on-chain. Learn more about [real-time subscriptions](https://docs.bitquery.io/docs/subscriptions/)
538+
539+
## Payment Analytics for x402 Server on Solana
540+
541+
This query provides comprehensive payment analytics for a specific x402 server on Solana, including total volume, unique users, and transaction counts.
542+
543+
:::note Solana API Version
544+
For complete transfer history on Solana, we use the v1 Solana API because v2 Solana API only shows transfers from the last 8 hours. The v1 API provides complete transfer history for comprehensive analytics.
545+
:::
546+
547+
You can run this query [here](https://ide.bitquery.io/Payment-analytics-related-specific-x402-server-on-Solana).
548+
549+
```graphql
550+
{
551+
solana {
552+
transfers(
553+
date: {since: "2025-11-22"}
554+
receiverAddress: {is: "DevFFyNWxZPtYLpEjzUnN1PFc9Po6PH7eZCi9f3tTkTw"}
555+
currency: {is: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"}
556+
) {
557+
totalTransactions7days: count(uniq: signature)
558+
amount7days: amount(calculate: sum)
559+
totalUniqueUsers7days: count(uniq: sender_address)
560+
transactions24h: count(time: {since: "2025-11-28T00:00:00"})
561+
}
562+
}
563+
}
564+
```
565+
566+
### Query Explanation
567+
568+
- **`solana`**: Uses the v1 Solana API schema for complete historical data
569+
- **`date: {since: "2025-11-22"}`**: Analyzes payments since the specified date
570+
- **`receiverAddress: {is: "..."}`**: Filters for transfers to the specific server address
571+
- **`currency: {is: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"}`**: Filters for USDC payments (USDC mint address on Solana)
572+
- **`count(uniq: signature)`**: Counts unique transaction signatures
573+
- **`amount(calculate: sum)`**: Calculates total payment volume
574+
- **`count(uniq: sender_address)`**: Counts unique users who made payments
575+
- **`count(time: {since: "..."})`**: Conditional count for transactions in the last 24 hours
576+
577+
### Analytics Metrics Returned
578+
579+
- **`totalTransactions7days`**: Total number of payment transactions in the specified period
580+
- **`amount7days`**: Total payment amount received
581+
- **`totalUniqueUsers7days`**: Number of unique users who made payments
582+
- **`transactions24h`**: Number of transactions in the last 24 hours
583+
419584
## Related Documentation
420585

421586
- [Blockchain Networks](https://docs.bitquery.io/docs/blockchain/introduction) - Overview of supported blockchain networks
422587
- [Base Network Documentation](https://docs.bitquery.io/docs/blockchain/Base/) - Complete guide to querying Base blockchain data
588+
- [Solana Network Documentation](https://docs.bitquery.io/docs/blockchain/Solana/) - Complete guide to querying Solana blockchain data
423589
- [Ethereum Network Documentation](https://docs.bitquery.io/docs/blockchain/Ethereum/) - Query Ethereum blockchain data
424590
- [BSC Network Documentation](https://docs.bitquery.io/docs/blockchain/BSC/) - Query BSC blockchain data
425591
- [GraphQL Query Guide](https://docs.bitquery.io/docs/graphql/query) - Learn how to build GraphQL queries
426592
- [Real-time Subscriptions](https://docs.bitquery.io/docs/subscriptions/) - Monitor blockchain data in real-time
427593
- [Transfer API Documentation](https://docs.bitquery.io/docs/blockchain/Ethereum/transfers/erc20-token-transfer-api) - Query ERC-20 token transfers
594+
- [Solana Transfers](https://docs.bitquery.io/docs/blockchain/Solana/solana-transfers) - Query Solana token transfers
428595
- [GraphQL Filters](https://docs.bitquery.io/docs/graphql/filters) - Advanced filtering techniques
429596
- [GraphQL Metrics](https://docs.bitquery.io/docs/graphql/metrics) - Aggregation and calculation functions
430597
- [Datetime Queries](https://docs.bitquery.io/docs/graphql/datetime) - Time-based filtering and analysis

0 commit comments

Comments
 (0)