moltspay 1.2.1 → 1.4.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.
Files changed (59) hide show
  1. package/README.md +292 -34
  2. package/dist/cdp/index.d.mts +4 -4
  3. package/dist/cdp/index.d.ts +4 -4
  4. package/dist/cdp/index.js +110 -30368
  5. package/dist/cdp/index.js.map +1 -1
  6. package/dist/cdp/index.mjs +94 -30360
  7. package/dist/cdp/index.mjs.map +1 -1
  8. package/dist/cdp-DeohBe1o.d.ts +66 -0
  9. package/dist/cdp-p_eHuQpb.d.mts +66 -0
  10. package/dist/chains/index.d.mts +9 -8
  11. package/dist/chains/index.d.ts +9 -8
  12. package/dist/chains/index.js +86 -0
  13. package/dist/chains/index.js.map +1 -1
  14. package/dist/chains/index.mjs +86 -0
  15. package/dist/chains/index.mjs.map +1 -1
  16. package/dist/cli/index.js +2746 -290
  17. package/dist/cli/index.js.map +1 -1
  18. package/dist/cli/index.mjs +2752 -282
  19. package/dist/cli/index.mjs.map +1 -1
  20. package/dist/client/index.d.mts +60 -4
  21. package/dist/client/index.d.ts +60 -4
  22. package/dist/client/index.js +734 -43
  23. package/dist/client/index.js.map +1 -1
  24. package/dist/client/index.mjs +732 -41
  25. package/dist/client/index.mjs.map +1 -1
  26. package/dist/facilitators/index.d.mts +220 -39
  27. package/dist/facilitators/index.d.ts +220 -39
  28. package/dist/facilitators/index.js +897 -1
  29. package/dist/facilitators/index.js.map +1 -1
  30. package/dist/facilitators/index.mjs +902 -1
  31. package/dist/facilitators/index.mjs.map +1 -1
  32. package/dist/{index-DgJPZMBG.d.mts → index-D_2FkLwV.d.mts} +6 -2
  33. package/dist/{index-DgJPZMBG.d.ts → index-D_2FkLwV.d.ts} +6 -2
  34. package/dist/index.d.mts +3 -2
  35. package/dist/index.d.ts +3 -2
  36. package/dist/index.js +2238 -30837
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.mjs +2167 -30766
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/server/index.d.mts +30 -3
  41. package/dist/server/index.d.ts +30 -3
  42. package/dist/server/index.js +1345 -54
  43. package/dist/server/index.js.map +1 -1
  44. package/dist/server/index.mjs +1355 -54
  45. package/dist/server/index.mjs.map +1 -1
  46. package/dist/verify/index.d.mts +1 -1
  47. package/dist/verify/index.d.ts +1 -1
  48. package/dist/verify/index.js +86 -0
  49. package/dist/verify/index.js.map +1 -1
  50. package/dist/verify/index.mjs +86 -0
  51. package/dist/verify/index.mjs.map +1 -1
  52. package/dist/wallet/index.d.mts +3 -3
  53. package/dist/wallet/index.d.ts +3 -3
  54. package/dist/wallet/index.js +86 -0
  55. package/dist/wallet/index.js.map +1 -1
  56. package/dist/wallet/index.mjs +86 -0
  57. package/dist/wallet/index.mjs.map +1 -1
  58. package/package.json +8 -2
  59. package/schemas/moltspay.services.schema.json +27 -132
@@ -1,67 +1,248 @@
1
- import { B as BaseFacilitator, a as FacilitatorConfig, H as HealthCheckResult, X as X402PaymentPayload, f as X402PaymentRequirements, V as VerifyResult, e as SettleResult, b as FacilitatorFee } from '../registry-OsEO2dOu.mjs';
2
- export { F as Facilitator, c as FacilitatorRegistry, d as FacilitatorSelection, S as SelectionStrategy, g as createRegistry, h as getDefaultRegistry } from '../registry-OsEO2dOu.mjs';
1
+ import { B as BaseFacilitator, H as HealthCheckResult, X as X402PaymentPayload, f as X402PaymentRequirements, V as VerifyResult, e as SettleResult } from '../registry-OsEO2dOu.mjs';
2
+ export { F as Facilitator, a as FacilitatorConfig, b as FacilitatorFee, c as FacilitatorRegistry, d as FacilitatorSelection, S as SelectionStrategy, g as createRegistry, h as getDefaultRegistry } from '../registry-OsEO2dOu.mjs';
3
+ export { C as CDPFacilitator, a as CDPFacilitatorConfig } from '../cdp-p_eHuQpb.mjs';
4
+ import { Keypair, PublicKey, Transaction } from '@solana/web3.js';
3
5
 
