@@ -65,6 +65,55 @@ console.log(`Using remote facilitator at: ${facilitatorUrl}`);
6565app . use (
6666 paymentMiddleware (
6767 {
68+ // Multi-method endpoint - accepts multiple payment methods in preference order
69+ "GET /protected" : {
70+ accepts : [
71+ // 1. Base USDC EIP-3009 (highest preference)
72+ {
73+ payTo : EVM_PAYEE_ADDRESS ,
74+ scheme : "exact" ,
75+ price : "$0.001" ,
76+ network : EVM_NETWORK ,
77+ } ,
78+ // 2. Base WETH Permit2
79+ {
80+ payTo : EVM_PAYEE_ADDRESS ,
81+ scheme : "exact" ,
82+ network : EVM_NETWORK ,
83+ price : {
84+ amount : "1000" ,
85+ asset : "0x036CbD53842c5426634e7929541eC2318f3dCF7e" , // Base Sepolia USDC
86+ extra : {
87+ assetTransferMethod : "permit2" ,
88+ } ,
89+ } ,
90+ } ,
91+ // 3. Solana USDC (lowest preference)
92+ {
93+ payTo : SVM_PAYEE_ADDRESS ,
94+ scheme : "exact" ,
95+ price : "$0.001" ,
96+ network : SVM_NETWORK ,
97+ } ,
98+ ] ,
99+ extensions : {
100+ ...declareDiscoveryExtension ( {
101+ output : {
102+ example : {
103+ message : "Multi-method endpoint accessed successfully" ,
104+ timestamp : "2024-01-01T00:00:00Z" ,
105+ } ,
106+ schema : {
107+ properties : {
108+ message : { type : "string" } ,
109+ timestamp : { type : "string" } ,
110+ } ,
111+ required : [ "message" , "timestamp" ] ,
112+ } ,
113+ } ,
114+ } ) ,
115+ } ,
116+ } ,
68117 // Route-specific payment configuration
69118 "GET /protected-eip3009" : {
70119 accepts : {
@@ -157,7 +206,23 @@ app.use(
157206) ;
158207
159208/**
160- * Protected endpoint - requires payment to access
209+ * Multi-method protected endpoint - accepts multiple payment methods
210+ *
211+ * This endpoint demonstrates a resource protected by x402 payment middleware
212+ * that accepts multiple payment methods in preference order:
213+ * 1. Base USDC EIP-3009
214+ * 2. Base WETH Permit2
215+ * 3. Solana USDC
216+ */
217+ app . get ( "/protected" , ( req , res ) => {
218+ res . json ( {
219+ message : "Multi-method endpoint accessed successfully" ,
220+ timestamp : new Date ( ) . toISOString ( ) ,
221+ } ) ;
222+ } ) ;
223+
224+ /**
225+ * Protected EIP-3009 endpoint - requires payment to access
161226 *
162227 * This endpoint demonstrates a resource protected by x402 payment middleware.
163228 * Clients must provide a valid payment signature to access this endpoint.
@@ -238,6 +303,7 @@ app.listen(parseInt(PORT), () => {
238303║ SVM Payee: ${ SVM_PAYEE_ADDRESS } ║
239304║ ║
240305║ Endpoints: ║
306+ ║ • GET /protected (multi-method payment) ║
241307║ • GET /protected-eip3009 (EIP-3009 payment) ║
242308║ • GET /protected-svm (SVM payment) ║
243309║ • GET /protected-permit2 (Permit2 payment) ║
0 commit comments