@secondlayer/sdk 10.4.1 → 10.4.2
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 +0 -46
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -595,52 +595,6 @@ verifySecondlayerSignature(
|
|
|
595
595
|
Prefer the per-webhook HMAC (Standard Webhooks) secret instead? Use
|
|
596
596
|
`verifyWebhookSignature(rawBody, headers, secret)` — raw body first.
|
|
597
597
|
|
|
598
|
-
## x402 pay-per-call (accountless)
|
|
599
|
-
|
|
600
|
-
Call the public `/v1/*` reads with **no API key, no account, no Stripe** — pay a
|
|
601
|
-
few hundredths of a cent per request from a Stacks wallet. Payment is **gasless**
|
|
602
|
-
(you sign; we sponsor the STX fee) and uses standard **x402 v2** on `stacks:1`.
|
|
603
|
-
Supported assets: **sBTC** (default), **USDCx**, **STX**.
|
|
604
|
-
|
|
605
|
-
> Keyed (`INSTANCE_TOKEN`) requests skip x402. The rail is for accountless
|
|
606
|
-
> callers on an instance that has it enabled.
|
|
607
|
-
|
|
608
|
-
Drop-in `fetch` that pays on `402` automatically:
|
|
609
|
-
|
|
610
|
-
```typescript
|
|
611
|
-
import { withX402, readX402Receipt } from "@secondlayer/sdk";
|
|
612
|
-
import { privateKeyToAccount } from "@secondlayer/stacks/accounts";
|
|
613
|
-
|
|
614
|
-
const x402fetch = withX402(fetch, {
|
|
615
|
-
account: privateKeyToAccount(process.env.AGENT_STACKS_KEY!), // funded with sBTC/USDCx
|
|
616
|
-
preferAssets: ["sBTC", "USDCx", "STX"], // optional (this is the default)
|
|
617
|
-
maxAmountPerCall: { sBTC: 2000n }, // optional spend guard (atomic units)
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
const res = await x402fetch(
|
|
621
|
-
"http://127.0.0.1:3800/v1/index/events?event_type=ft_transfer",
|
|
622
|
-
);
|
|
623
|
-
const data = await res.json();
|
|
624
|
-
readX402Receipt(res); // { success, txid, payer, network } | null
|
|
625
|
-
```
|
|
626
|
-
|
|
627
|
-
Or a small client returning `{ data, payment }`:
|
|
628
|
-
|
|
629
|
-
```typescript
|
|
630
|
-
import { createX402Client } from "@secondlayer/sdk";
|
|
631
|
-
|
|
632
|
-
const sl = createX402Client({ account }); // baseUrl defaults to http://127.0.0.1:3800
|
|
633
|
-
const { data, payment } = await sl.get("/v1/index/events", {
|
|
634
|
-
query: { event_type: "ft_transfer" },
|
|
635
|
-
});
|
|
636
|
-
```
|
|
637
|
-
|
|
638
|
-
The SDK selects an offer by `preferAssets` (skipping any over `maxAmountPerCall`,
|
|
639
|
-
else throws `X402SpendGuardError`), auto-resolves your account nonce, signs
|
|
640
|
-
origin-only, and retries. A paid call settles on-chain before returning
|
|
641
|
-
(confirmed-tier today, ~seconds; near-instant optimistic serve for Index/Streams
|
|
642
|
-
is rolling out). Discover capabilities at `GET /x402/supported`.
|
|
643
|
-
|
|
644
598
|
## Error Handling
|
|
645
599
|
|
|
646
600
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/sdk",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.2",
|
|
4
4
|
"description": "Decoded Stacks data in your own database — stream rows into your schema, or query the tables you defined.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"prepublishOnly": "bun run build"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@secondlayer/shared": "^11.
|
|
64
|
-
"@secondlayer/stacks": "^
|
|
65
|
-
"@secondlayer/subgraphs": "^4.3.
|
|
63
|
+
"@secondlayer/shared": "^11.6.0",
|
|
64
|
+
"@secondlayer/stacks": "^6.0.0",
|
|
65
|
+
"@secondlayer/subgraphs": "^4.3.4"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@openpkg-ts/cli": "^0.11.3",
|