Dexter
Dexter
Docs

Access Pass

Access Pass lets a buyer pay once and make unlimited requests during a time window (e.g. 1 hour, 24 hours) — no per-request signatures.

When to Use It

  • Per-request signing creates too much friction (dashboards, polling, analytics)
  • The buyer makes repeated requests in a session
  • You want a wallet-native alternative to API keys or subscriptions

Server Example

import express from 'express';
import { x402AccessPass } from '@dexterai/x402/server';
 
const app = express();
 
app.use(
  '/api',
  x402AccessPass({
    payTo: 'YourSolanaAddress...',
    tiers: {
      '1h': '0.50',
      '24h': '2.00',
    },
    ratePerHour: '0.50',
    facilitatorUrl: 'https://x402.dexter.cash',
  }),
);
 
app.get('/api/data', (req, res) => {
  res.json({ ok: true, source: 'protected by access pass' });
});

Client Example

import { wrapFetch } from '@dexterai/x402/client';
 
const x402Fetch = wrapFetch(fetch, {
  walletPrivateKey: process.env.SOLANA_PRIVATE_KEY,
  accessPass: {
    preferTier: '1h',
    maxSpend: '1.00',
  },
});
 
const first = await x402Fetch('https://api.example.com/api/data');
const second = await x402Fetch('https://api.example.com/api/data');

The expected behavior is:

  1. the first request purchases the pass
  2. the server issues a JWT-like access token
  3. later requests reuse that token instead of signing a fresh payment

React Example

import { useAccessPass } from '@dexterai/x402/react';
 
export function AccessPassPanel({ solanaWallet }: { solanaWallet: unknown }) {
  const { tiers, isPassValid, purchasePass, fetch } = useAccessPass({
    wallets: { solana: solanaWallet },
    resourceUrl: 'https://api.example.com',
  });
 
  return (
    <div>
      {!isPassValid &&
        tiers?.map((tier) => (
          <button key={tier.id} onClick={() => purchasePass(tier.id)}>
            {tier.label} - ${tier.price}
          </button>
        ))}
      <button onClick={() => fetch('/api/data')}>Use pass</button>
    </div>
  );
}

Good Product Uses

  • premium dashboards
  • repeated data polling
  • research or analytics workspaces
  • any surface where the user will predictably make many requests in one session

On this page