@agentxpay/sdk 0.1.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/dist/index.d.mts +217 -0
- package/dist/index.d.ts +217 -0
- package/dist/index.js +3382 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3366 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +61 -0
- package/src/AgentXPayClient.ts +135 -0
- package/src/abi/AgentWallet.json +360 -0
- package/src/abi/AgentWalletFactory.json +84 -0
- package/src/abi/Escrow.json +483 -0
- package/src/abi/PaymentManager.json +596 -0
- package/src/abi/ServiceRegistry.json +748 -0
- package/src/abi/SubscriptionManager.json +567 -0
- package/src/index.ts +34 -0
- package/src/modules/escrow.ts +75 -0
- package/src/modules/payments.ts +96 -0
- package/src/modules/services.ts +97 -0
- package/src/modules/subscriptions.ts +78 -0
- package/src/modules/wallet.ts +111 -0
- package/src/types/index.ts +93 -0
- package/src/utils/constants.ts +25 -0
- package/src/utils/helpers.ts +30 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
|
|
3
|
+
interface AgentXPayConfig {
|
|
4
|
+
rpcUrl: string;
|
|
5
|
+
privateKey?: string;
|
|
6
|
+
signer?: any;
|
|
7
|
+
contracts?: ContractAddresses;
|
|
8
|
+
network?: "local" | "testnet" | "mainnet";
|
|
9
|
+
}
|
|
10
|
+
interface ContractAddresses {
|
|
11
|
+
serviceRegistry?: string;
|
|
12
|
+
paymentManager?: string;
|
|
13
|
+
subscriptionManager?: string;
|
|
14
|
+
escrow?: string;
|
|
15
|
+
agentWalletFactory?: string;
|
|
16
|
+
}
|
|
17
|
+
interface Service {
|
|
18
|
+
id: bigint;
|
|
19
|
+
provider: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
endpoint: string;
|
|
23
|
+
category: string;
|
|
24
|
+
pricePerCall: bigint;
|
|
25
|
+
isActive: boolean;
|
|
26
|
+
createdAt: bigint;
|
|
27
|
+
}
|
|
28
|
+
interface SubscriptionPlan {
|
|
29
|
+
planId: bigint;
|
|
30
|
+
serviceId: bigint;
|
|
31
|
+
price: bigint;
|
|
32
|
+
duration: bigint;
|
|
33
|
+
name: string;
|
|
34
|
+
}
|
|
35
|
+
interface Subscription {
|
|
36
|
+
subscriptionId: bigint;
|
|
37
|
+
serviceId: bigint;
|
|
38
|
+
planId: bigint;
|
|
39
|
+
subscriber: string;
|
|
40
|
+
startTime: bigint;
|
|
41
|
+
endTime: bigint;
|
|
42
|
+
autoRenew: boolean;
|
|
43
|
+
isActive: boolean;
|
|
44
|
+
}
|
|
45
|
+
declare enum EscrowStatus {
|
|
46
|
+
Created = 0,
|
|
47
|
+
Funded = 1,
|
|
48
|
+
Released = 2,
|
|
49
|
+
Disputed = 3,
|
|
50
|
+
Refunded = 4,
|
|
51
|
+
Resolved = 5
|
|
52
|
+
}
|
|
53
|
+
interface EscrowData {
|
|
54
|
+
escrowId: bigint;
|
|
55
|
+
serviceId: bigint;
|
|
56
|
+
payer: string;
|
|
57
|
+
provider: string;
|
|
58
|
+
amount: bigint;
|
|
59
|
+
status: EscrowStatus;
|
|
60
|
+
createdAt: bigint;
|
|
61
|
+
deadline: bigint;
|
|
62
|
+
description: string;
|
|
63
|
+
}
|
|
64
|
+
interface DiscoverFilter {
|
|
65
|
+
category?: string;
|
|
66
|
+
maxPrice?: bigint;
|
|
67
|
+
isActive?: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface PaymentResult {
|
|
70
|
+
txHash: string;
|
|
71
|
+
serviceId: bigint;
|
|
72
|
+
amount: bigint;
|
|
73
|
+
provider: string;
|
|
74
|
+
}
|
|
75
|
+
interface X402PaymentInfo {
|
|
76
|
+
address: string;
|
|
77
|
+
amount: string;
|
|
78
|
+
token: string;
|
|
79
|
+
serviceId: string;
|
|
80
|
+
chainId: string;
|
|
81
|
+
}
|
|
82
|
+
interface X402FetchOptions extends RequestInit {
|
|
83
|
+
autoPayment?: boolean;
|
|
84
|
+
maxRetries?: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare class ServicesModule {
|
|
88
|
+
private contract;
|
|
89
|
+
constructor(address: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
90
|
+
registerService(name: string, description: string, endpoint: string, category: string, pricePerCall: bigint): Promise<{
|
|
91
|
+
txHash: string;
|
|
92
|
+
serviceId: bigint;
|
|
93
|
+
}>;
|
|
94
|
+
addSubscriptionPlan(serviceId: bigint, name: string, price: bigint, duration: bigint): Promise<{
|
|
95
|
+
txHash: string;
|
|
96
|
+
planId: bigint;
|
|
97
|
+
}>;
|
|
98
|
+
getServiceDetails(serviceId: bigint): Promise<Service>;
|
|
99
|
+
discoverServices(filter?: DiscoverFilter): Promise<Service[]>;
|
|
100
|
+
getSubscriptionPlans(serviceId: bigint): Promise<SubscriptionPlan[]>;
|
|
101
|
+
getServiceCount(): Promise<bigint>;
|
|
102
|
+
private _mapService;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
declare class PaymentsModule {
|
|
106
|
+
private contract;
|
|
107
|
+
private address;
|
|
108
|
+
private signerOrProvider;
|
|
109
|
+
constructor(address: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
110
|
+
private getContract;
|
|
111
|
+
payPerUse(serviceId: bigint, amount: bigint): Promise<PaymentResult>;
|
|
112
|
+
batchPay(serviceIds: bigint[], totalAmount: bigint): Promise<string>;
|
|
113
|
+
deposit(amount: bigint): Promise<string>;
|
|
114
|
+
withdraw(amount: bigint): Promise<string>;
|
|
115
|
+
payFromBalance(serviceId: bigint): Promise<string>;
|
|
116
|
+
withdrawProviderEarnings(): Promise<string>;
|
|
117
|
+
getUserBalance(address: string): Promise<bigint>;
|
|
118
|
+
getProviderEarnings(address: string): Promise<bigint>;
|
|
119
|
+
getPaymentCount(address: string): Promise<bigint>;
|
|
120
|
+
getTotalSpent(address: string): Promise<bigint>;
|
|
121
|
+
getContractAddress(): string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare class SubscriptionsModule {
|
|
125
|
+
private contract;
|
|
126
|
+
constructor(address: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
127
|
+
private getContract;
|
|
128
|
+
subscribe(serviceId: bigint, planId: bigint, amount: bigint): Promise<{
|
|
129
|
+
txHash: string;
|
|
130
|
+
subscriptionId: bigint;
|
|
131
|
+
}>;
|
|
132
|
+
cancelSubscription(subscriptionId: bigint): Promise<string>;
|
|
133
|
+
renewSubscription(subscriptionId: bigint, amount: bigint): Promise<string>;
|
|
134
|
+
toggleAutoRenew(subscriptionId: bigint): Promise<string>;
|
|
135
|
+
getSubscription(subscriptionId: bigint): Promise<Subscription>;
|
|
136
|
+
getUserSubscriptions(address: string): Promise<bigint[]>;
|
|
137
|
+
isActive(subscriptionId: bigint): Promise<boolean>;
|
|
138
|
+
checkAccess(userAddress: string, serviceId: bigint): Promise<boolean>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare class EscrowModule {
|
|
142
|
+
private contract;
|
|
143
|
+
constructor(address: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
144
|
+
private getContract;
|
|
145
|
+
createEscrow(serviceId: bigint, provider: string, deadline: bigint, description: string, amount: bigint): Promise<{
|
|
146
|
+
txHash: string;
|
|
147
|
+
escrowId: bigint;
|
|
148
|
+
}>;
|
|
149
|
+
releaseEscrow(escrowId: bigint): Promise<string>;
|
|
150
|
+
disputeEscrow(escrowId: bigint): Promise<string>;
|
|
151
|
+
refundEscrow(escrowId: bigint): Promise<string>;
|
|
152
|
+
getEscrow(escrowId: bigint): Promise<EscrowData>;
|
|
153
|
+
getUserEscrows(address: string): Promise<bigint[]>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare class WalletModule {
|
|
157
|
+
private factoryContract;
|
|
158
|
+
private signerOrProvider;
|
|
159
|
+
constructor(factoryAddress: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
160
|
+
private getContract;
|
|
161
|
+
createWallet(dailyLimit: bigint): Promise<{
|
|
162
|
+
txHash: string;
|
|
163
|
+
walletAddress: string;
|
|
164
|
+
}>;
|
|
165
|
+
getWallets(owner: string): Promise<string[]>;
|
|
166
|
+
getWalletInstance(walletAddress: string): AgentWalletClient;
|
|
167
|
+
}
|
|
168
|
+
declare class AgentWalletClient {
|
|
169
|
+
private contract;
|
|
170
|
+
constructor(address: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
171
|
+
execute(to: string, value: bigint, data?: string): Promise<string>;
|
|
172
|
+
setDailySpendingLimit(limit: bigint): Promise<string>;
|
|
173
|
+
authorizeAgent(agent: string): Promise<string>;
|
|
174
|
+
revokeAgent(agent: string): Promise<string>;
|
|
175
|
+
withdrawFunds(amount: bigint): Promise<string>;
|
|
176
|
+
deposit(amount: bigint): Promise<string>;
|
|
177
|
+
isAuthorizedAgent(agent: string): Promise<boolean>;
|
|
178
|
+
getDailySpendingLimit(): Promise<bigint>;
|
|
179
|
+
getDailySpent(): Promise<bigint>;
|
|
180
|
+
getRemainingDailyAllowance(): Promise<bigint>;
|
|
181
|
+
getOwner(): Promise<string>;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
declare class AgentXPayClient {
|
|
185
|
+
services: ServicesModule;
|
|
186
|
+
payments: PaymentsModule;
|
|
187
|
+
subscriptions: SubscriptionsModule;
|
|
188
|
+
escrow: EscrowModule;
|
|
189
|
+
wallet: WalletModule;
|
|
190
|
+
private provider;
|
|
191
|
+
private signer;
|
|
192
|
+
constructor(config: AgentXPayConfig);
|
|
193
|
+
discoverServices(filter?: DiscoverFilter): Promise<Service[]>;
|
|
194
|
+
payAndCall(serviceId: bigint, amount: bigint): Promise<string>;
|
|
195
|
+
subscribe(serviceId: bigint, planId: bigint, amount: bigint): Promise<{
|
|
196
|
+
txHash: string;
|
|
197
|
+
subscriptionId: bigint;
|
|
198
|
+
}>;
|
|
199
|
+
/**
|
|
200
|
+
* x402-aware fetch: automatically handles HTTP 402 Payment Required responses
|
|
201
|
+
*/
|
|
202
|
+
fetch(url: string, options?: X402FetchOptions): Promise<Response>;
|
|
203
|
+
private _parsePaymentHeaders;
|
|
204
|
+
getProvider(): ethers.Provider;
|
|
205
|
+
getSigner(): ethers.Signer | null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
declare const MONAD_TESTNET_CHAIN_ID = 10143;
|
|
209
|
+
declare const MONAD_TESTNET_RPC = "https://testnet-rpc.monad.xyz/";
|
|
210
|
+
declare const DEFAULT_CONTRACTS: Record<string, ContractAddresses>;
|
|
211
|
+
|
|
212
|
+
declare function shortenAddress(address: string, chars?: number): string;
|
|
213
|
+
declare function formatEther(wei: bigint): string;
|
|
214
|
+
declare function parseEther(ether: string): bigint;
|
|
215
|
+
declare function isValidAddress(address: string): boolean;
|
|
216
|
+
|
|
217
|
+
export { AgentWalletClient, AgentXPayClient, type AgentXPayConfig, type ContractAddresses, DEFAULT_CONTRACTS, type DiscoverFilter, type EscrowData, EscrowModule, EscrowStatus, MONAD_TESTNET_CHAIN_ID, MONAD_TESTNET_RPC, type PaymentResult, PaymentsModule, type Service, ServicesModule, type Subscription, type SubscriptionPlan, SubscriptionsModule, WalletModule, type X402FetchOptions, type X402PaymentInfo, formatEther, isValidAddress, parseEther, shortenAddress };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
|
|
3
|
+
interface AgentXPayConfig {
|
|
4
|
+
rpcUrl: string;
|
|
5
|
+
privateKey?: string;
|
|
6
|
+
signer?: any;
|
|
7
|
+
contracts?: ContractAddresses;
|
|
8
|
+
network?: "local" | "testnet" | "mainnet";
|
|
9
|
+
}
|
|
10
|
+
interface ContractAddresses {
|
|
11
|
+
serviceRegistry?: string;
|
|
12
|
+
paymentManager?: string;
|
|
13
|
+
subscriptionManager?: string;
|
|
14
|
+
escrow?: string;
|
|
15
|
+
agentWalletFactory?: string;
|
|
16
|
+
}
|
|
17
|
+
interface Service {
|
|
18
|
+
id: bigint;
|
|
19
|
+
provider: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
endpoint: string;
|
|
23
|
+
category: string;
|
|
24
|
+
pricePerCall: bigint;
|
|
25
|
+
isActive: boolean;
|
|
26
|
+
createdAt: bigint;
|
|
27
|
+
}
|
|
28
|
+
interface SubscriptionPlan {
|
|
29
|
+
planId: bigint;
|
|
30
|
+
serviceId: bigint;
|
|
31
|
+
price: bigint;
|
|
32
|
+
duration: bigint;
|
|
33
|
+
name: string;
|
|
34
|
+
}
|
|
35
|
+
interface Subscription {
|
|
36
|
+
subscriptionId: bigint;
|
|
37
|
+
serviceId: bigint;
|
|
38
|
+
planId: bigint;
|
|
39
|
+
subscriber: string;
|
|
40
|
+
startTime: bigint;
|
|
41
|
+
endTime: bigint;
|
|
42
|
+
autoRenew: boolean;
|
|
43
|
+
isActive: boolean;
|
|
44
|
+
}
|
|
45
|
+
declare enum EscrowStatus {
|
|
46
|
+
Created = 0,
|
|
47
|
+
Funded = 1,
|
|
48
|
+
Released = 2,
|
|
49
|
+
Disputed = 3,
|
|
50
|
+
Refunded = 4,
|
|
51
|
+
Resolved = 5
|
|
52
|
+
}
|
|
53
|
+
interface EscrowData {
|
|
54
|
+
escrowId: bigint;
|
|
55
|
+
serviceId: bigint;
|
|
56
|
+
payer: string;
|
|
57
|
+
provider: string;
|
|
58
|
+
amount: bigint;
|
|
59
|
+
status: EscrowStatus;
|
|
60
|
+
createdAt: bigint;
|
|
61
|
+
deadline: bigint;
|
|
62
|
+
description: string;
|
|
63
|
+
}
|
|
64
|
+
interface DiscoverFilter {
|
|
65
|
+
category?: string;
|
|
66
|
+
maxPrice?: bigint;
|
|
67
|
+
isActive?: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface PaymentResult {
|
|
70
|
+
txHash: string;
|
|
71
|
+
serviceId: bigint;
|
|
72
|
+
amount: bigint;
|
|
73
|
+
provider: string;
|
|
74
|
+
}
|
|
75
|
+
interface X402PaymentInfo {
|
|
76
|
+
address: string;
|
|
77
|
+
amount: string;
|
|
78
|
+
token: string;
|
|
79
|
+
serviceId: string;
|
|
80
|
+
chainId: string;
|
|
81
|
+
}
|
|
82
|
+
interface X402FetchOptions extends RequestInit {
|
|
83
|
+
autoPayment?: boolean;
|
|
84
|
+
maxRetries?: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare class ServicesModule {
|
|
88
|
+
private contract;
|
|
89
|
+
constructor(address: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
90
|
+
registerService(name: string, description: string, endpoint: string, category: string, pricePerCall: bigint): Promise<{
|
|
91
|
+
txHash: string;
|
|
92
|
+
serviceId: bigint;
|
|
93
|
+
}>;
|
|
94
|
+
addSubscriptionPlan(serviceId: bigint, name: string, price: bigint, duration: bigint): Promise<{
|
|
95
|
+
txHash: string;
|
|
96
|
+
planId: bigint;
|
|
97
|
+
}>;
|
|
98
|
+
getServiceDetails(serviceId: bigint): Promise<Service>;
|
|
99
|
+
discoverServices(filter?: DiscoverFilter): Promise<Service[]>;
|
|
100
|
+
getSubscriptionPlans(serviceId: bigint): Promise<SubscriptionPlan[]>;
|
|
101
|
+
getServiceCount(): Promise<bigint>;
|
|
102
|
+
private _mapService;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
declare class PaymentsModule {
|
|
106
|
+
private contract;
|
|
107
|
+
private address;
|
|
108
|
+
private signerOrProvider;
|
|
109
|
+
constructor(address: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
110
|
+
private getContract;
|
|
111
|
+
payPerUse(serviceId: bigint, amount: bigint): Promise<PaymentResult>;
|
|
112
|
+
batchPay(serviceIds: bigint[], totalAmount: bigint): Promise<string>;
|
|
113
|
+
deposit(amount: bigint): Promise<string>;
|
|
114
|
+
withdraw(amount: bigint): Promise<string>;
|
|
115
|
+
payFromBalance(serviceId: bigint): Promise<string>;
|
|
116
|
+
withdrawProviderEarnings(): Promise<string>;
|
|
117
|
+
getUserBalance(address: string): Promise<bigint>;
|
|
118
|
+
getProviderEarnings(address: string): Promise<bigint>;
|
|
119
|
+
getPaymentCount(address: string): Promise<bigint>;
|
|
120
|
+
getTotalSpent(address: string): Promise<bigint>;
|
|
121
|
+
getContractAddress(): string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare class SubscriptionsModule {
|
|
125
|
+
private contract;
|
|
126
|
+
constructor(address: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
127
|
+
private getContract;
|
|
128
|
+
subscribe(serviceId: bigint, planId: bigint, amount: bigint): Promise<{
|
|
129
|
+
txHash: string;
|
|
130
|
+
subscriptionId: bigint;
|
|
131
|
+
}>;
|
|
132
|
+
cancelSubscription(subscriptionId: bigint): Promise<string>;
|
|
133
|
+
renewSubscription(subscriptionId: bigint, amount: bigint): Promise<string>;
|
|
134
|
+
toggleAutoRenew(subscriptionId: bigint): Promise<string>;
|
|
135
|
+
getSubscription(subscriptionId: bigint): Promise<Subscription>;
|
|
136
|
+
getUserSubscriptions(address: string): Promise<bigint[]>;
|
|
137
|
+
isActive(subscriptionId: bigint): Promise<boolean>;
|
|
138
|
+
checkAccess(userAddress: string, serviceId: bigint): Promise<boolean>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare class EscrowModule {
|
|
142
|
+
private contract;
|
|
143
|
+
constructor(address: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
144
|
+
private getContract;
|
|
145
|
+
createEscrow(serviceId: bigint, provider: string, deadline: bigint, description: string, amount: bigint): Promise<{
|
|
146
|
+
txHash: string;
|
|
147
|
+
escrowId: bigint;
|
|
148
|
+
}>;
|
|
149
|
+
releaseEscrow(escrowId: bigint): Promise<string>;
|
|
150
|
+
disputeEscrow(escrowId: bigint): Promise<string>;
|
|
151
|
+
refundEscrow(escrowId: bigint): Promise<string>;
|
|
152
|
+
getEscrow(escrowId: bigint): Promise<EscrowData>;
|
|
153
|
+
getUserEscrows(address: string): Promise<bigint[]>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare class WalletModule {
|
|
157
|
+
private factoryContract;
|
|
158
|
+
private signerOrProvider;
|
|
159
|
+
constructor(factoryAddress: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
160
|
+
private getContract;
|
|
161
|
+
createWallet(dailyLimit: bigint): Promise<{
|
|
162
|
+
txHash: string;
|
|
163
|
+
walletAddress: string;
|
|
164
|
+
}>;
|
|
165
|
+
getWallets(owner: string): Promise<string[]>;
|
|
166
|
+
getWalletInstance(walletAddress: string): AgentWalletClient;
|
|
167
|
+
}
|
|
168
|
+
declare class AgentWalletClient {
|
|
169
|
+
private contract;
|
|
170
|
+
constructor(address: string, signerOrProvider: ethers.Signer | ethers.Provider);
|
|
171
|
+
execute(to: string, value: bigint, data?: string): Promise<string>;
|
|
172
|
+
setDailySpendingLimit(limit: bigint): Promise<string>;
|
|
173
|
+
authorizeAgent(agent: string): Promise<string>;
|
|
174
|
+
revokeAgent(agent: string): Promise<string>;
|
|
175
|
+
withdrawFunds(amount: bigint): Promise<string>;
|
|
176
|
+
deposit(amount: bigint): Promise<string>;
|
|
177
|
+
isAuthorizedAgent(agent: string): Promise<boolean>;
|
|
178
|
+
getDailySpendingLimit(): Promise<bigint>;
|
|
179
|
+
getDailySpent(): Promise<bigint>;
|
|
180
|
+
getRemainingDailyAllowance(): Promise<bigint>;
|
|
181
|
+
getOwner(): Promise<string>;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
declare class AgentXPayClient {
|
|
185
|
+
services: ServicesModule;
|
|
186
|
+
payments: PaymentsModule;
|
|
187
|
+
subscriptions: SubscriptionsModule;
|
|
188
|
+
escrow: EscrowModule;
|
|
189
|
+
wallet: WalletModule;
|
|
190
|
+
private provider;
|
|
191
|
+
private signer;
|
|
192
|
+
constructor(config: AgentXPayConfig);
|
|
193
|
+
discoverServices(filter?: DiscoverFilter): Promise<Service[]>;
|
|
194
|
+
payAndCall(serviceId: bigint, amount: bigint): Promise<string>;
|
|
195
|
+
subscribe(serviceId: bigint, planId: bigint, amount: bigint): Promise<{
|
|
196
|
+
txHash: string;
|
|
197
|
+
subscriptionId: bigint;
|
|
198
|
+
}>;
|
|
199
|
+
/**
|
|
200
|
+
* x402-aware fetch: automatically handles HTTP 402 Payment Required responses
|
|
201
|
+
*/
|
|
202
|
+
fetch(url: string, options?: X402FetchOptions): Promise<Response>;
|
|
203
|
+
private _parsePaymentHeaders;
|
|
204
|
+
getProvider(): ethers.Provider;
|
|
205
|
+
getSigner(): ethers.Signer | null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
declare const MONAD_TESTNET_CHAIN_ID = 10143;
|
|
209
|
+
declare const MONAD_TESTNET_RPC = "https://testnet-rpc.monad.xyz/";
|
|
210
|
+
declare const DEFAULT_CONTRACTS: Record<string, ContractAddresses>;
|
|
211
|
+
|
|
212
|
+
declare function shortenAddress(address: string, chars?: number): string;
|
|
213
|
+
declare function formatEther(wei: bigint): string;
|
|
214
|
+
declare function parseEther(ether: string): bigint;
|
|
215
|
+
declare function isValidAddress(address: string): boolean;
|
|
216
|
+
|
|
217
|
+
export { AgentWalletClient, AgentXPayClient, type AgentXPayConfig, type ContractAddresses, DEFAULT_CONTRACTS, type DiscoverFilter, type EscrowData, EscrowModule, EscrowStatus, MONAD_TESTNET_CHAIN_ID, MONAD_TESTNET_RPC, type PaymentResult, PaymentsModule, type Service, ServicesModule, type Subscription, type SubscriptionPlan, SubscriptionsModule, WalletModule, type X402FetchOptions, type X402PaymentInfo, formatEther, isValidAddress, parseEther, shortenAddress };
|