Pay for published Pollen aggregate data with x402 v2 and USDC on Base.
x402 v2 Payments
Pollen paid endpoints use x402 v2 with exact USDC payments on Base. The network identifier is eip155:8453.
Wire flow
- Request a paid route without a payment.
- Receive HTTP
402with a v2 challenge in the JSON body andPAYMENT-REQUIREDheader. - Select an accepted requirement and sign its advertised asset-transfer method. Current V2 advertises EIP-3009; future V3 advertises Permit2.
- Retry with the encoded payload in
PAYMENT-SIGNATURE. - On success, receive the data and settlement receipt in
PAYMENT-RESPONSE.
Legacy X-PAYMENT and X-PAYMENT-RESPONSE headers are not accepted.
Inspect a challenge
curl -i https://api.usepollen.xyz/gridThe challenge includes the resource, exact amount in atomic USDC units, Base
CAIP-2 network, USDC contract, pay-to address, timeout, and
extra.assetTransferMethod. Never infer the method from the address alone.
Official TypeScript SDK
import { x402Client } from '@x402/core/client'
import {
decodePaymentRequiredHeader,
encodePaymentSignatureHeader,
} from '@x402/core/http'
import { ExactEvmScheme } from '@x402/evm/exact/client'
import { privateKeyToAccount } from 'viem/accounts'
const account = privateKeyToAccount(process.env.PAYER_KEY as `0x${string}`)
const client = new x402Client().register(
'eip155:8453',
new ExactEvmScheme(account),
)
const first = await fetch('https://api.usepollen.xyz/grid')
const required = decodePaymentRequiredHeader(
first.headers.get('PAYMENT-REQUIRED')!,
)
const payment = await client.createPaymentPayload(required)
const paid = await fetch(required.resource.url, {
headers: {
'PAYMENT-SIGNATURE': encodePaymentSignatureHeader(payment),
},
})Keep payment keys in a secure signer. Do not place a funded private key in browser code or source control.
Permit2 approval for V3
When a challenge advertises assetTransferMethod: permit2, the buyer needs a
one-time Base USDC approval to canonical Permit2 before signing payment
witnesses. The official SDK exports getPermit2AllowanceReadParams to check
the allowance and createPermit2ApprovalTx to construct the approval. Inspect
the transaction and confirm its spender is canonical Permit2 before sending
it. Do not approve the Pollen vault, relayer, or x402 proxy directly.
The approval is not required for every prompt or API request. Each paid request still gets its own exact, receiver-bound Permit2 signature.
Empty-result protection
The relayer verifies and reserves an authorization before running the protected query, but it settles only after a successful data response. If the query has no privacy-qualified rows, Pollen returns HTTP 425, releases the reservation, omits PAYMENT-RESPONSE, and reports charged: false.
Revenue flow under current contracts
Successful settlement transfers the buyer's USDC into PollenSettlementV2, which deposits it into PollenTokenV2. The current token contract accounts for that USDC pro rata across all POLLEN holders. Weekly contribution scoring determines new POLLEN mint allocations; it does not limit revenue accrual to recently active contributors.
Future V3 settlement
The repository implements future V3 using official x402 exact with
assetTransferMethod: permit2. The canonical x402 proxy transfers buyer USDC
directly to the active-revenue vault, and the signed witness binds that vault
as the recipient. Buyers must first approve canonical Permit2 to spend Base
USDC; this is a one-time, buyer-paid Base transaction for the beta. V3 is not
deployed or live. After a separately approved cutover, new payments would fund
weekly Merkle claims for recent World ID-verified contributors who held POLLEN
at the epoch boundary. Existing V2 accrual remains claimable from
PollenTokenV2.
Before trusting a payment challenge, check both the exact payTo address and
asset transfer method. A V2 settlement address plus EIP-3009 means
durable-holder accrual. A verified V3 vault plus Permit2 means the active-holder
path. Product copy or a dashboard flag cannot replace those checks.