4
6
  /**
5
- * CDP Facilitator
7
+ * Tempo Testnet Facilitator
6
8
  *
7
- * Coinbase Developer Platform x402 facilitator implementation.
8
- * Auto-detects mainnet vs testnet from chain ID in request.
9
+ * Verifies payments on Tempo Moderato testnet by checking transaction receipts.
10
+ * Unlike CDP facilitator, this directly verifies on-chain without a third-party service.
11
+ */
12
+
13
+ /**
14
+ * Tempo Testnet Facilitator
9
15
  *
10
- * Supported networks:
11
- * - Base mainnet (eip155:8453)
12
- * - Polygon mainnet (eip155:137)
13
- * - Base Sepolia testnet (eip155:84532)
16
+ * Verifies TIP-20 token transfers on Tempo Moderato (chainId 42431).
17
+ */
18
+ declare class TempoFacilitator extends BaseFacilitator {
19
+ readonly name = "tempo";
20
+ readonly displayName = "Tempo Testnet";
21
+ readonly supportedNetworks: string[];
22
+ private rpcUrl;
23
+ constructor();
24
+ healthCheck(): Promise<HealthCheckResult>;
25
+ verify(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<VerifyResult>;
26
+ settle(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<SettleResult>;
27
+ private getTransactionReceipt;
28
+ }
29
+
30
+ /**
31
+ * BNB Chain Facilitator
32
+ *
33
+ * Handles pay-for-success payments on BNB Smart Chain.
14
34
  *
15
- * @see https://docs.cdp.coinbase.com/x402/core-concepts/facilitator
35
+ * Flow:
36
+ * 1. Client pre-approves server wallet (one-time, via `moltspay init`)
37
+ * 2. Client signs EIP-712 intent (no gas, just signature)
38
+ * 3. Server verifies intent signature
39
+ * 4. Server executes service
40
+ * 5. Success → Server calls transferFrom (server pays gas)
41
+ * 6. Failure → No transfer, client keeps money
42
+ *
43
+ * Key difference from Tempo:
44
+ * - Tempo: Client pays first → service might fail → money lost
45
+ * - BNB: Service runs first → success = payment (pay-for-success)
16
46
  */
17
47
 
18
- interface CDPFacilitatorConfig extends FacilitatorConfig {
19
- /** CDP API Key ID (required) */
20
- apiKeyId?: string;
21
- /** CDP API Key Secret (required) */
22
- apiKeySecret?: string;
48
+ /**
49
+ * BNB Payment Intent (signed by client)
50
+ */
51
+ interface BNBPaymentIntent {
52
+ from: string;
53
+ to: string;
54
+ amount: string;
55
+ token: string;
56
+ service: string;
57
+ nonce: number;
58
+ deadline: number;
59
+ signature: string;
23
60
  }
24
61
  /**
25
- * CDP (Coinbase Developer Platform) Facilitator
62
+ * BNB Chain Facilitator
26
63
  *
27
- * Handles payment verification and settlement via Coinbase's x402 facilitator.
64
+ * Handles pay-for-success payments on BNB mainnet (chainId 56) and testnet (chainId 97).
65
+ * Server wallet executes transferFrom after successful service delivery.
28
66
  */
29
- declare class CDPFacilitator extends BaseFacilitator {
30
- readonly name = "cdp";
31
- readonly displayName = "Coinbase CDP";
67
+ declare class BNBFacilitator extends BaseFacilitator {
68
+ readonly name = "bnb";
69
+ readonly displayName = "BNB Smart Chain";
32
70
  readonly supportedNetworks: string[];
33
- private endpoint;
34
- private apiKeyId?;
35
- private apiKeySecret?;
36
- constructor(config?: CDPFacilitatorConfig);
71
+ private serverPrivateKey;
72
+ private spenderAddress;
73
+ private chainConfigs;
74
+ constructor(serverPrivateKey?: string);
75
+ healthCheck(): Promise<HealthCheckResult>;
37
76
  /**
38
- * Get auth headers for CDP API requests
77
+ * Verify a payment intent signature (before service execution)
78
+ *
79
+ * This verifies:
80
+ * 1. Signature is valid for the intent
81
+ * 2. Client has approved server wallet
82
+ * 3. Client has sufficient balance
83
+ * 4. Intent hasn't expired
39
84
  */
40
- private getAuthHeaders;
85
+ verify(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<VerifyResult>;
41
86
  /**
42
- * Health check - verify facilitator is reachable
87
+ * Settle a payment by executing transferFrom
88
+ *
89
+ * This is called AFTER the service has been successfully delivered.
90
+ * Server pays gas, transfers tokens from client to provider.
43
91
  */
44
- healthCheck(): Promise<HealthCheckResult>;
92
+ settle(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<SettleResult>;
45
93
  /**
46
- * Verify payment signature with facilitator
94
+ * Check if client has approved the server wallet
47
95
  */
48
- verify(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<VerifyResult>;
96
+ checkApproval(clientAddress: string, token: string, chainId: number): Promise<{
97
+ approved: boolean;
98
+ allowance: string;
99
+ }>;
49
100
  /**
50
- * Settle payment on-chain via facilitator
101
+ * Verify a completed transaction (for checking past payments)
51
102
  */
52
- settle(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<SettleResult>;
103
+ verifyTransaction(txHash: string, expected: {
104
+ to: string;
105
+ amount: string;
106
+ token: string;
107
+ }, chainId: number): Promise<VerifyResult>;
53
108
  /**
54
- * Get CDP fee information
109
+ * Get the server's spender address (public, for 402 responses)
110
+ * Returns cached value computed at construction time.
55
111
  */
56
- getFee(): Promise<FacilitatorFee>;
112
+ getSpenderAddress(): string | null;
113
+ private getServerAddress;
114
+ private recoverIntentSigner;
115
+ private getAllowance;
116
+ private getBalance;
117
+ private executeTransferFrom;
118
+ private getTransactionReceipt;
119
+ }
120
+ /**
121
+ * Create EIP-712 typed data for signing a payment intent
122
+ *
123
+ * Used by clients to sign their payment intent.
124
+ */
125
+ declare function createIntentTypedData(intent: Omit<BNBPaymentIntent, 'signature'>, chainId: number): {
126
+ domain: {
127
+ chainId: number;
128
+ name: string;
129
+ version: string;
130
+ };
131
+ types: {
132
+ PaymentIntent: {
133
+ name: string;
134
+ type: string;
135
+ }[];
136
+ };
137
+ primaryType: "PaymentIntent";
138
+ message: {
139
+ from: string;
140
+ to: string;
141
+ amount: string;
142
+ token: string;
143
+ service: string;
144
+ nonce: number;
145
+ deadline: number;
146
+ };
147
+ };
148
+
149
+ /**
150
+ * Solana Chain Configuration
151
+ *
152
+ * Solana is NOT an EVM chain - uses different:
153
+ * - Key format: ed25519 (EdDSA) vs secp256k1 (ECDSA)
154
+ * - Address format: Base58 vs 0x hex
155
+ * - Token standard: SPL vs ERC-20
156
+ */
157
+
158
+ type SolanaChainName = 'solana' | 'solana_devnet';
159
+
160
+ /**
161
+ * Solana Facilitator
162
+ *
163
+ * Pay-for-success payment settlement for Solana SPL token transfers.
164
+ * Unlike EVM chains, Solana doesn't have a third-party facilitator -
165
+ * we verify and settle directly on-chain.
166
+ *
167
+ * Flow:
168
+ * 1. Client signs a SPL token transfer authorization
169
+ * 2. Server receives the signed transaction
170
+ * 3. Server verifies the signature and amount
171
+ * 4. Server submits the transaction to settle payment
172
+ */
173
+
174
+ /**
175
+ * Solana payment payload structure
176
+ */
177
+ interface SolanaPaymentPayload {
178
+ /** Base58 encoded signed transaction */
179
+ signedTransaction: string;
180
+ /** Sender's public key (Base58) */
181
+ sender: string;
182
+ /** Chain: solana or solana_devnet */
183
+ chain: SolanaChainName;
184
+ }
185
+ /**
186
+ * Solana Facilitator configuration
187
+ */
188
+ interface SolanaFacilitatorConfig {
189
+ /** Optional fee payer keypair for gasless transactions */
190
+ feePayerKeypair?: Keypair;
191
+ }
192
+ /**
193
+ * Solana Facilitator for pay-for-success payments
194
+ *
195
+ * Supports gasless mode: if feePayerKeypair is provided, server pays tx fees
196
+ */
197
+ declare class SolanaFacilitator extends BaseFacilitator {
198
+ readonly name = "solana";
199
+ readonly displayName = "Solana Direct";
200
+ readonly supportedNetworks: string[];
201
+ private connections;
202
+ private feePayerKeypair?;
203
+ constructor(config?: SolanaFacilitatorConfig);
204
+ /**
205
+ * Get fee payer public key (for gasless transactions)
206
+ */
207
+ getFeePayerPubkey(): string | null;
208
+ private getConnection;
209
+ /**
210
+ * Convert our chain name to network identifier
211
+ */
212
+ static chainToNetwork(chain: SolanaChainName): string;
213
+ /**
214
+ * Convert network identifier to chain name
215
+ */
216
+ static networkToChain(network: string): SolanaChainName | null;
217
+ healthCheck(): Promise<HealthCheckResult>;
57
218
  /**
58
- * Check if a chain ID is testnet
219
+ * Verify a Solana payment
220
+ *
221
+ * Checks:
222
+ * 1. Transaction is valid and properly signed
223
+ * 2. Transfer instruction matches expected amount and recipient
59
224
  */
60
- static isTestnet(chainId: number): boolean;
225
+ verify(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<VerifyResult>;
61
226
  /**
62
- * Get configuration summary (for logging)
227
+ * Settle a Solana payment
228
+ *
229
+ * Submits the signed transaction to the network.
230
+ * In gasless mode, adds fee payer signature before submitting.
63
231
  */
64
- getConfigSummary(): string;
232
+ settle(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<SettleResult>;
233
+ supportsNetwork(network: string): boolean;
65
234
  }
235
+ /**
236
+ * Create a Solana payment transaction for signing
237
+ *
238
+ * This is called by the client to create the transaction to sign.
239
+ *
240
+ * @param senderPubkey - The sender's public key (token owner)
241
+ * @param recipientPubkey - The recipient's public key
242
+ * @param amount - Amount in token base units
243
+ * @param chain - Solana chain (solana or solana_devnet)
244
+ * @param feePayerPubkey - Optional fee payer public key for gasless transactions
245
+ */
246
+ declare function createSolanaPaymentTransaction(senderPubkey: PublicKey, recipientPubkey: PublicKey, amount: bigint, chain: SolanaChainName, feePayerPubkey?: PublicKey): Promise<Transaction>;
66
247
 
67
- export { BaseFacilitator, CDPFacilitator, type CDPFacilitatorConfig, FacilitatorConfig, FacilitatorFee, HealthCheckResult, SettleResult, VerifyResult, X402PaymentPayload, X402PaymentRequirements };
248
+ export { BNBFacilitator, type BNBPaymentIntent, BaseFacilitator, HealthCheckResult, SettleResult, SolanaFacilitator, type SolanaPaymentPayload, TempoFacilitator, VerifyResult, X402PaymentPayload, X402PaymentRequirements, createIntentTypedData, createSolanaPaymentTransaction };
@@ -1,67 +1,248 @@
1
- import { B as BaseFacilitator, a as FacilitatorConfig, H as HealthCheckResult, X as X402PaymentPayload, f as X402PaymentRequirements, V as VerifyResult, e as SettleResult, b as FacilitatorFee } from '../registry-OsEO2dOu.js';
2
- export { F as Facilitator, c as FacilitatorRegistry, d as FacilitatorSelection, S as SelectionStrategy, g as createRegistry, h as getDefaultRegistry } from '../registry-OsEO2dOu.js';
1
+ import { B as BaseFacilitator, H as HealthCheckResult, X as X402PaymentPayload, f as X402PaymentRequirements, V as VerifyResult, e as SettleResult } from '../registry-OsEO2dOu.js';
2
+ export { F as Facilitator, a as FacilitatorConfig, b as FacilitatorFee, c as FacilitatorRegistry, d as FacilitatorSelection, S as SelectionStrategy, g as createRegistry, h as getDefaultRegistry } from '../registry-OsEO2dOu.js';
3
+ export { C as CDPFacilitator, a as CDPFacilitatorConfig } from '../cdp-DeohBe1o.js';
4
+ import { Keypair, PublicKey, Transaction } from '@solana/web3.js';
3
5
 
4
6
  /**
5
- * CDP Facilitator
7
+ * Tempo Testnet Facilitator
6
8
  *
7
- * Coinbase Developer Platform x402 facilitator implementation.
8
- * Auto-detects mainnet vs testnet from chain ID in request.
9
+ * Verifies payments on Tempo Moderato testnet by checking transaction receipts.
10
+ * Unlike CDP facilitator, this directly verifies on-chain without a third-party service.
11
+ */
12
+
13
+ /**
14
+ * Tempo Testnet Facilitator
9
15
  *
10
- * Supported networks:
11
- * - Base mainnet (eip155:8453)
12
- * - Polygon mainnet (eip155:137)
13
- * - Base Sepolia testnet (eip155:84532)
16
+ * Verifies TIP-20 token transfers on Tempo Moderato (chainId 42431).
17
+ */
18
+ declare class TempoFacilitator extends BaseFacilitator {
19
+ readonly name = "tempo";
20
+ readonly displayName = "Tempo Testnet";
21
+ readonly supportedNetworks: string[];
22
+ private rpcUrl;
23
+ constructor();
24
+ healthCheck(): Promise<HealthCheckResult>;
25
+ verify(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<VerifyResult>;
26
+ settle(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<SettleResult>;
27
+ private getTransactionReceipt;
28
+ }
29
+
30
+ /**
31
+ * BNB Chain Facilitator
32
+ *
33
+ * Handles pay-for-success payments on BNB Smart Chain.
14
34
  *
15
- * @see https://docs.cdp.coinbase.com/x402/core-concepts/facilitator
35
+ * Flow:
36
+ * 1. Client pre-approves server wallet (one-time, via `moltspay init`)
37
+ * 2. Client signs EIP-712 intent (no gas, just signature)
38
+ * 3. Server verifies intent signature
39
+ * 4. Server executes service
40
+ * 5. Success → Server calls transferFrom (server pays gas)
41
+ * 6. Failure → No transfer, client keeps money
42
+ *
43
+ * Key difference from Tempo:
44
+ * - Tempo: Client pays first → service might fail → money lost
45
+ * - BNB: Service runs first → success = payment (pay-for-success)
16
46
  */
17
47
 
18
- interface CDPFacilitatorConfig extends FacilitatorConfig {
19
- /** CDP API Key ID (required) */
20
- apiKeyId?: string;
21
- /** CDP API Key Secret (required) */
22
- apiKeySecret?: string;
48
+ /**
49
+ * BNB Payment Intent (signed by client)
50
+ */
51
+ interface BNBPaymentIntent {
52
+ from: string;
53
+ to: string;
54
+ amount: string;
55
+ token: string;
56
+ service: string;
57
+ nonce: number;
58
+ deadline: number;
59
+ signature: string;
23
60
  }
24
61
  /**
25
- * CDP (Coinbase Developer Platform) Facilitator
62
+ * BNB Chain Facilitator
26
63
  *
27
- * Handles payment verification and settlement via Coinbase's x402 facilitator.
64
+ * Handles pay-for-success payments on BNB mainnet (chainId 56) and testnet (chainId 97).
65
+ * Server wallet executes transferFrom after successful service delivery.
28
66
  */
29
- declare class CDPFacilitator extends BaseFacilitator {
30
- readonly name = "cdp";
31
- readonly displayName = "Coinbase CDP";
67
+ declare class BNBFacilitator extends BaseFacilitator {
68
+ readonly name = "bnb";
69
+ readonly displayName = "BNB Smart Chain";
32
70
  readonly supportedNetworks: string[];
33
- private endpoint;
34
- private apiKeyId?;
35
- private apiKeySecret?;
36
- constructor(config?: CDPFacilitatorConfig);
71
+ private serverPrivateKey;
72
+ private spenderAddress;
73
+ private chainConfigs;
74
+ constructor(serverPrivateKey?: string);
75
+ healthCheck(): Promise<HealthCheckResult>;
37
76
  /**
38
- * Get auth headers for CDP API requests
77
+ * Verify a payment intent signature (before service execution)
78
+ *
79
+ * This verifies:
80
+ * 1. Signature is valid for the intent
81
+ * 2. Client has approved server wallet
82
+ * 3. Client has sufficient balance
83
+ * 4. Intent hasn't expired
39
84
  */
40
- private getAuthHeaders;
85
+ verify(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<VerifyResult>;
41
86
  /**
42
- * Health check - verify facilitator is reachable
87
+ * Settle a payment by executing transferFrom
88
+ *
89
+ * This is called AFTER the service has been successfully delivered.
90
+ * Server pays gas, transfers tokens from client to provider.
43
91
  */
44
- healthCheck(): Promise<HealthCheckResult>;
92
+ settle(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<SettleResult>;
45
93
  /**
46
- * Verify payment signature with facilitator
94
+ * Check if client has approved the server wallet
47
95
  */
48
- verify(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<VerifyResult>;
96
+ checkApproval(clientAddress: string, token: string, chainId: number): Promise<{
97
+ approved: boolean;
98
+ allowance: string;
99
+ }>;
49
100
  /**
50
- * Settle payment on-chain via facilitator
101
+ * Verify a completed transaction (for checking past payments)
51
102
  */
52
- settle(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<SettleResult>;
103
+ verifyTransaction(txHash: string, expected: {
104
+ to: string;
105
+ amount: string;
106
+ token: string;
107
+ }, chainId: number): Promise<VerifyResult>;
53
108
  /**
54
- * Get CDP fee information
109
+ * Get the server's spender address (public, for 402 responses)
110
+ * Returns cached value computed at construction time.
55
111
  */
56
- getFee(): Promise<FacilitatorFee>;
112
+ getSpenderAddress(): string | null;
113
+ private getServerAddress;
114
+ private recoverIntentSigner;
115
+ private getAllowance;
116
+ private getBalance;
117
+ private executeTransferFrom;
118
+ private getTransactionReceipt;
119
+ }
120
+ /**
121
+ * Create EIP-712 typed data for signing a payment intent
122
+ *
123
+ * Used by clients to sign their payment intent.
124
+ */
125
+ declare function createIntentTypedData(intent: Omit<BNBPaymentIntent, 'signature'>, chainId: number): {
126
+ domain: {
127
+ chainId: number;
128
+ name: string;
129
+ version: string;
130
+ };
131
+ types: {
132
+ PaymentIntent: {
133
+ name: string;
134
+ type: string;
135
+ }[];
136
+ };
137
+ primaryType: "PaymentIntent";
138
+ message: {
139
+ from: string;
140
+ to: string;
141
+ amount: string;
142
+ token: string;
143
+ service: string;
144
+ nonce: number;
145
+ deadline: number;
146
+ };
147
+ };
148
+
149
+ /**
150
+ * Solana Chain Configuration
151
+ *
152
+ * Solana is NOT an EVM chain - uses different:
153
+ * - Key format: ed25519 (EdDSA) vs secp256k1 (ECDSA)
154
+ * - Address format: Base58 vs 0x hex
155
+ * - Token standard: SPL vs ERC-20
156
+ */
157
+
158
+ type SolanaChainName = 'solana' | 'solana_devnet';
159
+
160
+ /**
161
+ * Solana Facilitator
162
+ *
163
+ * Pay-for-success payment settlement for Solana SPL token transfers.
164
+ * Unlike EVM chains, Solana doesn't have a third-party facilitator -
165
+ * we verify and settle directly on-chain.
166
+ *
167
+ * Flow:
168
+ * 1. Client signs a SPL token transfer authorization
169
+ * 2. Server receives the signed transaction
170
+ * 3. Server verifies the signature and amount
171
+ * 4. Server submits the transaction to settle payment
172
+ */
173
+
174
+ /**
175
+ * Solana payment payload structure
176
+ */
177
+ interface SolanaPaymentPayload {
178
+ /** Base58 encoded signed transaction */
179
+ signedTransaction: string;
180
+ /** Sender's public key (Base58) */
181
+ sender: string;
182
+ /** Chain: solana or solana_devnet */
183
+ chain: SolanaChainName;
184
+ }
185
+ /**
186
+ * Solana Facilitator configuration
187
+ */
188
+ interface SolanaFacilitatorConfig {
189
+ /** Optional fee payer keypair for gasless transactions */
190
+ feePayerKeypair?: Keypair;
191
+ }
192
+ /**
193
+ * Solana Facilitator for pay-for-success payments
194
+ *
195
+ * Supports gasless mode: if feePayerKeypair is provided, server pays tx fees
196
+ */
197
+ declare class SolanaFacilitator extends BaseFacilitator {
198
+ readonly name = "solana";
199
+ readonly displayName = "Solana Direct";
200
+ readonly supportedNetworks: string[];
201
+ private connections;
202
+ private feePayerKeypair?;
203
+ constructor(config?: SolanaFacilitatorConfig);
204
+ /**
205
+ * Get fee payer public key (for gasless transactions)
206
+ */
207
+ getFeePayerPubkey(): string | null;
208
+ private getConnection;
209
+ /**
210
+ * Convert our chain name to network identifier
211
+ */
212
+ static chainToNetwork(chain: SolanaChainName): string;
213
+ /**
214
+ * Convert network identifier to chain name
215
+ */
216
+ static networkToChain(network: string): SolanaChainName | null;
217
+ healthCheck(): Promise<HealthCheckResult>;
57
218
  /**
58
- * Check if a chain ID is testnet
219
+ * Verify a Solana payment
220
+ *
221
+ * Checks:
222
+ * 1. Transaction is valid and properly signed
223
+ * 2. Transfer instruction matches expected amount and recipient
59
224
  */
60
- static isTestnet(chainId: number): boolean;
225
+ verify(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<VerifyResult>;
61
226
  /**
62
- * Get configuration summary (for logging)
227
+ * Settle a Solana payment
228
+ *
229
+ * Submits the signed transaction to the network.
230
+ * In gasless mode, adds fee payer signature before submitting.
63
231
  */
64
- getConfigSummary(): string;
232
+ settle(paymentPayload: X402PaymentPayload, requirements: X402PaymentRequirements): Promise<SettleResult>;
233
+ supportsNetwork(network: string): boolean;
65
234
  }
235
+ /**
236
+ * Create a Solana payment transaction for signing
237
+ *
238
+ * This is called by the client to create the transaction to sign.
239
+ *
240
+ * @param senderPubkey - The sender's public key (token owner)
241
+ * @param recipientPubkey - The recipient's public key
242
+ * @param amount - Amount in token base units
243
+ * @param chain - Solana chain (solana or solana_devnet)
244
+ * @param feePayerPubkey - Optional fee payer public key for gasless transactions
245
+ */
246
+ declare function createSolanaPaymentTransaction(senderPubkey: PublicKey, recipientPubkey: PublicKey, amount: bigint, chain: SolanaChainName, feePayerPubkey?: PublicKey): Promise<Transaction>;
66
247
 
67
- export { BaseFacilitator, CDPFacilitator, type CDPFacilitatorConfig, FacilitatorConfig, FacilitatorFee, HealthCheckResult, SettleResult, VerifyResult, X402PaymentPayload, X402PaymentRequirements };
248
+ export { BNBFacilitator, type BNBPaymentIntent, BaseFacilitator, HealthCheckResult, SettleResult, SolanaFacilitator, type SolanaPaymentPayload, TempoFacilitator, VerifyResult, X402PaymentPayload, X402PaymentRequirements, createIntentTypedData, createSolanaPaymentTransaction };