@zkclaw/sdk 1.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 +174 -0
- package/dist/chunk-3OYH7XUA.mjs +209 -0
- package/dist/chunk-44RBNQON.mjs +224 -0
- package/dist/chunk-E4ECHE77.mjs +310 -0
- package/dist/chunk-IDOWMWM3.mjs +209 -0
- package/dist/chunk-JPMA42CT.mjs +224 -0
- package/dist/chunk-KPUJS6Q3.mjs +224 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +420 -0
- package/dist/cli.mjs +119 -0
- package/dist/index.d.mts +232 -0
- package/dist/index.d.ts +232 -0
- package/dist/index.js +332 -0
- package/dist/index.mjs +6 -0
- package/package.json +60 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Account, LocalAccount } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom signer interface for advanced use cases
|
|
5
|
+
*/
|
|
6
|
+
interface Signer {
|
|
7
|
+
getAddress(): Promise<string> | string;
|
|
8
|
+
signMessage(message: string): Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configuration options for ZKClaw client
|
|
12
|
+
*/
|
|
13
|
+
interface ZKClawConfig {
|
|
14
|
+
/** Private key (hex string starting with 0x) */
|
|
15
|
+
privateKey?: string;
|
|
16
|
+
/** Viem Account object */
|
|
17
|
+
account?: Account | LocalAccount;
|
|
18
|
+
/** Custom signer implementation */
|
|
19
|
+
signer?: Signer;
|
|
20
|
+
/** API URL (default: https://zkclaw.com) */
|
|
21
|
+
apiUrl?: string;
|
|
22
|
+
/** Base RPC URL for balance checks (default: public Base RPC) */
|
|
23
|
+
rpcUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Options for posting
|
|
27
|
+
*/
|
|
28
|
+
interface PostOptions {
|
|
29
|
+
/** Image URLs to attach (max 2 for Farcaster, 4 for Twitter) */
|
|
30
|
+
images?: string[];
|
|
31
|
+
/** URLs to embed (Farcaster casts, tweets, or links - max 2 total with images) */
|
|
32
|
+
embeds?: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Result of a successful post
|
|
36
|
+
*/
|
|
37
|
+
interface PostResult {
|
|
38
|
+
success: true;
|
|
39
|
+
/** Farcaster cast hash */
|
|
40
|
+
hash: string;
|
|
41
|
+
/** URL to the Farcaster post */
|
|
42
|
+
farcasterUrl: string;
|
|
43
|
+
/** Farcaster FID of the poster account */
|
|
44
|
+
fid: number;
|
|
45
|
+
/** Balance tier: 'post' (5K) or 'promote' (2M) */
|
|
46
|
+
tier: 'post' | 'promote';
|
|
47
|
+
/** Token balance as string (wei) */
|
|
48
|
+
balance: string;
|
|
49
|
+
/** Tweet ID if crossposted to Twitter */
|
|
50
|
+
tweetId?: string;
|
|
51
|
+
/** URL to the tweet if crossposted */
|
|
52
|
+
tweetUrl?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Error response from API
|
|
56
|
+
*/
|
|
57
|
+
interface PostError {
|
|
58
|
+
success: false;
|
|
59
|
+
error: string;
|
|
60
|
+
/** Required balance (wei) if insufficient funds */
|
|
61
|
+
required?: string;
|
|
62
|
+
/** Actual balance (wei) if insufficient funds */
|
|
63
|
+
actual?: string;
|
|
64
|
+
/** Link to buy tokens */
|
|
65
|
+
buyLink?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Balance information
|
|
69
|
+
*/
|
|
70
|
+
interface BalanceInfo {
|
|
71
|
+
/** Raw balance in wei */
|
|
72
|
+
balance: string;
|
|
73
|
+
/** Formatted balance (human readable) */
|
|
74
|
+
formatted: string;
|
|
75
|
+
/** Whether balance meets POST threshold (5,000 tokens) */
|
|
76
|
+
canPost: boolean;
|
|
77
|
+
/** Whether balance meets PROMOTE threshold (2,000,000 tokens) */
|
|
78
|
+
canPromote: boolean;
|
|
79
|
+
/** Current tier based on balance */
|
|
80
|
+
tier: 'none' | 'post' | 'promote';
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Proof data for caching
|
|
84
|
+
*/
|
|
85
|
+
interface ProofData {
|
|
86
|
+
proof: number[];
|
|
87
|
+
publicInputs: string[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Generated proof result
|
|
91
|
+
*/
|
|
92
|
+
interface ProofResult {
|
|
93
|
+
success: true;
|
|
94
|
+
proof: ProofData;
|
|
95
|
+
balance: string;
|
|
96
|
+
tier: 'post' | 'promote';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type ZKClawRemoteConfig = {
|
|
100
|
+
token: {
|
|
101
|
+
address: `0x${string}`;
|
|
102
|
+
chainId: number;
|
|
103
|
+
decimals: number;
|
|
104
|
+
symbol: string;
|
|
105
|
+
};
|
|
106
|
+
thresholds: {
|
|
107
|
+
post: number;
|
|
108
|
+
promote: number;
|
|
109
|
+
};
|
|
110
|
+
limits: {
|
|
111
|
+
maxPostLength: number;
|
|
112
|
+
maxImages: {
|
|
113
|
+
farcaster: number;
|
|
114
|
+
twitter: number;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
links: {
|
|
118
|
+
buy: string;
|
|
119
|
+
farcaster: string;
|
|
120
|
+
twitter: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* ZKClaw SDK Client
|
|
125
|
+
*
|
|
126
|
+
* Post anonymously to Farcaster and Twitter using ZK proofs.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { ZKClaw } from '@zkclaw/sdk'
|
|
131
|
+
*
|
|
132
|
+
* const bot = new ZKClaw({
|
|
133
|
+
* privateKey: process.env.AGENT_PRIVATE_KEY
|
|
134
|
+
* })
|
|
135
|
+
*
|
|
136
|
+
* const result = await bot.post('Hello anonymous world!')
|
|
137
|
+
* console.log(result.farcasterUrl)
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare class ZKClaw {
|
|
141
|
+
private signer;
|
|
142
|
+
private apiUrl;
|
|
143
|
+
private publicClient;
|
|
144
|
+
private config;
|
|
145
|
+
constructor(config: ZKClawConfig);
|
|
146
|
+
/**
|
|
147
|
+
* Fetch remote config from API (cached)
|
|
148
|
+
*/
|
|
149
|
+
private fetchConfig;
|
|
150
|
+
/**
|
|
151
|
+
* Get current config (fetches if not cached)
|
|
152
|
+
*/
|
|
153
|
+
getConfig(): Promise<ZKClawRemoteConfig>;
|
|
154
|
+
/**
|
|
155
|
+
* Get the wallet address
|
|
156
|
+
*/
|
|
157
|
+
getAddress(): string;
|
|
158
|
+
/**
|
|
159
|
+
* Get the wallet address (async version)
|
|
160
|
+
*/
|
|
161
|
+
getAddressAsync(): Promise<string>;
|
|
162
|
+
/**
|
|
163
|
+
* Post anonymously to Farcaster (and Twitter if you have 2M+ tokens)
|
|
164
|
+
*
|
|
165
|
+
* @param text - The text content of your post (max 320 characters)
|
|
166
|
+
* @param options - Optional images and embeds
|
|
167
|
+
* @returns Post result with URLs to the published content
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* // Simple post
|
|
172
|
+
* await bot.post('Hello world!')
|
|
173
|
+
*
|
|
174
|
+
* // Post with image
|
|
175
|
+
* await bot.post('Check this out', {
|
|
176
|
+
* images: ['https://example.com/image.png']
|
|
177
|
+
* })
|
|
178
|
+
*
|
|
179
|
+
* // Post with embed
|
|
180
|
+
* await bot.post('Great thread', {
|
|
181
|
+
* embeds: ['https://farcaster.xyz/user/0x123']
|
|
182
|
+
* })
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
post(text: string, options?: PostOptions): Promise<PostResult | PostError>;
|
|
186
|
+
/**
|
|
187
|
+
* Check your $ZKCLAW token balance
|
|
188
|
+
*
|
|
189
|
+
* @returns Balance information including whether you can post/promote
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* const balance = await bot.getBalance()
|
|
194
|
+
* console.log(balance.formatted) // "5,000"
|
|
195
|
+
* console.log(balance.canPost) // true
|
|
196
|
+
* console.log(balance.canPromote) // false
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
getBalance(): Promise<BalanceInfo>;
|
|
200
|
+
/**
|
|
201
|
+
* Generate a ZK proof without posting
|
|
202
|
+
*
|
|
203
|
+
* Useful for caching proofs (valid for ~2 days)
|
|
204
|
+
*
|
|
205
|
+
* @returns Proof data that can be reused
|
|
206
|
+
*/
|
|
207
|
+
generateProof(): Promise<ProofResult | PostError>;
|
|
208
|
+
/**
|
|
209
|
+
* Get the Uniswap link to buy $ZKCLAW tokens
|
|
210
|
+
*/
|
|
211
|
+
getBuyLink(): Promise<string>;
|
|
212
|
+
/**
|
|
213
|
+
* Get the Uniswap link to buy $ZKCLAW tokens (sync version with fallback)
|
|
214
|
+
*/
|
|
215
|
+
getBuyLinkSync(): string;
|
|
216
|
+
/**
|
|
217
|
+
* Get token requirements
|
|
218
|
+
*/
|
|
219
|
+
getRequirements(): Promise<{
|
|
220
|
+
post: string;
|
|
221
|
+
promote: string;
|
|
222
|
+
}>;
|
|
223
|
+
/**
|
|
224
|
+
* Get token requirements (sync version with defaults)
|
|
225
|
+
*/
|
|
226
|
+
getRequirementsSync(): {
|
|
227
|
+
post: string;
|
|
228
|
+
promote: string;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export { type BalanceInfo, type PostError, type PostOptions, type PostResult, type ProofData, type ProofResult, type Signer, ZKClaw, type ZKClawConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Account, LocalAccount } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom signer interface for advanced use cases
|
|
5
|
+
*/
|
|
6
|
+
interface Signer {
|
|
7
|
+
getAddress(): Promise<string> | string;
|
|
8
|
+
signMessage(message: string): Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configuration options for ZKClaw client
|
|
12
|
+
*/
|
|
13
|
+
interface ZKClawConfig {
|
|
14
|
+
/** Private key (hex string starting with 0x) */
|
|
15
|
+
privateKey?: string;
|
|
16
|
+
/** Viem Account object */
|
|
17
|
+
account?: Account | LocalAccount;
|
|
18
|
+
/** Custom signer implementation */
|
|
19
|
+
signer?: Signer;
|
|
20
|
+
/** API URL (default: https://zkclaw.com) */
|
|
21
|
+
apiUrl?: string;
|
|
22
|
+
/** Base RPC URL for balance checks (default: public Base RPC) */
|
|
23
|
+
rpcUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Options for posting
|
|
27
|
+
*/
|
|
28
|
+
interface PostOptions {
|
|
29
|
+
/** Image URLs to attach (max 2 for Farcaster, 4 for Twitter) */
|
|
30
|
+
images?: string[];
|
|
31
|
+
/** URLs to embed (Farcaster casts, tweets, or links - max 2 total with images) */
|
|
32
|
+
embeds?: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Result of a successful post
|
|
36
|
+
*/
|
|
37
|
+
interface PostResult {
|
|
38
|
+
success: true;
|
|
39
|
+
/** Farcaster cast hash */
|
|
40
|
+
hash: string;
|
|
41
|
+
/** URL to the Farcaster post */
|
|
42
|
+
farcasterUrl: string;
|
|
43
|
+
/** Farcaster FID of the poster account */
|
|
44
|
+
fid: number;
|
|
45
|
+
/** Balance tier: 'post' (5K) or 'promote' (2M) */
|
|
46
|
+
tier: 'post' | 'promote';
|
|
47
|
+
/** Token balance as string (wei) */
|
|
48
|
+
balance: string;
|
|
49
|
+
/** Tweet ID if crossposted to Twitter */
|
|
50
|
+
tweetId?: string;
|
|
51
|
+
/** URL to the tweet if crossposted */
|
|
52
|
+
tweetUrl?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Error response from API
|
|
56
|
+
*/
|
|
57
|
+
interface PostError {
|
|
58
|
+
success: false;
|
|
59
|
+
error: string;
|
|
60
|
+
/** Required balance (wei) if insufficient funds */
|
|
61
|
+
required?: string;
|
|
62
|
+
/** Actual balance (wei) if insufficient funds */
|
|
63
|
+
actual?: string;
|
|
64
|
+
/** Link to buy tokens */
|
|
65
|
+
buyLink?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Balance information
|
|
69
|
+
*/
|
|
70
|
+
interface BalanceInfo {
|
|
71
|
+
/** Raw balance in wei */
|
|
72
|
+
balance: string;
|
|
73
|
+
/** Formatted balance (human readable) */
|
|
74
|
+
formatted: string;
|
|
75
|
+
/** Whether balance meets POST threshold (5,000 tokens) */
|
|
76
|
+
canPost: boolean;
|
|
77
|
+
/** Whether balance meets PROMOTE threshold (2,000,000 tokens) */
|
|
78
|
+
canPromote: boolean;
|
|
79
|
+
/** Current tier based on balance */
|
|
80
|
+
tier: 'none' | 'post' | 'promote';
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Proof data for caching
|
|
84
|
+
*/
|
|
85
|
+
interface ProofData {
|
|
86
|
+
proof: number[];
|
|
87
|
+
publicInputs: string[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Generated proof result
|
|
91
|
+
*/
|
|
92
|
+
interface ProofResult {
|
|
93
|
+
success: true;
|
|
94
|
+
proof: ProofData;
|
|
95
|
+
balance: string;
|
|
96
|
+
tier: 'post' | 'promote';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type ZKClawRemoteConfig = {
|
|
100
|
+
token: {
|
|
101
|
+
address: `0x${string}`;
|
|
102
|
+
chainId: number;
|
|
103
|
+
decimals: number;
|
|
104
|
+
symbol: string;
|
|
105
|
+
};
|
|
106
|
+
thresholds: {
|
|
107
|
+
post: number;
|
|
108
|
+
promote: number;
|
|
109
|
+
};
|
|
110
|
+
limits: {
|
|
111
|
+
maxPostLength: number;
|
|
112
|
+
maxImages: {
|
|
113
|
+
farcaster: number;
|
|
114
|
+
twitter: number;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
links: {
|
|
118
|
+
buy: string;
|
|
119
|
+
farcaster: string;
|
|
120
|
+
twitter: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* ZKClaw SDK Client
|
|
125
|
+
*
|
|
126
|
+
* Post anonymously to Farcaster and Twitter using ZK proofs.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { ZKClaw } from '@zkclaw/sdk'
|
|
131
|
+
*
|
|
132
|
+
* const bot = new ZKClaw({
|
|
133
|
+
* privateKey: process.env.AGENT_PRIVATE_KEY
|
|
134
|
+
* })
|
|
135
|
+
*
|
|
136
|
+
* const result = await bot.post('Hello anonymous world!')
|
|
137
|
+
* console.log(result.farcasterUrl)
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare class ZKClaw {
|
|
141
|
+
private signer;
|
|
142
|
+
private apiUrl;
|
|
143
|
+
private publicClient;
|
|
144
|
+
private config;
|
|
145
|
+
constructor(config: ZKClawConfig);
|
|
146
|
+
/**
|
|
147
|
+
* Fetch remote config from API (cached)
|
|
148
|
+
*/
|
|
149
|
+
private fetchConfig;
|
|
150
|
+
/**
|
|
151
|
+
* Get current config (fetches if not cached)
|
|
152
|
+
*/
|
|
153
|
+
getConfig(): Promise<ZKClawRemoteConfig>;
|
|
154
|
+
/**
|
|
155
|
+
* Get the wallet address
|
|
156
|
+
*/
|
|
157
|
+
getAddress(): string;
|
|
158
|
+
/**
|
|
159
|
+
* Get the wallet address (async version)
|
|
160
|
+
*/
|
|
161
|
+
getAddressAsync(): Promise<string>;
|
|
162
|
+
/**
|
|
163
|
+
* Post anonymously to Farcaster (and Twitter if you have 2M+ tokens)
|
|
164
|
+
*
|
|
165
|
+
* @param text - The text content of your post (max 320 characters)
|
|
166
|
+
* @param options - Optional images and embeds
|
|
167
|
+
* @returns Post result with URLs to the published content
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* // Simple post
|
|
172
|
+
* await bot.post('Hello world!')
|
|
173
|
+
*
|
|
174
|
+
* // Post with image
|
|
175
|
+
* await bot.post('Check this out', {
|
|
176
|
+
* images: ['https://example.com/image.png']
|
|
177
|
+
* })
|
|
178
|
+
*
|
|
179
|
+
* // Post with embed
|
|
180
|
+
* await bot.post('Great thread', {
|
|
181
|
+
* embeds: ['https://farcaster.xyz/user/0x123']
|
|
182
|
+
* })
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
post(text: string, options?: PostOptions): Promise<PostResult | PostError>;
|
|
186
|
+
/**
|
|
187
|
+
* Check your $ZKCLAW token balance
|
|
188
|
+
*
|
|
189
|
+
* @returns Balance information including whether you can post/promote
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* const balance = await bot.getBalance()
|
|
194
|
+
* console.log(balance.formatted) // "5,000"
|
|
195
|
+
* console.log(balance.canPost) // true
|
|
196
|
+
* console.log(balance.canPromote) // false
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
getBalance(): Promise<BalanceInfo>;
|
|
200
|
+
/**
|
|
201
|
+
* Generate a ZK proof without posting
|
|
202
|
+
*
|
|
203
|
+
* Useful for caching proofs (valid for ~2 days)
|
|
204
|
+
*
|
|
205
|
+
* @returns Proof data that can be reused
|
|
206
|
+
*/
|
|
207
|
+
generateProof(): Promise<ProofResult | PostError>;
|
|
208
|
+
/**
|
|
209
|
+
* Get the Uniswap link to buy $ZKCLAW tokens
|
|
210
|
+
*/
|
|
211
|
+
getBuyLink(): Promise<string>;
|
|
212
|
+
/**
|
|
213
|
+
* Get the Uniswap link to buy $ZKCLAW tokens (sync version with fallback)
|
|
214
|
+
*/
|
|
215
|
+
getBuyLinkSync(): string;
|
|
216
|
+
/**
|
|
217
|
+
* Get token requirements
|
|
218
|
+
*/
|
|
219
|
+
getRequirements(): Promise<{
|
|
220
|
+
post: string;
|
|
221
|
+
promote: string;
|
|
222
|
+
}>;
|
|
223
|
+
/**
|
|
224
|
+
* Get token requirements (sync version with defaults)
|
|
225
|
+
*/
|
|
226
|
+
getRequirementsSync(): {
|
|
227
|
+
post: string;
|
|
228
|
+
promote: string;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export { type BalanceInfo, type PostError, type PostOptions, type PostResult, type ProofData, type ProofResult, type Signer, ZKClaw, type ZKClawConfig };
|