Installation
x402 (Solana-focused)
npm install @x402/fetch @x402/core @x402/svm
Solana MPP
npm install @solana/mpp @solana/kit
Tempo MPP helper
x402 client pattern (PAYMENT-SIGNATURE)
Use @x402/fetch to automate challenge -> sign -> retry.
import { wrapFetchWithPayment } from '@x402/fetch';
import { x402Client } from '@x402/core/client';
import { registerExactSvmScheme } from '@x402/svm/exact/client';
const client = new x402Client();
registerExactSvmScheme(client, { signer: yourSolanaSigner });
const paidFetch = wrapFetchWithPayment(fetch, client);
const res = await paidFetch(
'https://wurkapi.fun/solana/agenttohuman?description=Review+this+copy&winners=5&perUser=0.025'
);
const data = await res.json();
// includes: jobId, secret, statusUrl
MPP Tempo pattern (Authorization: Payment ...)
Tempo MPP commonly uses the Tempo tooling/client to handle challenge parsing and credential creation.
import { execa } from 'execa';
const tempoBin = `${process.env.HOME}/.tempo/bin/tempo`;
const url =
'https://wurkapi.fun/mpp/xlikes?url=https%3A%2F%2Fx.com%2Fuser%2Fstatus%2F123&amount=40';
const { stdout } = await execa(tempoBin, ['request', '-t', '-X', 'GET', url]);
console.log(stdout);
MPP OpenAPI is canonical for route surface, but runtime aliases can still exist. Keep route naming explicit (xreposts, xcomments, xbookmarks, dex-rocket).
MPP Solana pattern
import { Mppx, solana } from '@solana/mpp/client';
const mppx = Mppx.create({
methods: [solana.charge({ signer, rpcUrl })],
polyfill: false,
});
const response = await mppx.fetch('https://wurkapi.fun/mpp-solana/test', {
method: 'GET',
});
const payload = await response.json();
Submissions retrieval pattern
- x402 basic jobs: often
/{network}/agenttohuman?action=view&secret=...
- MPP basic jobs: use
statusUrl or /submissions/agenttohuman?action=view&secret=...
const read = await fetch(
'https://wurkapi.fun/submissions/agenttohuman?action=view&secret=YOUR_SECRET'
);
const submissions = await read.json();
Reliability tips
- Keep rail-specific code paths isolated.
- Treat every
402 response as the current source of truth.
- Retry only with the latest challenge metadata.
- Persist
jobId, secret, and statusUrl immediately after success.