@manifoldxyz/client-sdk 0.1.0-beta.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,277 @@
1
+ # Manifold Client SDK
2
+
3
+ The Manifold Storefront SDK enables **headless purchasing and display** of Manifold products.
4
+
5
+ Head to [studio.manifold.xyz](https://studio.manifold.xyz/) to launch your product, then build your own UI and use the SDK to seamlessly integrate product purchasing into your application.
6
+
7
+ ## โœจ Features
8
+
9
+ - **No API keys required** - Works out of the box
10
+ - **TypeScript first** - Full type safety and IntelliSense
11
+ - **Wallet agnostic** - Works with ethers and viem
12
+ - **Support for multiple product types**:
13
+ - Edition
14
+ - Burn/Redeem
15
+ - Blind Mint
16
+ - **Complete purchase flow**:
17
+ - Product data fetching
18
+ - Eligibility checking
19
+ - Price simulation
20
+ - Transaction preparation
21
+ - Cross-chain support (coming soon)
22
+ - Error handling
23
+
24
+ ## ๐Ÿ“ฆ Installation
25
+
26
+ ```bash
27
+ npm install @manifoldxyz/client-sdk
28
+ ```
29
+
30
+ ## ๐Ÿš€ Quick Start
31
+
32
+ ### 1. Import and Initialize
33
+
34
+ ```typescript
35
+ import { createClient } from '@manifoldxyz/client-sdk';
36
+
37
+ const client = createClient({
38
+ httpRPCs: {
39
+ 1: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY",
40
+ 8453: "https://base-mainnet.infura.io/v3/YOUR_KEY"
41
+ }
42
+ });
43
+ ```
44
+
45
+ ### 2. Get Product Data
46
+
47
+ ```typescript
48
+ const url = 'https://manifold.xyz/@meta8eth/id/4150231280'
49
+ const product = await client.getProduct(url); // can also use instanceId directly
50
+ const status = await product.getStatus();
51
+ console.log(`Currently ${status}`);
52
+ ```
53
+
54
+ ### 3. Check Eligibility & Price
55
+
56
+ ```typescript
57
+ const address = '0x...'
58
+ let preparedPurchase;
59
+
60
+ try {
61
+ preparedPurchase = await product.preparePurchase({
62
+ address,
63
+ payload: {
64
+ quantity: 1
65
+ }
66
+ });
67
+ } catch (error) {
68
+ console.log(`Unable to prepare purchase: ${error.message}`);
69
+ return;
70
+ }
71
+
72
+ console.log(`Total cost: ${preparedPurchase.cost.total.formatted}`);
73
+ ```
74
+
75
+ ### 4. Execute Purchase
76
+
77
+ ```typescript
78
+ const order = await product.purchase({
79
+ account: walletAccount,
80
+ preparedPurchase
81
+ });
82
+
83
+ console.log(order.receipts[0].txHash, order.status);
84
+ ```
85
+
86
+ ## ๐Ÿ“š API Reference
87
+
88
+ ### Client Creation
89
+
90
+ #### `createClient(config?)`
91
+
92
+ Creates a new SDK client instance.
93
+
94
+ **Parameters:**
95
+ - `debug` (boolean, optional): Enable debug logs
96
+ - `httpRPCs` (object, optional): Custom RPC URLs by network ID
97
+
98
+ **Example:**
99
+ ```typescript
100
+ const client = createClient({
101
+ debug: true,
102
+ httpRPCs: {
103
+ 1: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY",
104
+ }
105
+ });
106
+ ```
107
+
108
+ ### Client Methods
109
+
110
+ #### `client.getProduct(instanceIdOrUrl)`
111
+
112
+ Fetches detailed product information.
113
+
114
+ **Parameters:**
115
+ - `instanceIdOrUrl` (string): Manifold instance ID or Manifold Product URL
116
+
117
+ **Returns:** `EditionProduct | BurnRedeemProduct | BlindMintProduct`
118
+
119
+ **Example:**
120
+ ```typescript
121
+ const product = await client.getProduct('4150231280');
122
+ // or
123
+ const product = await client.getProduct('https://manifold.xyz/@creator/id/12345');
124
+ ```
125
+
126
+ #### `client.getProductsByWorkspace(workspaceId, options?)`
127
+
128
+ Fetches products from a workspace.
129
+
130
+ **Parameters:**
131
+ - `workspaceId` (string): Workspace identifier
132
+ - `options` (object, optional):
133
+ - `limit` (number): Result limit (1-100)
134
+ - `offset` (number): Offset results
135
+ - `sort` ('latest' | 'oldest'): Sort order
136
+ - `networkId` (number): Filter by network
137
+ - `type` ('edition' | 'burn-redeem' | 'blind-mint'): Filter by type
138
+
139
+ **Example:**
140
+ ```typescript
141
+ const products = await client.getProductsByWorkspace('workspace123', {
142
+ limit: 10,
143
+ sort: 'latest'
144
+ });
145
+ ```
146
+
147
+ ### Product Methods
148
+
149
+ #### `product.getStatus()`
150
+
151
+ Returns the current status of the product.
152
+
153
+ **Returns:** `'active' | 'paused' | 'completed' | 'upcoming'`
154
+
155
+ #### `product.getAllocations(params)`
156
+
157
+ Check allocation quantity for a wallet address.
158
+
159
+ **Parameters:**
160
+ - `recipientAddress` (string): Buyer's wallet address
161
+
162
+ **Returns:**
163
+ ```typescript
164
+ {
165
+ isEligible: boolean;
166
+ reason?: string;
167
+ quantity: number;
168
+ }
169
+ ```
170
+
171
+ #### `product.preparePurchase(params)`
172
+
173
+ Simulates purchase to check eligibility and get total cost.
174
+
175
+ **Parameters:**
176
+ - `address` (string): The address making the purchase
177
+ - `recipientAddress` (string, optional): If different than `address`
178
+ - `networkId` (number, optional): Force transaction on specific network
179
+ - `payload` (object, optional): Product-specific parameters
180
+ - For Edition: `{ quantity: number, code?: string }`
181
+ - For BurnRedeem: `{ burnTokenIds: string[] }`
182
+ - For BlindMint: `{ quantity: number }`
183
+ - `gasBuffer` (object, optional): Additional gas configuration
184
+
185
+ **Returns:** `PreparedPurchase` with cost breakdown and transaction steps
186
+
187
+ #### `product.purchase(params)`
188
+
189
+ Executes the purchase transaction(s).
190
+
191
+ **Parameters:**
192
+ - `account`: Wallet account object
193
+ - `preparedPurchase`: Result from `preparePurchase()`
194
+
195
+ **Returns:** `Order` with transaction receipts and status
196
+
197
+ ## ๐Ÿ”ง Product Types
198
+
199
+ ### Edition Product
200
+
201
+ ```typescript
202
+ interface EditionProduct {
203
+ type: 'edition';
204
+ totalSupply?: number;
205
+ maxPerWallet?: number;
206
+ price: bigint;
207
+ startTime?: Date;
208
+ endTime?: Date;
209
+ // ... base properties
210
+ }
211
+ ```
212
+
213
+ ### Burn/Redeem Product
214
+
215
+ ```typescript
216
+ interface BurnRedeemProduct {
217
+ type: 'burn-redeem';
218
+ burnTokens: BurnToken[];
219
+ redeemTokens: RedeemToken[];
220
+ // ... base properties
221
+ }
222
+ ```
223
+
224
+ ### Blind Mint Product
225
+
226
+ ```typescript
227
+ interface BlindMintProduct {
228
+ type: 'blind-mint';
229
+ revealTime?: Date;
230
+ maxSupply?: number;
231
+ // ... base properties
232
+ }
233
+ ```
234
+
235
+ ## ๐Ÿงช Testing
236
+
237
+ Run the playground to test the SDK:
238
+
239
+ ```bash
240
+ npm run playground
241
+ ```
242
+
243
+ Or run the test suite:
244
+
245
+ ```bash
246
+ npm test
247
+ ```
248
+
249
+ ## ๐Ÿ—๏ธ Development
250
+
251
+ ```bash
252
+ # Install dependencies
253
+ npm install
254
+
255
+ # Build the project
256
+ npm run build
257
+
258
+ # Run tests
259
+ npm test
260
+
261
+ # Run linting
262
+ npm run lint
263
+
264
+ # Type check
265
+ npm run typecheck
266
+ ```
267
+
268
+ ## ๐Ÿ“„ License
269
+
270
+ MIT ยฉ Manifold
271
+
272
+ ## ๐Ÿ”— Links
273
+
274
+ - [Manifold Studio](https://studio.manifold.xyz/)
275
+ - [Documentation](https://docs.manifold.xyz/)
276
+ - [GitHub](https://github.com/manifoldxyz/client-sdk)
277
+