@proofrails/sdk 1.0.0 → 1.2.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 (2) hide show
  1. package/README.md +40 -208
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,29 +1,31 @@
1
+
2
+ ````md
1
3
  # ProofRails SDK
2
4
 
3
- > **Beginner-friendly SDK for creating blockchain-verifiable ISO 20022 payment receipts**
5
+ **Beginner friendly SDK for creating blockchain verifiable ISO 20022 payment receipts**
4
6
 
5
- Create compliant, auditable payment receipts with just a few lines of code. No blockchain expertise required!
7
+ Create compliant, auditable payment receipts with just a few lines of code. No blockchain expertise required.
6
8
 
7
9
  ## Features
8
10
 
9
- - **Zero coding knowledge required** - Use simple templates
10
- - **ISO 20022 compliant** - Generates standard banking messages
11
- - **Blockchain-verified** - Receipts anchored on Flare blockchain
12
- - **Tamper-proof** - Cryptographic evidence bundles
13
- - **Real-time updates** - Live receipt status via SSE
14
- - **Works everywhere** - TypeScript, JavaScript, Node.js, browsers
11
+ - **Zero coding knowledge required**, use simple templates
12
+ - **ISO 20022 compliant**, generates standard banking messages
13
+ - **Blockchain verified**, receipts anchored on Flare blockchain
14
+ - **Tamper proof**, cryptographic evidence bundles
15
+ - **Real time updates**, live receipt status via SSE
16
+ - **Works everywhere**, TypeScript, JavaScript, Node.js, browsers
15
17
 
16
- ## Installation
18
+ ## Installation
17
19
 
18
20
  ```bash
19
- npm install @proofrails/sdk
21
+ npm i @proofrails-sdk/sdk
20
22
  # or
21
23
  yarn add @proofrails/sdk
22
- ```
24
+ ````
23
25
 
24
- ## Quick Start
26
+ ## Quick Start
25
27
 
26
- ### Option 1: Create New Project (Easiest)
28
+ ### Option 1, Create New Project (Easiest)
27
29
 
28
30
  ```javascript
29
31
  import ProofRails from '@proofrails/sdk';
@@ -33,11 +35,11 @@ const { client, apiKey, projectId } = await ProofRails.createProject({
33
35
  label: 'My App'
34
36
  });
35
37
 
36
- console.log('Your API Key:', apiKey); // Save this!
38
+ console.log('Your API Key:', apiKey); // Save this
37
39
  console.log('Your Project ID:', projectId);
38
40
  ```
39
41
 
40
- ### Option 2: Use Existing API Key
42
+ ### Option 2, Use Existing API Key
41
43
 
42
44
  ```javascript
43
45
  import ProofRails from '@proofrails/sdk';
@@ -47,7 +49,7 @@ const proofrails = new ProofRails({
47
49
  });
48
50
  ```
49
51
 
50
- ## Templates (Beginner-Friendly)
52
+ ## Templates (Beginner Friendly)
51
53
 
52
54
  ### Payment Receipt
53
55
 
@@ -114,16 +116,16 @@ const receipt = await proofrails.templates.refund({
114
116
  });
115
117
  ```
116
118
 
117
- ## Core Operations
119
+ ## Core Operations
118
120
 
119
121
  ### Get Receipt
120
122
 
121
123
  ```javascript
122
124
  const receipt = await proofrails.receipts.get('receipt-id');
123
125
 
124
- console.log(receipt.status); // 'pending' or 'anchored'
126
+ console.log(receipt.status);
125
127
  console.log(receipt.amount);
126
- console.log(receipt.anchorTx); // Blockchain transaction (if anchored)
128
+ console.log(receipt.anchorTx);
127
129
  ```
128
130
 
129
131
  ### List Receipts
@@ -134,8 +136,8 @@ const { items, total } = await proofrails.receipts.list({
134
136
  status: 'anchored'
135
137
  });
136
138
 
137
- items.forEach(receipt => {
138
- console.log(receipt.id, receipt.amount);
139
+ items.forEach(r => {
140
+ console.log(r.id, r.amount);
139
141
  });
140
142
  ```
141
143
 
@@ -149,7 +151,7 @@ console.log('Bundle:', artifacts.bundleUrl);
149
151
  console.log('Manifest:', artifacts.manifestUrl);
