Overview
Validates payment proof from client and executes the blockchain transaction. Endpoint:POST https://facilitator.corbits.dev/settle
Purpose
This endpoint is called by resource server middleware after receiving a payment attempt from a client. The facilitator validates the payment proof, executes the on-chain settlement, and returns the transaction hash. The validation and settlement logic differs based on the blockchain:- Solana: Validates and co-signs partially-signed transactions, then submits them to the network
- EVM: Validates EIP-3009 authorization signatures and calls
transferWithAuthorizationon the token contract
Request Body
The x402 protocol version. Currently
1.Base64-encoded JSON string containing the payment payload from the client’s
X-PAYMENT header.The original payment requirements object (same structure as in
/accepts endpoint).Response
Whether the payment settlement succeeded.
true if transaction was confirmed, false otherwise.Error message if
success is false. null on success.Blockchain transaction hash on success.
null on failure.Network identifier where the transaction was settled.
null on failure.Format:- Solana: x402 network identifier (e.g.,
"solana-devnet") - EVM: Numeric chain ID as string (e.g.,
"84532"for Base Sepolia)
Example Request (Solana)
Example Response (Success)
Example Response (Error)
Usage in Middleware
Resource servers typically call this endpoint through middleware:Handler Behavior
When the facilitator receives a/settle request:
- Decodes payment header: Extracts payment payload from base64-encoded header
- Tries each handler: Calls
handleSettle()on registered handlers - First match wins: Uses the first handler that returns a non-null result
- Validates payment: Handler performs blockchain-specific validation
- Executes settlement: Handler submits transaction to blockchain
- Waits for confirmation: Handler waits for on-chain confirmation
- Returns result: Transaction hash and success status returned
Solana Validation
The facilitator performs the following checks on Solana transactions:- Transaction Structure: Validates transaction has correct number of instructions (3 or 4)
- Fee Payer Verification: Ensures the facilitator’s public key is the fee payer
- Compute Budget: Validates compute unit limits and priority fees
- Transfer Instruction: Verifies correct token program, amount, recipient, and source account
- Security Checks: Prevents facilitator fund theft attempts
EVM Validation
The facilitator performs the following checks on EVM authorizations:- Payload Structure: Validates required fields are present
- Address Validation: Ensures
fromandtoaddresses are 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
- Token Contract Call: Executes
transferWithAuthorizationwith facilitator paying gas
Transaction Confirmation
The facilitator waits for different confirmation levels based on the blockchain: Solana:- Simulates transaction before sending to detect potential failures
- Sends transaction and polls
getSignatureStatusesfor confirmation status - Accepts either
confirmedORfinalizedcommitment level - Polls up to 30 times with 1-second intervals between checks
- Checks for both successful confirmation and transaction errors during polling
- Typical confirmation time: 1-5 seconds on normal network conditions
- Maximum wait time: 30 seconds before timing out
- Sends transaction and calls
waitForTransactionReceiptto wait for block inclusion - Verifies transaction receipt status is “success” (not just included in block)
- Typical confirmation time: 1-2 blocks (~12-30 seconds depending on chain)
- No explicit timeout configured (uses RPC provider defaults)
HTTP Status Codes
The/settle endpoint uses the following HTTP status codes:
200 OK:
- Request was processed successfully
- Check the
successfield in the response body to determine if settlement succeeded - Both successful settlements (
success: true) and validation failures (success: false) return 200 status
- Invalid request format
- Missing required fields (
paymentHeaderorpaymentRequirements) - Malformed JSON in request body
- Failed to decode payment header
- Handler threw an exception during settlement processing
- Blockchain RPC failure
- Unexpected errors during validation or execution
Important: Most validation and settlement errors return HTTP 200 with
success: false in the response body. Only malformed requests return 400, and only unexpected server errors return 500.See Also
- POST /accepts - Get enriched payment requirements
- Errors - Detailed error reference
- Solana Payments - Solana-specific details
- EVM Payments - EVM-specific details