Overview
Validates payment proof from client without executing the blockchain transaction. Endpoint:POST https://facilitator.corbits.dev/verify
Purpose
This endpoint is called by resource server middleware to validate a payment attempt before settlement. The facilitator performs all validation checks but does NOT execute the on-chain transaction, making it a safe “dry-run” that confirms payment validity. The validation logic differs based on the blockchain:- Solana: Validates transaction structure, signatures, amounts, and fees without submitting to network
- EVM: Validates EIP-3009 authorization signatures, amounts, addresses, and nonce status without calling the token contract
Request Body
The x402 protocol version (must be an integer). Currently
1.Note: The x402Version field appears both at the top-level request and inside the payment payload (when using paymentHeader or paymentPayload). Both should be set to 1 and typically match.Base64-encoded JSON string containing the payment payload from the client’s
X-PAYMENT header.Note: Either paymentHeader OR paymentPayload must be provided. The paymentHeader will be automatically decoded to produce the Payment Payload Structure shown below.Pre-decoded payment payload object. Has the same structure as the decoded
paymentHeader (see Payment Payload Structure above).Note: Either paymentHeader OR paymentPayload must be provided. If both are provided, paymentPayload takes precedence and paymentHeader is ignored.The original payment requirements object (same structure as in
/accepts endpoint).Response
Whether the payment is valid.
true if payment passes all validation checks, false otherwise.Explanation if
isValid is false. Omitted when payment is valid.Common reasons:"Invalid transaction"(Solana: transaction structure or validation failed)"Payment authorized to wrong address"(EVM: recipient mismatch)"Incorrect payment amount"(EVM: amount mismatch)"Authorization not yet valid"(EVM: before validAfter timestamp)"Authorization expired"(EVM: after validBefore timestamp)"Invalid from address"(EVM: sender address invalid)"Authorization already used on-chain"(EVM: nonce already consumed)"Invalid signature"(EVM: EIP-712 signature verification failed)
Example Request (Solana)
Example Response (Valid)
Example Response (Invalid)
Usage in Middleware
The/verify endpoint is used by Hono middleware when verifyBeforeSettle is enabled. This validates the payment before processing the request:
- Client sends payment with request
- Middleware calls
/verifyto validate payment - If valid, your handler runs
- After handler completes, middleware calls
/settleto execute on-chain - Response sent to client
/verify - it calls /settle directly. The verify endpoint is primarily for manual validation or the Hono advanced flow.
Handler Behavior
When the facilitator receives a/verify request:
- Decodes payment header (if needed): Extracts payment payload from base64-encoded header
- Tries each handler: Calls
handleVerify()on registered handlers - First match wins: Uses the first handler that returns a non-null result
- Validates payment: Handler performs blockchain-specific validation
- Returns result: Validation status and reason (if invalid)
- Unlike
/settle, the/verifyendpoint does NOT submit any transactions to the blockchain - Handlers may optionally implement
handleVerify(). If a handler doesn’t implement verification, it will be skipped and the next handler will be tried - If a handler throws an exception during verification, the request will fail with HTTP 500 Internal Server Error
Solana Validation
The facilitator performs the following checks on Solana transactions:- Transaction Structure: Validates transaction has exactly 3 or 4 instructions (3 = no ATA creation needed, 4 = includes ATA creation)
- Fee Payer Verification: Ensures the facilitator’s public key is the fee payer
- Compute Unit Limit: Validates SetComputeUnitLimit instruction is present and parseable
- Compute Unit Price: Validates SetComputeUnitPrice instruction is present and parseable
- Transfer Amount: Verifies transfer amount matches
maxAmountRequiredexactly - Transfer Mint: Verifies token mint matches the required
asset - Transfer Destination: Verifies destination matches
payToaddress (associated token account)
"Invalid transaction" error message when any check fails, unlike EVM which provides specific error messages for each validation failure.
See Solana Payments for detailed validation logic.
EVM Validation
The facilitator performs the following checks on EVM authorizations:- Payload Structure: Validates required fields are present
- Address Validation: Ensures
fromaddress is valid - Signature Verification: Validates EIP-712 typed data signature
- Amount Check: Ensures
valuematchesmaxAmountRequired - Recipient Check: Ensures
tomatchespayToaddress - Time Validity: Checks current time is between
validAfterandvalidBefore - Nonce Check: Verifies nonce hasn’t been used on-chain
Verify vs Settle
| Aspect | /verify | /settle |
|---|---|---|
| Purpose | Validate payment | Validate AND execute payment |
| On-chain action | No transaction (EVM: read-only nonce check; Solana: offline only) | Submits transaction |
| Gas/fees | Not consumed | Consumed |
| Idempotent | Yes | No (EVM: nonce consumed; Solana: blockhash expires, can retry) |
| Return value | {isValid, invalidReason} | {success, error, txHash, networkId} |
| Use case | Pre-flight check | Actual payment |
HTTP Status Codes
The/verify endpoint uses the following HTTP status codes:
200 OK:
- Request was processed successfully
- Check the
isValidfield in the response body to determine if payment is valid - Both valid (
isValid: true) and invalid (isValid: false) payments return 200 status
- Invalid request format
- Missing required fields (e.g.,
x402Version,paymentRequirements) - Failed to decode payment header
- No handler found for the payment scheme/network combination
- Handler threw an exception during verification
- Unexpected errors during validation
Important: Most validation failures return HTTP 200 with
isValid: false in the response body. Only malformed requests return 400, and only unexpected server errors return 500.When to Use Verify
The/verify endpoint is useful when:
- Pre-flight validation: Check if a payment would succeed before committing it
- User feedback: Provide immediate feedback to users about payment validity
- Testing: Validate payment construction logic without consuming gas/fees
- Debugging: Diagnose payment issues without state-changing transactions
- Client constructs payment
- Middleware calls
/verifyto check validity - If valid, middleware calls
/settleto execute payment - If invalid, middleware returns 402 Payment Required
See Also
- POST /settle - Execute verified payments on-chain
- POST /accepts - Get enriched payment requirements
- Errors - Detailed error reference
- Solana Payments - Solana-specific details
- EVM Payments - EVM-specific details