150
152
  ```
151
153
 
152
- ## Verification
154
+ ## Verification
153
155
 
154
156
  ### Verify Receipt
155
157
 
@@ -157,7 +159,7 @@ console.log('Manifest:', artifacts.manifestUrl);
157
159
  const verification = await proofrails.verify.byReceiptId('receipt-id');
158
160
 
159
161
  if (verification.valid && verification.onChain) {
160
- console.log(' Receipt is valid and on-chain!');
162
+ console.log('Receipt is valid and on chain');
161
163
  console.log('Anchor TX:', verification.anchorTx);
162
164
  }
163
165
  ```
@@ -178,22 +180,20 @@ console.log('Block Number:', proof.blockNumber);
178
180
  console.log('Timestamp:', proof.timestamp);
179
181
  ```
180
182
 
181
- ## Live Updates
183
+ ## Live Updates
182
184
 
183
185
  ```javascript
184
- // Listen to receipt status changes in real-time
185
- const listener = proofrails.events.listen('receipt-id', (update) => {
186
+ const listener = proofrails.events.listen('receipt-id', update => {
186
187
  console.log('Status:', update.status);
187
-
188
+
188
189
  if (update.status === 'anchored') {
189
- console.log('Receipt is now on-chain!');
190
- console.log('Anchor TX:', update.anchorTx);
191
- listener.stop(); // Stop listening
190
+ console.log('Receipt is now on chain');
191
+ listener.stop();
192
192
  }
193
193
  });
194
194
  ```
195
195
 
196
- ## Embeddable Widgets
196
+ ## Embeddable Widgets
197
197
 
198
198
  ### Generate Widget
199
199
 
@@ -204,7 +204,6 @@ const widget = proofrails.embed.widget('receipt-id', {
204
204
  height: '400px'
205
205
  });
206
206
 
207
- // Use in HTML
208
207
  document.getElementById('receipt').innerHTML = widget.iframeHtml;
209
208
  ```
210
209
 
@@ -212,201 +211,34 @@ document.getElementById('receipt').innerHTML = widget.iframeHtml;
212
211
 
213
212
  ```javascript
214
213
  const pageUrl = proofrails.embed.fullPage('receipt-id');
215
- // https://middleware.com/receipt/receipt-id
216
- ```
217
-
218
- ## Statements
219
-
220
- ### Generate Intraday Statement
221
-
222
- ```javascript
223
- const statement = await proofrails.statements.intraday({
224
- dateFrom: '2024-01-01',
225
- dateTo: '2024-01-31',
226
- accountId: 'my-account'
227
- });
228
-
229
- console.log('Download:', statement.downloadUrl);
230
- ```
231
-
232
- ### Generate End-of-Day Statement
233
-
234
- ```javascript
235
- const statement = await proofrails.statements.endOfDay({
236
- dateTo: '2024-01-31',
237
- accountId: 'my-account'
238
- });
239
214
  ```
240
215
 
241
- ## Project Management
242
-
243
- ### Get Project Info
216
+ ## Networks
244
217
 
245
218
  ```javascript
246
- const info = await proofrails.project.getInfo();
247
- console.log('Project ID:', info.projectId);
248
- ```
249
-
250
- ### Rotate API Key
251
-
252
- ```javascript
253
- const newKey = await proofrails.project.rotateKey();
254
- console.log('New API Key:', newKey.apiKey); // Save this!
255
-
256
- // Update client with new key
257
- proofrails.setApiKey(newKey.apiKey);
258
- ```
259
-
260
- ## Admin Operations
261
-
262
- ```javascript
263
- const admin = new ProofRails({ adminToken: 'your-admin-token' });
264
-
265
- // Create API key for specific project
266
- const key = await admin.admin.createKey({
267
- projectId: 'proj-123',
268
- label: 'Production Key'
269
- });
270
-
271
- label: 'Production Key'
272
- });
273
-
274
- // Delete API key
275
- await admin.admin.deleteKey('key-id');
276
- ```
277
-
278
- ## Networks
279
-
280
- ```javascript
281
- // Testnet (default)
282
219
  const proofrails = new ProofRails({
283
220
  apiKey: 'your-key',
284
221
  network: 'coston2'
285
222
  });
286
-
287
- // Mainnet
288
- const proofrails = new ProofRails({
289
- apiKey: 'your-key',
290
- network: 'flare'
291
- });
292
223
  ```
293
224
 
294
- ## Advanced Configuration
295
-
296
225
  ```javascript
297
226
  const proofrails = new ProofRails({
298
227
  apiKey: 'your-key',
299
- network: 'coston2',
300
- baseUrl: 'https://custom-middleware.com', // Optional
301
- timeout: 60000 // Request timeout in ms (default: 30000)
302
- });
303
- ```
304
-
305
- ## React Hooks (New!)
306
-
307
- The SDK exports dedicated React hooks for the easiest integration experience.
308
-
309
- ### Setup
310
-
311
- ```typescript
312
- import { useProofRails } from '@proofrails/sdk/react';
313
-
314
- // Initialize the hook
315
- const sdk = useProofRails({
316
- apiKey: 'your-api-key'
317
- });
318
- ```
319
-
320
- ### Sending Payments (Zero Boilerplate)
321
-
322
- ```typescript
323
- import { useProofRailsPayment } from '@proofrails/sdk/react';
324
-
325
- const { send, loading, receipt, status } = useProofRailsPayment(sdk);
326
-
327
- const handleMyButton = async () => {
328
- await send({
329
- amount: "10.0",
330
- to: "0xReceiverAddress...",
331
- purpose: "Payment for Services"
332
- });
333
- };
334
- ```
335
-
336
- ### Self-Serve Project Creation
337
-
338
- ```typescript
339
- import { useCreateProject } from '@proofrails/sdk/react';
340
-
341
- const { create, loading } = useCreateProject();
342
-
343
- const setup = async () => {
344
- const { apiKey, projectId } = await create("My New dApp");
345
- console.log("My new key:", apiKey);
346
- };
347
- ```
348
-
349
- ## TypeScript Support
350
-
351
- Full TypeScript support with type definitions included:
352
-
353
- ```typescript
354
- import ProofRails, { Receipt, VerificationResult } from '@proofrails/sdk';
355
-
356
- const proofrails = new ProofRails({ apiKey: 'your-key' });
357
-
358
- const receipt: Receipt = await proofrails.templates.payment({
359
- amount: 100,
360
- from: 'Alice',
361
- to: 'Bob',
362
- purpose: 'Payment',
363
- transactionHash: '0x123...'
228
+ network: 'flare'
364
229
  });
365
-
366
- const verification: VerificationResult = await proofrails.verify.byReceiptId(receipt.id);
367
230
  ```
368
231
 
369
- ## JavaScript (No TypeScript)
370
-
371
- Works perfectly in plain JavaScript too:
372
-
373
- ```javascript
374
- const ProofRails = require('@proofrails/sdk');
375
-
376
- const proofrails = new ProofRails({ apiKey: 'your-key' });
377
-
378
- // Same API, no types needed!
379
- ```
380
-
381
- ## Error Handling
382
-
383
- ```javascript
384
- import { ProofRailsError } from '@proofrails/sdk';
385
-
386
- try {
387
- const receipt = await proofrails.receipts.get('invalid-id');
388
- } catch (error) {
389
- if (error instanceof ProofRailsError) {
390
- console.error('Error:', error.message);
391
- console.error('Code:', error.code);
392
- console.error('Status:', error.statusCode);
393
- }
394
- }
395
- ```
396
-
397
- ## License
232
+ ## License
398
233
 
399
234
  MIT
400
235
 
401
- ## Support
236
+ ## Support
402
237
 
403
- - Documentation: [docs.proofrails.com](https://docs.proofrails.com)
404
- - Issues: [GitHub Issues](https://github.com/proofrails/proofrails-sdk/issues)
405
- - Email: support@proofrails.com
406
-
407
- ---
238
+ * Documentation, [https://www.flarestudio.xyz/sdk/proofrails-sdk/overview](https://www.flarestudio.xyz/sdk/proofrails-sdk/overview)
239
+ * Repository, [https://github.com/Elite-tch/Proofrails-sdk.git](https://github.com/Elite-tch/Proofrails-sdk.git)
240
+ * Email, [izuchukwujohnbosco95@gmail.com](mailto:izuchukwujohnbosco95@gmail.com)
408
241
 
409
242
  **Made with ❤️ by ProofRails**
410
- # Proofrails-sdk
411
-
412
-
243
+
244
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proofrails/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Beginner-friendly SDK for ProofRails ISO 20022 Middleware - Create blockchain-verifiable payment receipts with zero coding knowledge",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",