Loading...
Loading...
Validate and create x402 payment endpoint responses (HTTP 402 Payment Required). Use when the user asks to: (1) validate an x402 config or 402 response, (2) create/generate an x402 payment config, (3) build an HTTP 402 endpoint that returns payment requirements, (4) debug why an x402 config is invalid, (5) convert between x402 v1 and v2 formats, (6) check EVM/Solana addresses for x402, or (7) work with CAIP-2 network identifiers for payment configs. Triggers on keywords: x402, 402 payment, payment-required header, paywall config, CAIP-2 payment.
npx skill4agent add rawgroundbeef/x402lint x402lintx402lintpackages/x402lint/import { check } from './packages/x402lint/src/index'
const result = check({
body: configObject, // or parse from header
headers: { 'payment-required': base64String }
})
// result.valid - boolean
// result.errors - ValidationIssue[] (blocking)
// result.warnings - ValidationIssue[] (non-blocking)
// result.normalized - canonical v2 shape
// result.summary - display-ready per-accept entries with registry datacheck(response, { strict: true })validate(input)extractConfig(response){
"x402Version": 2,
"accepts": [
{
"scheme": "exact",
"network": "<CAIP-2 identifier>",
"amount": "<atomic units as string>",
"asset": "<token contract address>",
"payTo": "<recipient address with proper checksum>",
"maxTimeoutSeconds": 300
}
],
"resource": {
"url": "<the protected resource URL>",
"method": "GET"
}
}amount"1000000"networknamespace:reference"base"payToassetpayToassetmaxTimeoutSecondsresourceurl{ "network": "eip155:8453", "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" }{ "network": "eip155:84532", "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e" }{ "network": "eip155:43114", "asset": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E" }{ "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" }// Express/Node example
app.get('/api/premium', (req, res) => {
// Check for valid payment proof in request...
// If no payment, return 402:
res.status(402).json({
x402Version: 2,
accepts: [{
scheme: "exact",
network: "eip155:8453",
amount: "1000000",
asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
payTo: "0xYourChecksummedAddress",
maxTimeoutSeconds: 300
}],
resource: {
url: "https://yourapi.com/api/premium",
method: "GET"
}
})
})Payment-Requiredcheck()validate()result.errorscodefieldmessagefixINVALID_NETWORK_FORMAT"eip155:8453""base"INVALID_AMOUNT"1.5"1000000BAD_EVM_CHECKSUMMISSING_PAY_TOMISSING_ASSETLEGACY_FORMATnormalize()fix