@settlr/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/LICENSE +21 -0
- package/README.md +510 -0
- package/dist/index.d.mts +635 -0
- package/dist/index.d.ts +635 -0
- package/dist/index.js +974 -0
- package/dist/index.mjs +936 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Settlr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
# @settlr/sdk
|
|
2
|
+
|
|
3
|
+
> Solana USDC payments in 7 lines of code
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @settlr/sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add @settlr/sdk
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @settlr/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### 1. Get Your API Key
|
|
18
|
+
|
|
19
|
+
Sign up at [settlr.dev/dashboard](https://settlr.dev/dashboard) and create an API key.
|
|
20
|
+
|
|
21
|
+
### 2. Create a Payment Link
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Settlr } from "@settlr/sdk";
|
|
25
|
+
|
|
26
|
+
const settlr = new Settlr({
|
|
27
|
+
apiKey: "sk_live_xxxxxxxxxxxx", // Your API key
|
|
28
|
+
merchant: {
|
|
29
|
+
name: "My Store",
|
|
30
|
+
walletAddress: "YOUR_SOLANA_WALLET_ADDRESS",
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const payment = await settlr.createPayment({
|
|
35
|
+
amount: 29.99,
|
|
36
|
+
memo: "Premium subscription",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Redirect customer to checkout
|
|
40
|
+
window.location.href = payment.checkoutUrl;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 3. Drop-in Buy Button ⭐ NEW
|
|
44
|
+
|
|
45
|
+
The easiest way to accept payments - just drop in a button:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { SettlrProvider, BuyButton } from "@settlr/sdk";
|
|
49
|
+
|
|
50
|
+
function App() {
|
|
51
|
+
return (
|
|
52
|
+
<SettlrProvider
|
|
53
|
+
config={{
|
|
54
|
+
apiKey: "sk_live_xxxxxxxxxxxx",
|
|
55
|
+
merchant: { name: "GameStore", walletAddress: "YOUR_WALLET" },
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
<BuyButton
|
|
59
|
+
amount={49.99}
|
|
60
|
+
memo="Premium Game Bundle"
|
|
61
|
+
onSuccess={(result) => {
|
|
62
|
+
console.log("Payment successful!", result.signature);
|
|
63
|
+
unlockContent();
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
Buy Now - $49.99
|
|
67
|
+
</BuyButton>
|
|
68
|
+
</SettlrProvider>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 4. Checkout Widget ⭐ NEW
|
|
74
|
+
|
|
75
|
+
Full embeddable checkout with product info:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { CheckoutWidget } from "@settlr/sdk";
|
|
79
|
+
|
|
80
|
+
<CheckoutWidget
|
|
81
|
+
amount={149.99}
|
|
82
|
+
productName="Annual Subscription"
|
|
83
|
+
productDescription="Full access to all premium features"
|
|
84
|
+
productImage="/subscription.png"
|
|
85
|
+
onSuccess={(result) => router.push("/success")}
|
|
86
|
+
onError={(error) => console.error(error)}
|
|
87
|
+
/>;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Direct Payment (with wallet adapter)
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { Settlr } from "@settlr/sdk";
|
|
94
|
+
import { useWallet } from "@solana/wallet-adapter-react";
|
|
95
|
+
|
|
96
|
+
const settlr = new Settlr({
|
|
97
|
+
apiKey: "sk_live_xxxxxxxxxxxx",
|
|
98
|
+
merchant: {
|
|
99
|
+
name: "My Store",
|
|
100
|
+
walletAddress: "YOUR_WALLET",
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// In your component
|
|
105
|
+
const wallet = useWallet();
|
|
106
|
+
|
|
107
|
+
const result = await settlr.pay({
|
|
108
|
+
wallet: {
|
|
109
|
+
publicKey: wallet.publicKey!,
|
|
110
|
+
signTransaction: wallet.signTransaction!,
|
|
111
|
+
},
|
|
112
|
+
amount: 29.99,
|
|
113
|
+
memo: "Order #1234",
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (result.success) {
|
|
117
|
+
console.log("Payment successful!", result.signature);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### React Hook
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { SettlrProvider, useSettlr } from "@settlr/sdk";
|
|
125
|
+
|
|
126
|
+
// Wrap your app
|
|
127
|
+
function App() {
|
|
128
|
+
return (
|
|
129
|
+
<WalletProvider wallets={wallets}>
|
|
130
|
+
<ConnectionProvider endpoint={endpoint}>
|
|
131
|
+
<SettlrProvider
|
|
132
|
+
config={{
|
|
133
|
+
apiKey: "sk_live_xxxxxxxxxxxx",
|
|
134
|
+
merchant: {
|
|
135
|
+
name: "My Store",
|
|
136
|
+
walletAddress: "YOUR_WALLET",
|
|
137
|
+
},
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
<YourApp />
|
|
141
|
+
</SettlrProvider>
|
|
142
|
+
</ConnectionProvider>
|
|
143
|
+
</WalletProvider>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// In your component
|
|
148
|
+
function CheckoutButton() {
|
|
149
|
+
const { pay, connected } = useSettlr();
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<button onClick={() => pay({ amount: 29.99 })} disabled={!connected}>
|
|
153
|
+
Pay $29.99
|
|
154
|
+
</button>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Payment Link Generator Hook ⭐ NEW
|
|
160
|
+
|
|
161
|
+
Generate shareable payment links programmatically:
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
import { usePaymentLink } from "@settlr/sdk";
|
|
165
|
+
|
|
166
|
+
function InvoicePage() {
|
|
167
|
+
const { generateLink, generateQRCode } = usePaymentLink({
|
|
168
|
+
merchantWallet: "YOUR_WALLET",
|
|
169
|
+
merchantName: "My Store",
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const link = generateLink({
|
|
173
|
+
amount: 500,
|
|
174
|
+
memo: "Invoice #1234",
|
|
175
|
+
orderId: "inv_1234",
|
|
176
|
+
});
|
|
177
|
+
// → https://settlr.dev/pay?amount=500&merchant=My+Store&...
|
|
178
|
+
|
|
179
|
+
const qrCode = await generateQRCode({ amount: 500 });
|
|
180
|
+
// → QR code image URL
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## React Components
|
|
185
|
+
|
|
186
|
+
### `<BuyButton>`
|
|
187
|
+
|
|
188
|
+
Drop-in payment button component.
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
<BuyButton
|
|
192
|
+
amount={49.99} // Required: amount in USDC
|
|
193
|
+
memo="Order description" // Optional
|
|
194
|
+
orderId="order_123" // Optional: your order ID
|
|
195
|
+
onSuccess={(result) => {}} // Called on successful payment
|
|
196
|
+
onError={(error) => {}} // Called on payment failure
|
|
197
|
+
onProcessing={() => {}} // Called when payment starts
|
|
198
|
+
useRedirect={false} // Use redirect flow instead of direct payment
|
|
199
|
+
successUrl="https://..." // Redirect URL (if useRedirect=true)
|
|
200
|
+
cancelUrl="https://..." // Cancel URL (if useRedirect=true)
|
|
201
|
+
variant="primary" // "primary" | "secondary" | "outline"
|
|
202
|
+
size="md" // "sm" | "md" | "lg"
|
|
203
|
+
disabled={false}
|
|
204
|
+
className=""
|
|
205
|
+
style={{}}
|
|
206
|
+
>
|
|
207
|
+
Buy Now - $49.99
|
|
208
|
+
</BuyButton>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### `<CheckoutWidget>`
|
|
212
|
+
|
|
213
|
+
Full checkout UI component with product info.
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
<CheckoutWidget
|
|
217
|
+
amount={149.99} // Required
|
|
218
|
+
productName="Annual Subscription" // Required
|
|
219
|
+
productDescription="Description" // Optional
|
|
220
|
+
productImage="/image.png" // Optional
|
|
221
|
+
merchantName="My Store" // Optional (uses config)
|
|
222
|
+
memo="Transaction memo" // Optional
|
|
223
|
+
orderId="order_123" // Optional
|
|
224
|
+
onSuccess={(result) => {}} // Called on success
|
|
225
|
+
onError={(error) => {}} // Called on error
|
|
226
|
+
onCancel={() => {}} // Called on cancel
|
|
227
|
+
theme="dark" // "dark" | "light"
|
|
228
|
+
showBranding={true} // Show "Powered by Settlr"
|
|
229
|
+
className=""
|
|
230
|
+
style={{}}
|
|
231
|
+
/>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## API Keys
|
|
235
|
+
|
|
236
|
+
### Types of Keys
|
|
237
|
+
|
|
238
|
+
| Key Type | Prefix | Use Case |
|
|
239
|
+
| -------- | ---------- | ----------------------------------- |
|
|
240
|
+
| Live | `sk_live_` | Production payments |
|
|
241
|
+
| Test | `sk_test_` | Development/testing (no validation) |
|
|
242
|
+
|
|
243
|
+
### Rate Limits
|
|
244
|
+
|
|
245
|
+
| Tier | Requests/min | Platform Fee |
|
|
246
|
+
| ---------- | ------------ | ------------ |
|
|
247
|
+
| Free | 60 | 2% |
|
|
248
|
+
| Pro | 300 | 1.5% |
|
|
249
|
+
| Enterprise | 1000 | 1% |
|
|
250
|
+
|
|
251
|
+
### Get Your API Key
|
|
252
|
+
|
|
253
|
+
1. Go to [settlr.dev/dashboard](https://settlr.dev/dashboard)
|
|
254
|
+
2. Connect your wallet
|
|
255
|
+
3. Click "Create API Key"
|
|
256
|
+
4. Save the key securely (only shown once!)
|
|
257
|
+
|
|
258
|
+
## API Reference
|
|
259
|
+
|
|
260
|
+
### `Settlr`
|
|
261
|
+
|
|
262
|
+
Main client class.
|
|
263
|
+
|
|
264
|
+
#### Constructor Options
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
interface SettlrConfig {
|
|
268
|
+
merchant: {
|
|
269
|
+
name: string;
|
|
270
|
+
walletAddress: string;
|
|
271
|
+
logoUrl?: string;
|
|
272
|
+
webhookUrl?: string;
|
|
273
|
+
};
|
|
274
|
+
network?: "devnet" | "mainnet-beta"; // default: 'devnet'
|
|
275
|
+
rpcEndpoint?: string;
|
|
276
|
+
testMode?: boolean;
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### Methods
|
|
281
|
+
|
|
282
|
+
##### `createPayment(options)`
|
|
283
|
+
|
|
284
|
+
Create a payment link.
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
const payment = await settlr.createPayment({
|
|
288
|
+
amount: 29.99, // Required: amount in USDC
|
|
289
|
+
memo: 'Order #123', // Optional: description
|
|
290
|
+
orderId: 'order_123', // Optional: your order ID
|
|
291
|
+
successUrl: 'https://...', // Optional: redirect after success
|
|
292
|
+
cancelUrl: 'https://...', // Optional: redirect on cancel
|
|
293
|
+
expiresIn: 3600, // Optional: expiry in seconds (default: 1 hour)
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// Returns
|
|
297
|
+
{
|
|
298
|
+
id: 'pay_abc123',
|
|
299
|
+
amount: 29.99,
|
|
300
|
+
status: 'pending',
|
|
301
|
+
checkoutUrl: 'https://settlr.dev/pay?...',
|
|
302
|
+
qrCode: 'data:image/svg+xml,...',
|
|
303
|
+
createdAt: Date,
|
|
304
|
+
expiresAt: Date,
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
##### `buildTransaction(options)`
|
|
309
|
+
|
|
310
|
+
Build a transaction for signing.
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
const tx = await settlr.buildTransaction({
|
|
314
|
+
payerPublicKey: wallet.publicKey,
|
|
315
|
+
amount: 29.99,
|
|
316
|
+
memo: "Order #123",
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
// Sign and send
|
|
320
|
+
const signature = await wallet.sendTransaction(tx, connection);
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
##### `pay(options)`
|
|
324
|
+
|
|
325
|
+
Execute a direct payment.
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
const result = await settlr.pay({
|
|
329
|
+
wallet: {
|
|
330
|
+
publicKey: wallet.publicKey,
|
|
331
|
+
signTransaction: wallet.signTransaction,
|
|
332
|
+
},
|
|
333
|
+
amount: 29.99,
|
|
334
|
+
memo: 'Order #123',
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// Returns
|
|
338
|
+
{
|
|
339
|
+
success: true,
|
|
340
|
+
signature: '5KtP...',
|
|
341
|
+
amount: 29.99,
|
|
342
|
+
merchantAddress: '...',
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
##### `getPaymentStatus(signature)`
|
|
347
|
+
|
|
348
|
+
Check payment status.
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
const status = await settlr.getPaymentStatus("5KtP...");
|
|
352
|
+
// Returns: 'pending' | 'completed' | 'failed'
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
##### `createCheckoutSession(options)` ⭐ NEW
|
|
356
|
+
|
|
357
|
+
Create a hosted checkout session (like Stripe Checkout).
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
const session = await settlr.createCheckoutSession({
|
|
361
|
+
amount: 29.99,
|
|
362
|
+
description: 'Premium Plan',
|
|
363
|
+
successUrl: 'https://mystore.com/success?session_id={CHECKOUT_SESSION_ID}',
|
|
364
|
+
cancelUrl: 'https://mystore.com/cancel',
|
|
365
|
+
webhookUrl: 'https://mystore.com/api/webhooks/settlr', // Optional
|
|
366
|
+
metadata: { orderId: 'order_123' }, // Optional
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// Redirect to hosted checkout
|
|
370
|
+
window.location.href = session.url;
|
|
371
|
+
|
|
372
|
+
// Returns
|
|
373
|
+
{
|
|
374
|
+
id: 'cs_abc123...',
|
|
375
|
+
url: 'https://settlr.dev/checkout/cs_abc123...',
|
|
376
|
+
expiresAt: 1702659600000, // 30 min expiry
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
## Webhooks ⭐ UPDATED
|
|
381
|
+
|
|
382
|
+
Get notified when payments complete to fulfill orders automatically.
|
|
383
|
+
|
|
384
|
+
### Quick Setup (Next.js)
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
// app/api/webhooks/settlr/route.ts
|
|
388
|
+
import { createWebhookHandler } from "@settlr/sdk";
|
|
389
|
+
|
|
390
|
+
export const POST = createWebhookHandler({
|
|
391
|
+
secret: process.env.SETTLR_WEBHOOK_SECRET!,
|
|
392
|
+
handlers: {
|
|
393
|
+
"payment.completed": async (event) => {
|
|
394
|
+
console.log("Payment completed!", event.payment.id);
|
|
395
|
+
await fulfillOrder(event.payment.orderId);
|
|
396
|
+
await sendConfirmationEmail(event.payment);
|
|
397
|
+
},
|
|
398
|
+
"payment.failed": async (event) => {
|
|
399
|
+
await notifyCustomer(event.payment.orderId);
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
});
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Express.js
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
import express from "express";
|
|
409
|
+
import { createWebhookHandler } from "@settlr/sdk";
|
|
410
|
+
|
|
411
|
+
const app = express();
|
|
412
|
+
|
|
413
|
+
app.post(
|
|
414
|
+
"/webhooks/settlr",
|
|
415
|
+
express.raw({ type: "application/json" }),
|
|
416
|
+
createWebhookHandler({
|
|
417
|
+
secret: process.env.SETTLR_WEBHOOK_SECRET!,
|
|
418
|
+
handlers: {
|
|
419
|
+
"payment.completed": async (event) => {
|
|
420
|
+
await fulfillOrder(event.payment.orderId);
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
})
|
|
424
|
+
);
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Manual Verification
|
|
428
|
+
|
|
429
|
+
```typescript
|
|
430
|
+
import { verifyWebhookSignature, parseWebhookPayload } from "@settlr/sdk";
|
|
431
|
+
|
|
432
|
+
export async function POST(request: Request) {
|
|
433
|
+
const signature = request.headers.get("x-settlr-signature")!;
|
|
434
|
+
const body = await request.text();
|
|
435
|
+
|
|
436
|
+
// Verify signature
|
|
437
|
+
if (!verifyWebhookSignature(body, signature, process.env.WEBHOOK_SECRET!)) {
|
|
438
|
+
return new Response("Invalid signature", { status: 401 });
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const event = JSON.parse(body);
|
|
442
|
+
|
|
443
|
+
if (event.type === "payment.completed") {
|
|
444
|
+
await fulfillOrder(event.payment.orderId);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return new Response("OK", { status: 200 });
|
|
448
|
+
}
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### Webhook Events
|
|
452
|
+
|
|
453
|
+
| Event | Description |
|
|
454
|
+
| ------------------- | -------------------------- |
|
|
455
|
+
| `payment.created` | Payment link was created |
|
|
456
|
+
| `payment.completed` | Payment confirmed on-chain |
|
|
457
|
+
| `payment.failed` | Payment failed |
|
|
458
|
+
| `payment.expired` | Payment link expired |
|
|
459
|
+
| `payment.refunded` | Payment was refunded |
|
|
460
|
+
|
|
461
|
+
### Webhook Payload
|
|
462
|
+
|
|
463
|
+
```json
|
|
464
|
+
{
|
|
465
|
+
"id": "evt_abc123",
|
|
466
|
+
"type": "payment.completed",
|
|
467
|
+
"payment": {
|
|
468
|
+
"id": "pay_xyz789",
|
|
469
|
+
"amount": 29.99,
|
|
470
|
+
"status": "completed",
|
|
471
|
+
"orderId": "order_123",
|
|
472
|
+
"memo": "Premium subscription",
|
|
473
|
+
"txSignature": "5KtP...",
|
|
474
|
+
"payerAddress": "7xKX...3mPq",
|
|
475
|
+
"merchantAddress": "4dGo...7Ywd"
|
|
476
|
+
},
|
|
477
|
+
"timestamp": "2025-12-17T10:30:00.000Z",
|
|
478
|
+
"signature": "hmac_sha256_signature"
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
##### `getMerchantBalance()`
|
|
483
|
+
|
|
484
|
+
Get merchant's USDC balance.
|
|
485
|
+
|
|
486
|
+
```typescript
|
|
487
|
+
const balance = await settlr.getMerchantBalance();
|
|
488
|
+
console.log(`Balance: $${balance} USDC`);
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### Utilities
|
|
492
|
+
|
|
493
|
+
```typescript
|
|
494
|
+
import { formatUSDC, parseUSDC, shortenAddress } from "@settlr/sdk";
|
|
495
|
+
|
|
496
|
+
formatUSDC(29990000n); // "29.99"
|
|
497
|
+
parseUSDC(29.99); // 29990000n
|
|
498
|
+
shortenAddress("ABC...XYZ"); // "ABC...XYZ"
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
## Networks
|
|
502
|
+
|
|
503
|
+
| Network | USDC Mint |
|
|
504
|
+
| ------- | ---------------------------------------------- |
|
|
505
|
+
| Devnet | `4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU` |
|
|
506
|
+
| Mainnet | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` |
|
|
507
|
+
|
|
508
|
+
## License
|
|
509
|
+
|
|
510
|
+
MIT
|