@proofrails/sdk 1.1.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.
- package/README.md +244 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,244 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
````md
|
|
3
|
+
# ProofRails SDK
|
|
4
|
+
|
|
5
|
+
**Beginner friendly SDK for creating blockchain verifiable ISO 20022 payment receipts**
|
|
6
|
+
|
|
7
|
+
Create compliant, auditable payment receipts with just a few lines of code. No blockchain expertise required.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
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
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm i @proofrails-sdk/sdk
|
|
22
|
+
# or
|
|
23
|
+
yarn add @proofrails/sdk
|
|
24
|
+
````
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### Option 1, Create New Project (Easiest)
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
import ProofRails from '@proofrails/sdk';
|
|
32
|
+
|
|
33
|
+
// Create a new project automatically
|
|
34
|
+
const { client, apiKey, projectId } = await ProofRails.createProject({
|
|
35
|
+
label: 'My App'
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
console.log('Your API Key:', apiKey); // Save this
|
|
39
|
+
console.log('Your Project ID:', projectId);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Option 2, Use Existing API Key
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
import ProofRails from '@proofrails/sdk';
|
|
46
|
+
|
|
47
|
+
const proofrails = new ProofRails({
|
|
48
|
+
apiKey: 'your-api-key-here'
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Templates (Beginner Friendly)
|
|
53
|
+
|
|
54
|
+
### Payment Receipt
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
const receipt = await proofrails.templates.payment({
|
|
58
|
+
amount: 100,
|
|
59
|
+
from: 'Alice',
|
|
60
|
+
to: 'Bob',
|
|
61
|
+
purpose: 'Freelance web development',
|
|
62
|
+
transactionHash: '0x123...'
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
console.log('Receipt ID:', receipt.id);
|
|
66
|
+
console.log('Status:', receipt.status);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Donation Receipt
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
const receipt = await proofrails.templates.donation({
|
|
73
|
+
amount: 50,
|
|
74
|
+
donor: 'John Doe',
|
|
75
|
+
organization: 'Red Cross',
|
|
76
|
+
campaign: 'Disaster Relief 2024',
|
|
77
|
+
transactionHash: '0x456...'
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Escrow Release
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
const receipt = await proofrails.templates.escrow({
|
|
85
|
+
amount: 1000,
|
|
86
|
+
buyer: 'Alice',
|
|
87
|
+
seller: 'Bob',
|
|
88
|
+
escrowId: 'ESC-2024-001',
|
|
89
|
+
releaseReason: 'Milestone 1 completed',
|
|
90
|
+
transactionHash: '0x789...'
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Grant Disbursement
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
const receipt = await proofrails.templates.grant({
|
|
98
|
+
amount: 5000,
|
|
99
|
+
grantee: 'Research Lab',
|
|
100
|
+
grantor: 'Science Foundation',
|
|
101
|
+
grantId: 'GR-2024-001',
|
|
102
|
+
purpose: 'Climate change research',
|
|
103
|
+
transactionHash: '0xabc...'
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Refund
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
const receipt = await proofrails.templates.refund({
|
|
111
|
+
amount: 25,
|
|
112
|
+
originalPayment: 'receipt-id-123',
|
|
113
|
+
reason: 'Product returned',
|
|
114
|
+
customer: 'Jane Smith',
|
|
115
|
+
transactionHash: '0xdef...'
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Core Operations
|
|
120
|
+
|
|
121
|
+
### Get Receipt
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
const receipt = await proofrails.receipts.get('receipt-id');
|
|
125
|
+
|
|
126
|
+
console.log(receipt.status);
|
|
127
|
+
console.log(receipt.amount);
|
|
128
|
+
console.log(receipt.anchorTx);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### List Receipts
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
const { items, total } = await proofrails.receipts.list({
|
|
135
|
+
limit: 10,
|
|
136
|
+
status: 'anchored'
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
items.forEach(r => {
|
|
140
|
+
console.log(r.id, r.amount);
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Download Artifacts
|
|
145
|
+
|
|
146
|
+
```javascript
|
|
147
|
+
const artifacts = await proofrails.receipts.getArtifacts('receipt-id');
|
|
148
|
+
|
|
149
|
+
console.log('ISO XML:', artifacts.pain001Url);
|
|
150
|
+
console.log('Bundle:', artifacts.bundleUrl);
|
|
151
|
+
console.log('Manifest:', artifacts.manifestUrl);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Verification
|
|
155
|
+
|
|
156
|
+
### Verify Receipt
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
const verification = await proofrails.verify.byReceiptId('receipt-id');
|
|
160
|
+
|
|
161
|
+
if (verification.valid && verification.onChain) {
|
|
162
|
+
console.log('Receipt is valid and on chain');
|
|
163
|
+
console.log('Anchor TX:', verification.anchorTx);
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Verify by Bundle Hash
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
const verification = await proofrails.verify.byHash('0x123...');
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Get Verification Proof
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
const proof = await proofrails.verify.getProof('receipt-id');
|
|
177
|
+
|
|
178
|
+
console.log('Bundle Hash:', proof.bundleHash);
|
|
179
|
+
console.log('Block Number:', proof.blockNumber);
|
|
180
|
+
console.log('Timestamp:', proof.timestamp);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Live Updates
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
const listener = proofrails.events.listen('receipt-id', update => {
|
|
187
|
+
console.log('Status:', update.status);
|
|
188
|
+
|
|
189
|
+
if (update.status === 'anchored') {
|
|
190
|
+
console.log('Receipt is now on chain');
|
|
191
|
+
listener.stop();
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Embeddable Widgets
|
|
197
|
+
|
|
198
|
+
### Generate Widget
|
|
199
|
+
|
|
200
|
+
```javascript
|
|
201
|
+
const widget = proofrails.embed.widget('receipt-id', {
|
|
202
|
+
theme: 'light',
|
|
203
|
+
width: '100%',
|
|
204
|
+
height: '400px'
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
document.getElementById('receipt').innerHTML = widget.iframeHtml;
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Full Page URL
|
|
211
|
+
|
|
212
|
+
```javascript
|
|
213
|
+
const pageUrl = proofrails.embed.fullPage('receipt-id');
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Networks
|
|
217
|
+
|
|
218
|
+
```javascript
|
|
219
|
+
const proofrails = new ProofRails({
|
|
220
|
+
apiKey: 'your-key',
|
|
221
|
+
network: 'coston2'
|
|
222
|
+
});
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
```javascript
|
|
226
|
+
const proofrails = new ProofRails({
|
|
227
|
+
apiKey: 'your-key',
|
|
228
|
+
network: 'flare'
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
MIT
|
|
235
|
+
|
|
236
|
+
## Support
|
|
237
|
+
|
|
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)
|
|
241
|
+
|
|
242
|
+
**Made with ❤️ by ProofRails**
|
|
243
|
+
|
|
244
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proofrails/sdk",
|
|
3
|
-
"version": "1.
|
|
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",
|