@x402x/facilitator-sdk 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,307 @@
1
+ # @x402x/facilitator-sdk
2
+
3
+ SchemeNetworkFacilitator SDK for x402x - enables router settlement with official x402 protocol.
4
+
5
+ ## Overview
6
+
7
+ This package provides a complete implementation of the `SchemeNetworkFacilitator` interface that enables atomic settlement using SettlementRouter contracts. It supports:
8
+
9
+ - **Atomic Settlement**: Single transaction completes verification, transfer, and hook execution
10
+ - **Multi-Party Support**: Facilitator fees and merchant payments in one atomic operation
11
+ - **Hook Integration**: Extensible business logic execution during settlement
12
+ - **v2 Compatibility**: Uses official `@x402/*` v2 packages only
13
+ - **Type Safety**: Full TypeScript support with comprehensive validation
14
+
15
+ ## Features
16
+
17
+ - ✅ Implements `SchemeNetworkFacilitator` interface from `@x402/core`
18
+ - ✅ SettlementRouter contract integration with viem
19
+ - ✅ Comprehensive parameter validation and security checks
20
+ - ✅ Support for both SettlementRouter and standard modes
21
+ - ✅ Gas optimization and configurable limits
22
+ - ✅ Multi-network support with dynamic RPC URLs
23
+ - ✅ Full error handling and mapping
24
+ - ✅ Workspace-only package (private, not published to npm)
25
+
26
+ ## Installation
27
+
28
+ This is a workspace-only package. Install within the x402-exec monorepo:
29
+
30
+ ```bash
31
+ pnpm install
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```typescript
37
+ import { createRouterSettlementFacilitator } from "@x402x/facilitator_v2";
38
+
39
+ // Create facilitator instance
40
+ const facilitator = createRouterSettlementFacilitator({
41
+ signer: "0x1234567890123456789012345678901234567890",
42
+ allowedRouters: {
43
+ "eip155:84532": ["0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"], // Base Sepolia
44
+ "eip155:8453": ["0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"], // Base
45
+ },
46
+ rpcUrls: {
47
+ "eip155:84532": "https://sepolia.base.org",
48
+ "eip155:8453": "https://mainnet.base.org",
49
+ },
50
+ });
51
+
52
+ // Verify payment without executing
53
+ const verification = await facilitator.verify(paymentPayload, paymentRequirements);
54
+ if (!verification.isValid) {
55
+ console.error("Payment verification failed:", verification.invalidReason);
56
+ return;
57
+ }
58
+
59
+ // Execute settlement atomically
60
+ const settlement = await facilitator.settle(paymentPayload, paymentRequirements);
61
+ if (settlement.success) {
62
+ console.log("Settlement successful:", {
63
+ transaction: settlement.transaction,
64
+ network: settlement.network,
65
+ payer: settlement.payer,
66
+ });
67
+ } else {
68
+ console.error("Settlement failed:", settlement.errorReason);
69
+ }
70
+ ```
71
+
72
+ ## Configuration
73
+
74
+ ### FacilitatorConfig
75
+
76
+ ```typescript
77
+ interface FacilitatorConfig {
78
+ // Required
79
+ signer: Address; // Facilitator signer address
80
+
81
+ // Optional security
82
+ allowedRouters?: Record<string, string[]>; // Whitelisted routers per network
83
+ rpcUrls?: Record<string, string>; // Custom RPC URLs per network
84
+
85
+ // Optional gas settings
86
+ gasConfig?: {
87
+ maxGasLimit: bigint; // Maximum gas limit (default: 5M)
88
+ gasMultiplier: number; // Gas multiplier for safety (default: 1.2)
89
+ };
90
+
91
+ // Optional fee settings
92
+ feeConfig?: {
93
+ minFee: string; // Minimum facilitator fee
94
+ maxFee: string; // Maximum facilitator fee
95
+ };
96
+
97
+ // Optional timeouts
98
+ timeouts?: {
99
+ verify: number; // Verification timeout in ms (default: 5000)
100
+ settle: number; // Settlement timeout in ms (default: 30000)
101
+ };
102
+ }
103
+ ```
104
+
105
+ ## API Reference
106
+
107
+ ### RouterSettlementFacilitator
108
+
109
+ Implements `SchemeNetworkFacilitator` interface:
110
+
111
+ #### Properties
112
+
113
+ - `scheme`: "exact" - Payment scheme identifier
114
+ - `caipFamily`: "eip155:\*" - Supported network families
115
+
116
+ #### Methods
117
+
118
+ ##### `getExtra(network: string): Record<string, unknown> | undefined`
119
+
120
+ Returns scheme-specific metadata for the given network.
121
+
122
+ ##### `getSigners(network: string): string[]`
123
+
124
+ Returns list of signer addresses for the given network.
125
+
126
+ ##### `verify(payload, requirements): Promise<VerifyResponse>`
127
+
128
+ Validates payment without executing settlement.
129
+
130
+ **Returns:**
131
+
132
+ ```typescript
133
+ interface VerifyResponse {
134
+ isValid: boolean;
135
+ invalidReason?: string;
136
+ payer?: string;
137
+ }
138
+ ```
139
+
140
+ ##### `settle(payload, requirements): Promise<SettleResponse>`
141
+
142
+ Executes payment settlement on-chain.
143
+
144
+ **Returns:**
145
+
146
+ ```typescript
147
+ interface SettleResponse {
148
+ success: boolean;
149
+ transaction: string;
150
+ network: string;
151
+ payer?: string;
152
+ errorReason?: string;
153
+ }
154
+ ```
155
+
156
+ ### SettlementRouter Integration
157
+
158
+ #### `createPublicClientForNetwork(network, rpcUrls?): PublicClient`
159
+
160
+ Creates a viem public client for the specified network.
161
+
162
+ #### `createWalletClientForNetwork(network, signer, rpcUrls?): WalletClient`
163
+
164
+ Creates a viem wallet client for the specified network.
165
+
166
+ #### `settleWithSettlementRouter(requirements, payload, config, options?): Promise<SettleResponse>`
167
+
168
+ Direct SettlementRouter settlement execution.
169
+
170
+ ### Validation Utilities
171
+
172
+ #### `validateSettlementExtra(extra): SettlementExtraCore`
173
+
174
+ Validates and parses settlement extra parameters.
175
+
176
+ #### `validateSettlementRouter(network, router, allowedRouters?, networkConfig?): Address`
177
+
178
+ Validates SettlementRouter address against whitelist and network config.
179
+
180
+ #### `validateNetwork(network): Network`
181
+
182
+ Validates network string format.
183
+
184
+ #### `isValidEthereumAddress(address): boolean`
185
+
186
+ Checks if string is a valid Ethereum address.
187
+
188
+ ## Error Handling
189
+
190
+ The package provides custom error types:
191
+
192
+ - `FacilitatorValidationError`: Parameter validation failures
193
+ - `SettlementRouterError`: Contract interaction failures
194
+
195
+ All errors include descriptive messages for debugging.
196
+
197
+ ## Settlement Mode Detection
198
+
199
+ The package automatically detects SettlementRouter mode using:
200
+
201
+ ```typescript
202
+ import { isSettlementMode } from "@x402x/facilitator_v2";
203
+
204
+ if (isSettlementMode(paymentRequirements)) {
205
+ // Use SettlementRouter flow
206
+ } else {
207
+ // Use standard EIP-3009 flow
208
+ }
209
+ ```
210
+
211
+ ## Examples
212
+
213
+ ### Basic SettlementRouter Usage
214
+
215
+ ```typescript
216
+ import { createRouterSettlementFacilitator } from "@x402x/facilitator_v2";
217
+
218
+ const facilitator = createRouterSettlementFacilitator({
219
+ signer: "0xYourFacilitatorAddress",
220
+ });
221
+
222
+ // Payment requirements with SettlementRouter extra
223
+ const requirements = {
224
+ scheme: "exact",
225
+ network: "eip155:84532",
226
+ maxAmountRequired: "1000000", // 1 USDC (6 decimals)
227
+ asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
228
+ payTo: "0xSettlementRouterAddress",
229
+ extra: {
230
+ settlementRouter: "0xSettlementRouterAddress",
231
+ salt: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
232
+ payTo: "0xMerchantAddress",
233
+ facilitatorFee: "100000", // 0.1 USDC
234
+ hook: "0xTransferHookAddress",
235
+ hookData: "0x",
236
+ name: "USD Coin",
237
+ version: "3",
238
+ },
239
+ };
240
+
241
+ const settlement = await facilitator.settle(paymentPayload, requirements);
242
+ ```
243
+
244
+ ### Multi-Network Configuration
245
+
246
+ ```typescript
247
+ const facilitator = createRouterSettlementFacilitator({
248
+ signer: "0xYourFacilitatorAddress",
249
+ allowedRouters: {
250
+ "eip155:84532": ["0xBaseSepoliaRouter"],
251
+ "eip155:8453": ["0xBaseRouter"],
252
+ "eip155:137": ["0xPolygonRouter"],
253
+ },
254
+ rpcUrls: {
255
+ "eip155:84532": "https://sepolia.base.org",
256
+ "eip155:8453": "https://mainnet.base.org",
257
+ "eip155:137": "https://polygon-rpc.com",
258
+ },
259
+ gasConfig: {
260
+ maxGasLimit: 3_000_000n,
261
+ gasMultiplier: 1.1,
262
+ },
263
+ });
264
+ ```
265
+
266
+ ## Development
267
+
268
+ ```bash
269
+ # Install dependencies
270
+ pnpm install
271
+
272
+ # Build package
273
+ pnpm build
274
+
275
+ # Run tests
276
+ pnpm test
277
+
278
+ # Run tests in watch mode
279
+ pnpm test:watch
280
+
281
+ # Generate coverage report
282
+ pnpm test:coverage
283
+
284
+ # Lint code
285
+ pnpm lint
286
+
287
+ # Format code
288
+ pnpm format
289
+ ```
290
+
291
+ ## Dependencies
292
+
293
+ - `@x402/core`: Official x402 v2 core types
294
+ - `@x402/evm`: Official x402 v2 EVM utilities
295
+ - `@x402x/core_v2`: x402x core utilities (workspace)
296
+ - `viem`: Ethereum TypeScript library
297
+
298
+ ## License
299
+
300
+ Apache-2.0 - see LICENSE file for details.
301
+
302
+ ## Related Packages
303
+
304
+ - `@x402x/core_v2`: Core utilities and types
305
+ - `@x402x/express_v2`: Express middleware wrapper
306
+ - `@x402x/hono_v2`: Hono middleware wrapper
307
+ - `@x402x/fetch_v2`: Fetch client wrapper
@@ -0,0 +1,189 @@
1
+ import { SchemeNetworkFacilitator, PaymentPayload, PaymentRequirements, SettleResponse } from '@x402/core/types';
2
+ export { PaymentPayload, PaymentRequirements, SchemeNetworkFacilitator, SettleResponse } from '@x402/core/types';
3
+ import { FacilitatorConfig, VerifyResponse, SettlementRouterParams, Address as Address$1, NetworkConfig, SettlementExtraCore, Network } from '@x402x/extensions';
4
+ export { Address, FacilitatorConfig, FacilitatorValidationError, Network, NetworkConfig, SETTLEMENT_ROUTER_ABI, SettlementExtraCore, SettlementRouterError, SettlementRouterParams, VerifyResponse, getNetworkConfig, isSettlementMode, parseSettlementExtra } from '@x402x/extensions';
5
+ import { PublicClient, Address, Transport, WalletClient, Hex } from 'viem';
6
+
7
+ /**
8
+ * RouterSettlementFacilitator implementation
9
+ *
10
+ * Implements SchemeNetworkFacilitator interface using SettlementRouter for atomic settlement
11
+ */
12
+
13
+ /**
14
+ * SchemeNetworkFacilitator implementation using SettlementRouter
15
+ *
16
+ * Provides atomic settlement with hooks and facilitator fee handling
17
+ */
18
+ declare class RouterSettlementFacilitator implements SchemeNetworkFacilitator {
19
+ readonly scheme = "exact";
20
+ readonly caipFamily = "eip155:*";
21
+ private readonly config;
22
+ constructor(config: FacilitatorConfig);
23
+ /**
24
+ * Get scheme-specific extra data for responses
25
+ */
26
+ getExtra(network: string): Record<string, unknown> | undefined;
27
+ /**
28
+ * Get signer addresses for the network
29
+ * Derives from privateKey if signer address not explicitly provided
30
+ */
31
+ getSigners(network: string): string[];
32
+ /**
33
+ * Verify payment payload without executing settlement
34
+ */
35
+ verify(payload: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
36
+ /**
37
+ * Settle payment by executing blockchain transaction
38
+ */
39
+ settle(payload: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
40
+ /**
41
+ * Validate basic payload and requirements
42
+ */
43
+ private validateBasicPayload;
44
+ /**
45
+ * Verify payment for SettlementRouter mode
46
+ */
47
+ private verifySettlementRouter;
48
+ /**
49
+ * Verify payment for standard mode (fallback)
50
+ */
51
+ private verifyStandard;
52
+ /**
53
+ * Settle payment using SettlementRouter
54
+ */
55
+ private settleWithRouter;
56
+ /**
57
+ * Settle payment using standard method (fallback)
58
+ */
59
+ private settleStandard;
60
+ }
61
+ /**
62
+ * Factory function to create RouterSettlementFacilitator instance
63
+ */
64
+ declare function createRouterSettlementFacilitator(config: FacilitatorConfig): RouterSettlementFacilitator;
65
+
66
+ /**
67
+ * SettlementRouter integration utilities for @x402x/facilitator-sdk
68
+ *
69
+ * Provides direct viem integration with SettlementRouter contracts
70
+ */
71
+
72
+ /**
73
+ * Create viem public client for a network
74
+ *
75
+ * @param network - Network identifier (V1 name or V2 CAIP-2 format)
76
+ * @param rpcUrls - Optional custom RPC URLs
77
+ */
78
+ declare function createPublicClientForNetwork(network: string, rpcUrls?: Record<string, string>): PublicClient;
79
+ /**
80
+ * Create viem wallet client for a network
81
+ * If privateKey is provided, uses local signing (works with standard RPC providers)
82
+ * If only signer address is provided, requires node to have the account unlocked
83
+ */
84
+ declare function createWalletClientForNetwork(network: string, signer?: Address, rpcUrls?: Record<string, string>, transport?: Transport, privateKey?: string): WalletClient;
85
+ /**
86
+ * Calculate gas limit for SettlementRouter transaction
87
+ */
88
+ declare function calculateGasLimit(baseFee: string, facilitatorFee: string, gasMultiplier?: number): bigint;
89
+ /**
90
+ * Check if a settlement has already been executed
91
+ */
92
+ declare function checkIfSettled(publicClient: PublicClient, router: Address, contextKey: Hex): Promise<boolean>;
93
+ /**
94
+ * Execute settlement via SettlementRouter
95
+ */
96
+ declare function executeSettlementWithRouter(walletClient: WalletClient, params: SettlementRouterParams, config?: {
97
+ gasLimit?: bigint;
98
+ gasMultiplier?: number;
99
+ }): Promise<Hex>;
100
+ /**
101
+ * Wait for transaction receipt and extract relevant data
102
+ */
103
+ declare function waitForSettlementReceipt(publicClient: PublicClient, txHash: Hex, timeoutMs?: number): Promise<{
104
+ success: boolean;
105
+ blockNumber?: bigint;
106
+ gasUsed?: bigint;
107
+ effectiveGasPrice?: bigint;
108
+ }>;
109
+ /**
110
+ * Parse settlement parameters from payment requirements and payload
111
+ */
112
+ declare function parseSettlementRouterParams(paymentRequirements: any, paymentPayload: any): SettlementRouterParams;
113
+ /**
114
+ * Execute settlement using provided WalletClient (for AccountPool integration)
115
+ * This function allows external wallet management by accepting a pre-configured WalletClient
116
+ */
117
+ declare function executeSettlementWithWalletClient(walletClient: WalletClient, publicClient: PublicClient, paymentRequirements: PaymentRequirements, paymentPayload: PaymentPayload, config?: {
118
+ gasLimit?: bigint;
119
+ gasMultiplier?: number;
120
+ timeoutMs?: number;
121
+ allowedRouters?: Record<string, string[]>;
122
+ }): Promise<SettleResponse>;
123
+ /**
124
+ * Full settlement workflow using SettlementRouter
125
+ * This function creates its own clients based on FacilitatorConfig
126
+ */
127
+ declare function settleWithSettlementRouter(paymentRequirements: any, paymentPayload: any, config: FacilitatorConfig, options?: {
128
+ gasMultiplier?: number;
129
+ gasLimit?: bigint;
130
+ timeoutMs?: number;
131
+ }): Promise<SettleResponse>;
132
+
133
+ /**
134
+ * Validation utilities for @x402x/facilitator-sdk
135
+ *
136
+ * Provides parameter validation and security checks for SettlementRouter integration
137
+ */
138
+
139
+ /**
140
+ * Check if an Ethereum address is valid
141
+ */
142
+ declare function isValidEthereumAddress(address: string): address is Address$1;
143
+ /**
144
+ * Check if a hex string is valid
145
+ */
146
+ declare function isValidHex(hex: string): boolean;
147
+ /**
148
+ * Check if a string is a valid 32-byte hex (for salt, nonce, etc.)
149
+ */
150
+ declare function isValid32ByteHex(hex: string): boolean;
151
+ /**
152
+ * Check if a string is a valid 256-bit number (for values, fees, timestamps)
153
+ */
154
+ declare function isValid256BitHex(hex: string): boolean;
155
+ /**
156
+ * Validate SettlementRouter address against allowed list
157
+ */
158
+ declare function validateSettlementRouter(network: string, router: Address$1, allowedRouters?: Record<string, string[]>, networkConfig?: NetworkConfig): Address$1;
159
+ /**
160
+ * Validate settlement extra parameters
161
+ */
162
+ declare function validateSettlementExtra(extra: unknown): SettlementExtraCore;
163
+ /**
164
+ * Validate network string format
165
+ */
166
+ declare function validateNetwork(network: string): Network;
167
+ /**
168
+ * Validate facilitator configuration
169
+ */
170
+ declare function validateFacilitatorConfig(config: {
171
+ signer?: string;
172
+ privateKey?: string;
173
+ allowedRouters?: Record<string, string[]>;
174
+ rpcUrls?: Record<string, string>;
175
+ }): void;
176
+ /**
177
+ * Validate gas limit configuration
178
+ */
179
+ declare function validateGasLimit(gasLimit: bigint): void;
180
+ /**
181
+ * Validate gas multiplier
182
+ */
183
+ declare function validateGasMultiplier(multiplier: number): void;
184
+ /**
185
+ * Validate fee amount against minimum and maximum
186
+ */
187
+ declare function validateFeeAmount(fee: string, minFee?: string, maxFee?: string): void;
188
+
189
+ export { RouterSettlementFacilitator, calculateGasLimit, checkIfSettled, createPublicClientForNetwork, createRouterSettlementFacilitator, createWalletClientForNetwork, executeSettlementWithRouter, executeSettlementWithWalletClient, isValid256BitHex, isValid32ByteHex, isValidEthereumAddress, isValidHex, parseSettlementRouterParams, settleWithSettlementRouter, validateFacilitatorConfig, validateFeeAmount, validateGasLimit, validateGasMultiplier, validateNetwork, validateSettlementExtra, validateSettlementRouter, waitForSettlementReceipt };
@@ -0,0 +1,189 @@
1
+ import { SchemeNetworkFacilitator, PaymentPayload, PaymentRequirements, SettleResponse } from '@x402/core/types';
2
+ export { PaymentPayload, PaymentRequirements, SchemeNetworkFacilitator, SettleResponse } from '@x402/core/types';
3
+ import { FacilitatorConfig, VerifyResponse, SettlementRouterParams, Address as Address$1, NetworkConfig, SettlementExtraCore, Network } from '@x402x/extensions';
4
+ export { Address, FacilitatorConfig, FacilitatorValidationError, Network, NetworkConfig, SETTLEMENT_ROUTER_ABI, SettlementExtraCore, SettlementRouterError, SettlementRouterParams, VerifyResponse, getNetworkConfig, isSettlementMode, parseSettlementExtra } from '@x402x/extensions';
5
+ import { PublicClient, Address, Transport, WalletClient, Hex } from 'viem';
6
+
7
+ /**
8
+ * RouterSettlementFacilitator implementation
9
+ *
10
+ * Implements SchemeNetworkFacilitator interface using SettlementRouter for atomic settlement
11
+ */
12
+
13
+ /**
14
+ * SchemeNetworkFacilitator implementation using SettlementRouter
15
+ *
16
+ * Provides atomic settlement with hooks and facilitator fee handling
17
+ */
18
+ declare class RouterSettlementFacilitator implements SchemeNetworkFacilitator {
19
+ readonly scheme = "exact";
20
+ readonly caipFamily = "eip155:*";
21
+ private readonly config;
22
+ constructor(config: FacilitatorConfig);
23
+ /**
24
+ * Get scheme-specific extra data for responses
25
+ */
26
+ getExtra(network: string): Record<string, unknown> | undefined;
27
+ /**
28
+ * Get signer addresses for the network
29
+ * Derives from privateKey if signer address not explicitly provided
30
+ */
31
+ getSigners(network: string): string[];
32
+ /**
33
+ * Verify payment payload without executing settlement
34
+ */
35
+ verify(payload: PaymentPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
36
+ /**
37
+ * Settle payment by executing blockchain transaction
38
+ */
39
+ settle(payload: PaymentPayload, requirements: PaymentRequirements): Promise<SettleResponse>;
40
+ /**
41
+ * Validate basic payload and requirements
42
+ */
43
+ private validateBasicPayload;
44
+ /**
45
+ * Verify payment for SettlementRouter mode
46
+ */
47
+ private verifySettlementRouter;
48
+ /**
49
+ * Verify payment for standard mode (fallback)
50
+ */
51
+ private verifyStandard;
52
+ /**
53
+ * Settle payment using SettlementRouter
54
+ */
55
+ private settleWithRouter;
56
+ /**
57
+ * Settle payment using standard method (fallback)
58
+ */
59
+ private settleStandard;
60
+ }
61
+ /**
62
+ * Factory function to create RouterSettlementFacilitator instance
63
+ */
64
+ declare function createRouterSettlementFacilitator(config: FacilitatorConfig): RouterSettlementFacilitator;
65
+
66
+ /**
67
+ * SettlementRouter integration utilities for @x402x/facilitator-sdk
68
+ *
69
+ * Provides direct viem integration with SettlementRouter contracts
70
+ */
71
+
72
+ /**
73
+ * Create viem public client for a network
74
+ *
75
+ * @param network - Network identifier (V1 name or V2 CAIP-2 format)
76
+ * @param rpcUrls - Optional custom RPC URLs
77
+ */
78
+ declare function createPublicClientForNetwork(network: string, rpcUrls?: Record<string, string>): PublicClient;
79
+ /**
80
+ * Create viem wallet client for a network
81
+ * If privateKey is provided, uses local signing (works with standard RPC providers)
82
+ * If only signer address is provided, requires node to have the account unlocked
83
+ */
84
+ declare function createWalletClientForNetwork(network: string, signer?: Address, rpcUrls?: Record<string, string>, transport?: Transport, privateKey?: string): WalletClient;
85
+ /**
86
+ * Calculate gas limit for SettlementRouter transaction
87
+ */
88
+ declare function calculateGasLimit(baseFee: string, facilitatorFee: string, gasMultiplier?: number): bigint;
89
+ /**
90
+ * Check if a settlement has already been executed
91
+ */
92
+ declare function checkIfSettled(publicClient: PublicClient, router: Address, contextKey: Hex): Promise<boolean>;
93
+ /**
94
+ * Execute settlement via SettlementRouter
95
+ */
96
+ declare function executeSettlementWithRouter(walletClient: WalletClient, params: SettlementRouterParams, config?: {
97
+ gasLimit?: bigint;
98
+ gasMultiplier?: number;
99
+ }): Promise<Hex>;
100
+ /**
101
+ * Wait for transaction receipt and extract relevant data
102
+ */
103
+ declare function waitForSettlementReceipt(publicClient: PublicClient, txHash: Hex, timeoutMs?: number): Promise<{
104
+ success: boolean;
105
+ blockNumber?: bigint;
106
+ gasUsed?: bigint;
107
+ effectiveGasPrice?: bigint;
108
+ }>;
109
+ /**
110
+ * Parse settlement parameters from payment requirements and payload
111
+ */
112
+ declare function parseSettlementRouterParams(paymentRequirements: any, paymentPayload: any): SettlementRouterParams;
113
+ /**
114
+ * Execute settlement using provided WalletClient (for AccountPool integration)
115
+ * This function allows external wallet management by accepting a pre-configured WalletClient
116
+ */
117
+ declare function executeSettlementWithWalletClient(walletClient: WalletClient, publicClient: PublicClient, paymentRequirements: PaymentRequirements, paymentPayload: PaymentPayload, config?: {
118
+ gasLimit?: bigint;
119
+ gasMultiplier?: number;
120
+ timeoutMs?: number;
121
+ allowedRouters?: Record<string, string[]>;
122
+ }): Promise<SettleResponse>;
123
+ /**
124
+ * Full settlement workflow using SettlementRouter
125
+ * This function creates its own clients based on FacilitatorConfig
126
+ */
127
+ declare function settleWithSettlementRouter(paymentRequirements: any, paymentPayload: any, config: FacilitatorConfig, options?: {
128
+ gasMultiplier?: number;
129
+ gasLimit?: bigint;
130
+ timeoutMs?: number;
131
+ }): Promise<SettleResponse>;
132
+
133
+ /**
134
+ * Validation utilities for @x402x/facilitator-sdk
135
+ *
136
+ * Provides parameter validation and security checks for SettlementRouter integration
137
+ */
138
+
139
+ /**
140
+ * Check if an Ethereum address is valid
141
+ */
142
+ declare function isValidEthereumAddress(address: string): address is Address$1;
143
+ /**
144
+ * Check if a hex string is valid
145
+ */
146
+ declare function isValidHex(hex: string): boolean;
147
+ /**
148
+ * Check if a string is a valid 32-byte hex (for salt, nonce, etc.)
149
+ */
150
+ declare function isValid32ByteHex(hex: string): boolean;
151
+ /**
152
+ * Check if a string is a valid 256-bit number (for values, fees, timestamps)
153
+ */
154
+ declare function isValid256BitHex(hex: string): boolean;
155
+ /**
156
+ * Validate SettlementRouter address against allowed list
157
+ */
158
+ declare function validateSettlementRouter(network: string, router: Address$1, allowedRouters?: Record<string, string[]>, networkConfig?: NetworkConfig): Address$1;
159
+ /**
160
+ * Validate settlement extra parameters
161
+ */
162
+ declare function validateSettlementExtra(extra: unknown): SettlementExtraCore;
163
+ /**
164
+ * Validate network string format
165
+ */
166
+ declare function validateNetwork(network: string): Network;
167
+ /**
168
+ * Validate facilitator configuration
169
+ */
170
+ declare function validateFacilitatorConfig(config: {
171
+ signer?: string;
172
+ privateKey?: string;
173
+ allowedRouters?: Record<string, string[]>;
174
+ rpcUrls?: Record<string, string>;
175
+ }): void;
176
+ /**
177
+ * Validate gas limit configuration
178
+ */
179
+ declare function validateGasLimit(gasLimit: bigint): void;
180
+ /**
181
+ * Validate gas multiplier
182
+ */
183
+ declare function validateGasMultiplier(multiplier: number): void;
184
+ /**
185
+ * Validate fee amount against minimum and maximum
186
+ */
187
+ declare function validateFeeAmount(fee: string, minFee?: string, maxFee?: string): void;
188
+
189
+ export { RouterSettlementFacilitator, calculateGasLimit, checkIfSettled, createPublicClientForNetwork, createRouterSettlementFacilitator, createWalletClientForNetwork, executeSettlementWithRouter, executeSettlementWithWalletClient, isValid256BitHex, isValid32ByteHex, isValidEthereumAddress, isValidHex, parseSettlementRouterParams, settleWithSettlementRouter, validateFacilitatorConfig, validateFeeAmount, validateGasLimit, validateGasMultiplier, validateNetwork, validateSettlementExtra, validateSettlementRouter, waitForSettlementReceipt };