Usage
Configuration
Return Value
Example Implementation
Payment Flows
Standard Wallet (no session)
x402Fetchmakes initial request- Server returns
402withPAYMENT-REQUIREDheader - Hook parses requirement, validates against
maxPaymentAmountandallowedRecipients - Signs SNIP-12 typed data locally via
signTypedData()(no on-chain transaction) - Retries with
X-PAYMENTheader containing the signed payload - Facilitator settles the payment on-chain
Session Key (automatic payments)
- Same flow, but signs using session key via
executeTransactionWithSession() - Payment executes on-chain immediately (pre-signed)
lastTxHashcontains the actual transaction hash- No owner signature needed — session key handles it
Security
maxPaymentAmountenforced before signing — prevents overpaymentallowedRecipientswhitelist — prevents payment to unauthorized addresses- Only
"exact"scheme and"starknet-mainnet"network accepted - Only USDC asset accepted (native USDC contract address validated)
- Amount validation uses BigInt math (no float precision issues)
Standard wallet payments return
lastTxHash: null because the signature is SNIP-12 off-chain — the facilitator settles on-chain later. Session payments return the actual transaction hash.