Dexter
Dexter
Docs

For Clients

When you make an x402 payment through the Dexter facilitator, the settlement response may include sponsored recommendations — relevant tools or APIs suggested by advertisers. The SDK provides typed helpers to extract and act on these recommendations.

Node.js

import {
  wrapFetch,
  getSponsoredRecommendations,
  fireImpressionBeacon,
} from '@dexterai/x402/client';
 
const x402Fetch = wrapFetch(fetch, {
  walletPrivateKey: process.env.SOLANA_PRIVATE_KEY,
});
 
const response = await x402Fetch('https://api.example.com/data');
 
const recs = getSponsoredRecommendations(response);
if (recs) {
  for (const rec of recs) {
    console.log(`${rec.sponsor}: ${rec.description} -- ${rec.resourceUrl}`);
  }
  // Confirm delivery to the ad network
  await fireImpressionBeacon(response);
}

React

The useX402Payment hook automatically populates sponsoredRecommendations after a payment completes and fires the impression beacon.

import { useX402Payment } from '@dexterai/x402/react';
 
function DataView() {
  const {
    fetch,
    isLoading,
    sponsoredRecommendations,
  } = useX402Payment({ wallets });
 
  return (
    <div>
      <button onClick={() => fetch('/api/data')} disabled={isLoading}>
        Fetch Data
      </button>
 
      {sponsoredRecommendations?.map((rec, i) => (
        <a key={i} href={rec.resourceUrl}>
          {rec.sponsor}: {rec.description}
        </a>
      ))}
    </div>
  );
}

Full Extension Data

For advanced use cases, getSponsoredAccessInfo() returns the complete extension payload including tracking URLs:

import { getSponsoredAccessInfo } from '@dexterai/x402/client';
 
const info = getSponsoredAccessInfo(response);
if (info) {
  console.log('Delivered:', info.delivered);
  console.log('Recommendations:', info.recommendations.length);
  console.log('Impression beacon:', info.tracking?.impressionBeacon);
  console.log('Conversion resource:', info.tracking?.conversionResource);
}

Types

All types are re-exported from @dexterai/x402-ads-types:

import type {
  SponsoredRecommendation,
  SponsoredAccessSettlementInfo,
} from '@dexterai/x402/client';
 
interface SponsoredRecommendation {
  resourceUrl: string;    // The URL to call
  description: string;    // Agent-readable description
  sponsor: string;        // Brand name
  bazaarId?: string;      // Bazaar catalog ID
  price?: string;         // Cost in atomic units
  currency?: string;      // e.g., "USDC"
}

How Conversions Work

If an agent sees a recommendation and calls the suggested resource, the facilitator automatically detects this and records a conversion. No extra code is needed — the correlation is based on:

  1. Same payer wallet
  2. Called the recommended resource URL
  3. Within a 30-minute window of seeing the recommendation
  4. Both transactions are on-chain, providing cryptographic proof

On this page