@quicknode/sdk 3.7.0 → 3.8.1

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 CHANGED
@@ -11,8 +11,12 @@ This is one of four language bindings published from the same Rust core. See the
11
11
  - [Installation](#installation)
12
12
  - [Quick Start](#quick-start)
13
13
  - [Configuration](#configuration)
14
+ - [Option A — Pass config directly](#option-a--pass-config-directly)
15
+ - [Option B — Load from environment (`from_env()`)](#option-b--load-from-environment-from_env)
16
+ - [Custom headers and `User-Agent`](#custom-headers-and-user-agent)
14
17
  - [Platform Support](#platform-support)
15
18
  - [API Reference](#api-reference)
19
+ - [Language conventions](#language-conventions)
16
20
  - [Admin Client](#admin-client)
17
21
  - [Endpoints](#endpoints)
18
22
  - [Endpoint Tags](#endpoint-tags)
@@ -48,6 +52,12 @@ This is one of four language bindings published from the same Rust core. See the
48
52
  - [Sets](#sets)
49
53
  - [Lists](#lists)
50
54
  - [SQL Client](#sql-client)
55
+ - [RPC & Tooling Access](#rpc--tooling-access)
56
+ - [Crypto-micropayment lane (`rpc.call`)](#crypto-micropayment-lane-rpccall)
57
+ - [Wallet generation](#wallet-generation)
58
+ - [x402 credit drawdown (authenticate once, then draw one credit per call)](#x402-credit-drawdown-authenticate-once-then-draw-one-credit-per-call)
59
+ - [Testnet faucet](#testnet-faucet)
60
+ - [MPP payment channel (deposit once, then vouchers)](#mpp-payment-channel-deposit-once-then-vouchers)
51
61
  - [Error Handling](#error-handling)
52
62
  - [License](#license)
53
63
 
@@ -78,6 +88,10 @@ There are two ways to configure the SDK.
78
88
  // Node.js
79
89
  import { QuicknodeSdk } from "quicknode-sdk";
80
90
  const qn = new QuicknodeSdk({ apiKey: "your-key", http: { timeoutSecs: 30 } });
91
+
92
+ // apiKey is optional: the crypto-micropayment lane pays per request instead, so
93
+ // omitting it builds a usable SDK. Every other client still needs one, and
94
+ // fromEnv() always requires QN_SDK__API_KEY.
81
95
  ```
82
96
 
83
97
  ### Option B — Load from environment (`from_env()`)
@@ -1727,6 +1741,171 @@ A host that persists across processes can snapshot the cached token with
1727
1741
  `RpcConfig.endpointUrl` to route every call to a custom HTTP URL by default (no
1728
1742
  JWT minted); a per-call `endpointUrl` overrides it.
1729
1743
 
1744
+ ## Crypto-micropayment lane (`rpc.call`)
1745
+
1746
+ Pay per RPC request with a stablecoin instead of a provisioned account + API key,
1747
+ against Quicknode's `x402.quicknode.com` and `mpp.quicknode.com` gateways. Configure
1748
+ it by setting `payment` on the RPC config; the SDK runs the `402` → sign → resend
1749
+ handshake for you. An API key is **not** required for this lane — build a keyless SDK.
1750
+
1751
+ There are four payment paths. Two pay per request; two amortize one signature over many
1752
+ calls.
1753
+
1754
+ | Path | Entry point | Gateway | Signs |
1755
+ |---|---|---|---|
1756
+ | Per-request x402 | `call` / `callWithReceipt` with `scheme: "x402"` | x402 | once per call |
1757
+ | Per-request MPP charge | `call` / `callWithReceipt` with `scheme: "mpp"` | mpp | once per call |
1758
+ | [x402 credit drawdown](#x402-credit-drawdown-authenticate-once-then-draw-one-credit-per-call) | `gatewayAuthenticate` → `gatewayDrawdownCall` | x402 | once per session |
1759
+ | [MPP payment channel](#mpp-payment-channel-deposit-once-then-vouchers) | `mppOpen` → `mppSessionCall` | mpp | once per channel |
1760
+
1761
+ The signer construction is derived from the scheme and pay network, never stated directly:
1762
+ **x402/EVM** signs an EIP-712 `TransferWithAuthorization`, **x402/Solana** an SPL
1763
+ `TransferChecked` in a v0 tx (the gateway sponsors gas), and **MPP/Tempo** a native Tempo
1764
+ transaction.
1765
+
1766
+ `scheme` selects the gateway for `call` only. The `gateway*` drawdown methods always use
1767
+ the x402 gateway and the `mpp*` channel methods always use the MPP gateway, whatever
1768
+ `scheme` is set to.
1769
+
1770
+ `PaymentConfig` fields:
1771
+
1772
+ | Field | Meaning |
1773
+ |---|---|
1774
+ | `scheme` | `"x402"` (pay-per-request) or `"mpp"` (MPP charge; `"mpp-charge"` is accepted too) |
1775
+ | `key` | raw private key — EVM/Tempo: hex; Solana: base58 64-byte secret |
1776
+ | `payNetwork` | CAIP-2 pay network, e.g. `eip155:84532`, `solana:5eykt4…` |
1777
+ | `asset` | token address/mint to pay in (matches the offered menu entry) |
1778
+ | `maxAmount` | **required** spend ceiling in integer base units of `asset` |
1779
+ | `svmRpcUrl` | optional Solana RPC for x402/Solana payment-build reads (mint + blockhash) |
1780
+ | `baseUrlOverride` | optional gateway base (testing) |
1781
+
1782
+ `network` on the call is the **query** chain (gateway path slug), independent of the
1783
+ pay network. Use `callWithReceipt` to also get the settlement receipt (`reference` =
1784
+ settlement tx hash) — populated on the MPP lane, `null` for x402.
1785
+
1786
+ **Things to know:**
1787
+
1788
+ - **Do not log your own `PaymentConfig`** — the `key` field is readable. The SDK
1789
+ never prints it in its own errors, but `console.log(config)` will show it.
1790
+ - **`maxAmount` is integer base units of the selected asset.** The SDK skips any offered
1791
+ entry above it and refuses to sign one — a guard against an overcharging gateway.
1792
+ - **`PaymentIndeterminateError` means the paid request was sent but the response was lost.**
1793
+ You MAY have been charged — do **not** blindly retry.
1794
+ - **x402/Solana: one payment per call.** Building a payment reads the mint and a recent
1795
+ blockhash from a Solana RPC. The default is a public RPC that **rate-limits
1796
+ aggressively** — set `svmRpcUrl` to your own endpoint at any volume.
1797
+
1798
+ ```typescript
1799
+ import { QuicknodeSdk } from "@quicknode/sdk";
1800
+
1801
+ const qn = new QuicknodeSdk({
1802
+ rpc: {
1803
+ payment: {
1804
+ scheme: "x402",
1805
+ key: process.env.QN_PAYMENT_KEY!,
1806
+ payNetwork: "eip155:84532",
1807
+ asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
1808
+ maxAmount: "10000",
1809
+ },
1810
+ },
1811
+ });
1812
+ const { result, paymentReceipt } = await qn.rpc.callWithReceipt("eth_blockNumber", [], "base-sepolia");
1813
+ console.log(result, paymentReceipt);
1814
+ ```
1815
+
1816
+ ### Wallet generation
1817
+
1818
+ `generatePaymentWallet("evm")` creates a fresh keypair offline — no network call, no funds — for
1819
+ `"evm"`, `"svm"`, or `"tempo"`. The private key is returned **exactly once**, at
1820
+ generation; nothing in the SDK stores or re-derives it, so persist it immediately.
1821
+
1822
+ ```typescript
1823
+ import { generatePaymentWallet } from "@quicknode/sdk";
1824
+
1825
+ const wallet = generatePaymentWallet("evm");
1826
+ console.log("fund this address:", wallet.address);
1827
+ // wallet.key is returned exactly once — persist it now.
1828
+ ```
1829
+
1830
+ ### x402 credit drawdown (authenticate once, then draw one credit per call)
1831
+
1832
+ Cheaper per call than paying per request: one SIWE or SIWS signature mints a session JWT, then
1833
+ each call draws a single credit from the account balance instead of signing a fresh
1834
+ settlement. Minting the session is free and moves no funds, so a host can re-authenticate
1835
+ transparently. Persist it between processes.
1836
+
1837
+ Fund the payment wallet out of band — the testnet faucet below, or by sending funds to
1838
+ `paymentAddress()` directly. Credits are provisioned against the account gateway-side.
1839
+
1840
+ EVM payment networks use SIWE. Solana payment networks use SIWS with an Ed25519
1841
+ signature encoded as Base58. Solana wallets must be funded out of band; the faucet
1842
+ is available for Base Sepolia only.
1843
+
1844
+ | Method | Cost | Returns |
1845
+ |---|---|---|
1846
+ | `paymentAddress()` | free, offline | the wallet address derived from the key |
1847
+ | `gatewayAuthenticate()` | free | `GatewaySession { token, expUnix, accountId }` |
1848
+ | `gatewayCredits(session)` | free | `CreditBalance { accountId, credits }` |
1849
+ | `gatewayDrip(session)` | free (testnet) | `DripReceipt { accountId, transactionHash }` |
1850
+ | `gatewayDrawdownCall(method, session, network, params?)` | 1 credit | the JSON-RPC `result` |
1851
+
1852
+ ```typescript
1853
+ const session = await qn.rpc.gatewayAuthenticate();
1854
+ const balance = await qn.rpc.gatewayCredits(session);
1855
+ console.log("credits:", balance.credits);
1856
+ const result = await qn.rpc.gatewayDrawdownCall("eth_blockNumber", session, "base-sepolia");
1857
+ ```
1858
+
1859
+ A `token_expired` surfaces as an `ApiError` with status 401/403; re-authenticate and retry
1860
+ that call.
1861
+
1862
+ #### Testnet faucet
1863
+
1864
+ `gatewayDrip` requests testnet tokens for the payment **wallet** on Base Sepolia. The
1865
+ gateway allows one drip per account, and it returns the on-chain funding transaction hash
1866
+ — not a credit balance.
1867
+
1868
+ ### MPP payment channel (deposit once, then vouchers)
1869
+
1870
+ Open a payment channel by depositing into the escrow, then authorize each call with a
1871
+ cumulative voucher — one `ecrecover` server-side, no on-chain transaction per call.
1872
+
1873
+ | Method | Cost | Returns |
1874
+ |---|---|---|
1875
+ | `mppOpen(deposit)` | **moves funds** | `ChannelState` — persist it |
1876
+ | `mppTopUp(channel, additionalDeposit)` | **moves funds** | the updated channel state |
1877
+ | `mppStatus(channel)` | **1 request unit** | `ChannelStatus { channelId, acceptedCumulative, spent }` |
1878
+ | `mppSessionCall(method, network, channel, newCumulative, params?)` | 1 request unit | the JSON-RPC `result` |
1879
+ | `mppClose(channel)` | settles on-chain | nothing — refunds the unused deposit |
1880
+
1881
+ ```typescript
1882
+ const channel = await qn.rpc.mppOpen("1000000"); // persist this object
1883
+ const newTotal = (BigInt(channel.cumulativeSpent) + BigInt(channel.perCall)).toString();
1884
+ const result = await qn.rpc.mppSessionCall(
1885
+ "eth_blockNumber", "base-sepolia", channel, newTotal,
1886
+ );
1887
+ // On success, store newTotal as the channel's cumulativeSpent.
1888
+ ```
1889
+
1890
+ **Things to know:**
1891
+
1892
+ - **Persist the channel state.** The gateway exposes no read-only channel endpoint, so a
1893
+ lost local record means opening (and funding) a new channel.
1894
+ - **`mppStatus` is not free.** The gateway prices every session POST as a chargeable
1895
+ request and computes the balance from the *new* spend a voucher authorizes, so the
1896
+ probe advances `cumulativeSpent` by `perCall` exactly like a call. Re-persist the
1897
+ advanced total. It raises `PaymentUnsupportedError` before any network I/O when the
1898
+ channel has no room left for the probe.
1899
+ - **The lifecycle takes no query network.** A channel is scoped by the configured pay
1900
+ network and asset, so one channel funds calls to every supported network. Only
1901
+ `mppSessionCall` takes a network, because it routes an RPC method.
1902
+ - **Amounts are decimal strings, not numbers.** They are `u128` in the core; a JS `number` is an f64 that loses precision above 2^53, so pass and store them as strings.
1903
+ - **Advance `cumulativeSpent` only after a success.** A voucher authorizes the running total
1904
+ *after* the call; re-presenting the current high-water mark authorizes zero and is
1905
+ always refused with `insufficient-balance`.
1906
+
1907
+
1908
+
1730
1909
  ## Error Handling
1731
1910
 
1732
1911
  Every binding exposes a typed exception hierarchy derived from the core `SdkError`
@@ -1743,8 +1922,12 @@ subclass to branch on transport vs. API semantics.
1743
1922
  | `ApiError` | non-2xx HTTP response | `status`, `body` |
1744
1923
  | `DecodeError` | 2xx response but JSON parse failed | `body` |
1745
1924
  | `RpcError` | JSON-RPC call returned an `error` member | `code`, `message` |
1925
+ | `PaymentError` | base class for the crypto-micropayment lane | — |
1926
+ | `PaymentUnsupportedError` | no offered payment option matched your selector (or all were over `max_amount`/unsupported) | — |
1927
+ | `PaymentRejectedError` | the gateway rejected a signed payment (terminal, one resend only) | `status`, `body` |
1928
+ | `PaymentIndeterminateError` | paid request sent but response lost — MAY have been charged; do NOT blindly retry | — |
1746
1929
 
1747
- Class names: Importable from `@quicknode/sdk`: `QuicknodeError`, `ConfigError`, `HttpError`, `TimeoutError`, `ConnectionError`, `ApiError`, `DecodeError`, `RpcError`. All extend `Error`.
1930
+ Class names: Importable from `@quicknode/sdk`: `QuicknodeError`, `ConfigError`, `HttpError`, `TimeoutError`, `ConnectionError`, `ApiError`, `DecodeError`, `RpcError`, `PaymentError`, `PaymentUnsupportedError`, `PaymentRejectedError`, `PaymentIndeterminateError`. All extend `Error`.
1748
1931
 
1749
1932
  ```typescript
1750
1933
  // Node.js
package/errors.js CHANGED
@@ -62,7 +62,40 @@ class RpcError extends QuicknodeError {
62
62
  }
63
63
  }
64
64
 
65
- const TAG_RE = /^\[(Config|Http|Timeout|Connect|Api|Decode|Rpc)\|([^|]+)\|([^\]]+)\](.*)$/s;
65
+ // Payment-lane errors. PaymentError is the family base; PaymentRejectedError
66
+ // carries the gateway status/body; PaymentIndeterminateError is its own class
67
+ // so callers can catch "may have been charged — do not retry" distinctly.
68
+ class PaymentError extends QuicknodeError {
69
+ constructor(message) {
70
+ super(message);
71
+ this.name = "PaymentError";
72
+ }
73
+ }
74
+
75
+ class PaymentUnsupportedError extends PaymentError {
76
+ constructor(message) {
77
+ super(message);
78
+ this.name = "PaymentUnsupportedError";
79
+ }
80
+ }
81
+
82
+ class PaymentRejectedError extends PaymentError {
83
+ constructor(message, status, body) {
84
+ super(message);
85
+ this.name = "PaymentRejectedError";
86
+ this.status = status;
87
+ this.body = body;
88
+ }
89
+ }
90
+
91
+ class PaymentIndeterminateError extends PaymentError {
92
+ constructor(message) {
93
+ super(message);
94
+ this.name = "PaymentIndeterminateError";
95
+ }
96
+ }
97
+
98
+ const TAG_RE = /^\[(Config|Http|Timeout|Connect|Api|Decode|Rpc|PaymentUnsupported|PaymentRejected|PaymentIndeterminate)\|([^|]+)\|([^\]]+)\](.*)$/s;
66
99
 
67
100
  function fromNapiError(err) {
68
101
  if (!(err instanceof Error)) return err;
@@ -92,6 +125,9 @@ function fromNapiError(err) {
92
125
  case "Decode": return new DecodeError(msg, body);
93
126
  // For Rpc, statusStr is the JSON-RPC code and body is its message.
94
127
  case "Rpc": return new RpcError(body || msg, Number(statusStr));
128
+ case "PaymentUnsupported": return new PaymentUnsupportedError(msg);
129
+ case "PaymentRejected": return new PaymentRejectedError(msg, Number(statusStr), body);
130
+ case "PaymentIndeterminate": return new PaymentIndeterminateError(msg);
95
131
  default: return err;
96
132
  }
97
133
  }
@@ -127,6 +163,10 @@ module.exports = {
127
163
  ApiError,
128
164
  DecodeError,
129
165
  RpcError,
166
+ PaymentError,
167
+ PaymentUnsupportedError,
168
+ PaymentRejectedError,
169
+ PaymentIndeterminateError,
130
170
  fromNapiError,
131
171
  wrapClient,
132
172
  };
package/index.d.ts CHANGED
@@ -1367,6 +1367,55 @@ export interface Payment {
1367
1367
  marketplaceAmount?: string
1368
1368
  }
1369
1369
 
1370
+ /**
1371
+ * Binding-facing crypto-micropayment configuration. **Plain data** — all
1372
+ * fields are strings so this can be a `napi(object)` / `pyclass` / Ruby hash;
1373
+ * it is converted to the internal `enum Signer` + resolved config at the Rust
1374
+ * boundary. The private `key` field stays readable to the caller, but the
1375
+ * SDK's own `Debug` redacts it (below) so an SDK log line or panic can't leak
1376
+ * it.
1377
+ *
1378
+ * **Do not log your own `PaymentConfig`** — `println!("{config:?}")` on the
1379
+ * derived-Debug *binding* object (napi/pyclass/hash) still shows the raw key.
1380
+ * Only the SDK's internal rendering is redacted.
1381
+ */
1382
+ export interface PaymentConfig {
1383
+ /** Payment protocol: `"x402"` (pay-per-request) or `"mpp"` (MPP charge). */
1384
+ scheme: string
1385
+ /**
1386
+ * Raw private key. EVM/Tempo: hex (with or without `0x`). Solana: base58
1387
+ * 64-byte secret key.
1388
+ */
1389
+ key: string
1390
+ /**
1391
+ * CAIP-2 pay network selector, e.g. `"eip155:84532"` (x402/EVM),
1392
+ * `"solana:5eykt4…"` (x402/Solana), or `"eip155:42431"` (MPP/Tempo).
1393
+ */
1394
+ payNetwork: string
1395
+ /**
1396
+ * Asset (token) address/mint to pay in. Matches the offered menu entry's
1397
+ * `asset`. EVM: token contract hex. Solana: mint base58.
1398
+ */
1399
+ asset: string
1400
+ /**
1401
+ * Spend ceiling in base units of `asset` (integer string). **Required.**
1402
+ * The selector skips any offered entry above this, and the driver refuses
1403
+ * to sign one — guarding against a buggy/hostile gateway overcharging a
1404
+ * custodied key.
1405
+ */
1406
+ maxAmount: string
1407
+ /**
1408
+ * Explicit Solana RPC URL for x402/Solana payment-build reads: the mint
1409
+ * (for its decimals and owning token program) and a recent blockhash, so
1410
+ * two reads per payment. Optional; when unset the SDK falls back to a
1411
+ * public Solana RPC matching the pay cluster. **Set this at any real
1412
+ * volume** — the public default rate-limits aggressively.
1413
+ */
1414
+ svmRpcUrl?: string
1415
+ /** Test-only gateway base override (points the lane at a mock gateway). */
1416
+ baseUrlOverride?: string
1417
+ }
1418
+
1370
1419
  /** Configuration for delivering stream batches to a PostgreSQL database. */
1371
1420
  export interface PostgresAttributes {
1372
1421
  /** Database host. */
@@ -1512,6 +1561,19 @@ export interface RpcConfig {
1512
1561
  * call path needs no map.
1513
1562
  */
1514
1563
  networks?: Record<string, string>
1564
+ /**
1565
+ * Crypto-micropayment lane. When set, `rpc.call` pays per request with a
1566
+ * stablecoin against Quicknode's x402/MPP gateways instead of using the
1567
+ * account API key + session JWT. `#[serde(skip)]` so `from_env` can never
1568
+ * populate it — an env-derived private key is exactly what we don't want;
1569
+ * callers must pass this programmatically. The field is always present
1570
+ * (plain data), but the payment lane is only wired into `rpc.call` when a
1571
+ * crypto feature (`payments`/`payments-svm`/`payments-tempo`) is enabled;
1572
+ * built without any of them, a set `payment` is ignored and `rpc.call`
1573
+ * keeps its normal tooling-JWT behavior. The precompiled Python/Node/Ruby
1574
+ * packages always ship with the payment features on.
1575
+ */
1576
+ payment?: PaymentConfig
1515
1577
  }
1516
1578
 
1517
1579
  /** Configuration for delivering stream batches to an S3-compatible object store. */
@@ -1539,7 +1601,17 @@ export interface S3Attributes {
1539
1601
  }
1540
1602
 
1541
1603
  export interface SdkFullConfig {
1542
- apiKey: string
1604
+ /**
1605
+ * Account API key. **Optional** so a keyless SDK can be built for the
1606
+ * crypto-micropayment lane (`rpc.call` with `RpcConfig.payment`). When
1607
+ * absent, no `x-api-key` header is installed: the payment lane works, while
1608
+ * the keyed surfaces (admin/streams/webhooks/kvstore/sql and tooling-JWT
1609
+ * `rpc.call`) send un-authenticated requests and the gateway rejects them
1610
+ * (surfacing as an `ApiError`, typically 401). `from_env` still requires
1611
+ * the key (validated in `from_config`) — only programmatic construction
1612
+ * may omit it.
1613
+ */
1614
+ apiKey?: string
1543
1615
  http?: HttpConfig
1544
1616
  admin?: AdminConfig
1545
1617
  streams?: StreamsConfig
@@ -2532,6 +2604,13 @@ export declare class RpcApiClient {
2532
2604
  * `RpcError`.
2533
2605
  */
2534
2606
  call(method: string, params?: any | undefined | null, network?: string | undefined | null, endpointUrl?: string | undefined | null): Promise<any>
2607
+ /**
2608
+ * Like `call`, but also returns the crypto-micropayment settlement
2609
+ * receipt. Resolves to `{ result, paymentReceipt }` where `paymentReceipt`
2610
+ * is `{ method, status, timestamp, reference }` on the MPP payment lane and
2611
+ * `null` for x402 and every non-payment lane (identical to `call`).
2612
+ */
2613
+ callWithReceipt(method: string, params?: any | undefined | null, network?: string | undefined | null, endpointUrl?: string | undefined | null): Promise<any>
2535
2614
  /**
2536
2615
  * Seeds the per-network URL map for multichain routing (network key ->
2537
2616
  * full http_url), typically built from
@@ -2549,6 +2628,79 @@ export declare class RpcApiClient {
2549
2628
  * token between processes.
2550
2629
  */
2551
2630
  currentToken(): CachedToken | null
2631
+ /**
2632
+ * The configured payment wallet's on-chain address (EVM/Tempo `0x…` hex,
2633
+ * Solana base58), derived offline from the key with no network round trip.
2634
+ */
2635
+ paymentAddress(): string
2636
+ /**
2637
+ * Authenticates against the x402 gateway with a SIWX message and resolves
2638
+ * to `{ token, expUnix, accountId }`. Free — no funds move. Persist the
2639
+ * object and pass it back to the `gateway*` methods.
2640
+ */
2641
+ gatewayAuthenticate(): Promise<any>
2642
+ /**
2643
+ * Reads the account's current x402 credit balance. Resolves to
2644
+ * `{ accountId, credits }`. `session` comes from `gatewayAuthenticate`.
2645
+ */
2646
+ gatewayCredits(session: any): Promise<any>
2647
+ /**
2648
+ * Buys a block of credits, settling the gateway's offer with the same
2649
+ * signer construction as the per-request lane. Resolves to the
2650
+ * post-purchase `{ accountId, credits }`. Single-attempt: a paid lane never
2651
+ * blind-retries.
2652
+ */
2653
+ gatewayBuyCredits(session: any, network: string): Promise<any>
2654
+ /**
2655
+ * Requests testnet tokens from the x402 faucet. Resolves to the funding
2656
+ * transaction `{ accountId, transactionHash }` — NOT a balance; call
2657
+ * `gatewayCredits` afterwards for that. Allowed once per account.
2658
+ */
2659
+ gatewayDrip(session: any): Promise<any>
2660
+ /**
2661
+ * Makes one x402 drawdown JSON-RPC call with the session as a Bearer
2662
+ * token, drawing 1 credit on success. Resolves to the unwrapped JSON-RPC
2663
+ * `result`. Single-attempt; re-authenticate on a 401/403 `ApiError`.
2664
+ */
2665
+ gatewayDrawdownCall(method: string, session: any, network: string, params?: any | undefined | null): Promise<any>
2666
+ /**
2667
+ * Opens an MPP payment channel by depositing `deposit` base units (a
2668
+ * decimal string) into the escrow. Resolves to the channel state — persist
2669
+ * it; the gateway has no read-only channel endpoint, so a lost record means
2670
+ * opening a new channel. Moves real funds; single-attempt.
2671
+ *
2672
+ * Takes no network: the channel is scoped by the configured pay network and
2673
+ * asset, so one channel funds calls to every supported network.
2674
+ */
2675
+ mppOpen(deposit: string): Promise<any>
2676
+ /**
2677
+ * Adds `additionalDeposit` base units (a decimal string) to an open
2678
+ * channel. Resolves to the updated channel state. Moves real funds;
2679
+ * single-attempt.
2680
+ */
2681
+ mppTopUp(channel: any, additionalDeposit: string): Promise<any>
2682
+ /**
2683
+ * Cooperatively closes a channel: settles the final cumulative spend
2684
+ * on-chain and refunds the unused deposit. Single-attempt.
2685
+ */
2686
+ mppClose(channel: any): Promise<void>
2687
+ /**
2688
+ * Fetches the gateway's view of the channel as
2689
+ * `{ channelId, acceptedCumulative, spent }` (amounts are decimal strings).
2690
+ *
2691
+ * **This costs one request unit** and advances the voucher by `perCall`,
2692
+ * exactly like a session call — persist the advanced `cumulativeSpent`.
2693
+ * Rejects with `PaymentUnsupportedError` before any network I/O when the
2694
+ * channel has no room left for the probe.
2695
+ */
2696
+ mppStatus(channel: any): Promise<any>
2697
+ /**
2698
+ * Makes one MPP session-lane JSON-RPC call, authorizing it with a
2699
+ * cumulative voucher for `newCumulative` (a decimal string: the running
2700
+ * total AFTER this call). Resolves to the unwrapped JSON-RPC `result`.
2701
+ * Single-attempt; advance the persisted `cumulativeSpent` on success.
2702
+ */
2703
+ mppSessionCall(method: string, network: string, channel: any, newCumulative: string, params?: any | undefined | null): Promise<any>
2552
2704
  }
2553
2705
 
2554
2706
  export declare class SqlApiClient {
@@ -2744,6 +2896,17 @@ export interface CreateWebhookFromTemplateParamsNode {
2744
2896
  templateArgs: any
2745
2897
  }
2746
2898
 
2899
+ /**
2900
+ * Generates a fresh payment keypair for `chain` (`"evm"`, `"svm"`, or
2901
+ * `"tempo"`). Returns `{ address, chain, key }` where `key` is the raw private
2902
+ * key in the format the `keyFile` config reads.
2903
+ *
2904
+ * The key is returned exactly once, at generation: nothing in the SDK stores or
2905
+ * re-derives it, so persist it before discarding the object. Randomness comes
2906
+ * from the OS CSPRNG.
2907
+ */
2908
+ export declare function generatePaymentWallet(chain: string): any
2909
+
2747
2910
  export interface ListStreamsResponseNode {
2748
2911
  data: Array<StreamNode>
2749
2912
  pageInfo: PageInfo
Binary file
package/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('@quicknode/sdk-android-arm64')
79
79
  const bindingPackageVersion = require('@quicknode/sdk-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('@quicknode/sdk-android-arm-eabi')
95
95
  const bindingPackageVersion = require('@quicknode/sdk-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('@quicknode/sdk-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('@quicknode/sdk-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('@quicknode/sdk-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('@quicknode/sdk-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('@quicknode/sdk-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('@quicknode/sdk-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('@quicknode/sdk-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('@quicknode/sdk-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('@quicknode/sdk-darwin-universal')
184
184
  const bindingPackageVersion = require('@quicknode/sdk-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('@quicknode/sdk-darwin-x64')
200
200
  const bindingPackageVersion = require('@quicknode/sdk-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('@quicknode/sdk-darwin-arm64')
216
216
  const bindingPackageVersion = require('@quicknode/sdk-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@quicknode/sdk-freebsd-x64')
236
236
  const bindingPackageVersion = require('@quicknode/sdk-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('@quicknode/sdk-freebsd-arm64')
252
252
  const bindingPackageVersion = require('@quicknode/sdk-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('@quicknode/sdk-linux-x64-musl')
273
273
  const bindingPackageVersion = require('@quicknode/sdk-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('@quicknode/sdk-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('@quicknode/sdk-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('@quicknode/sdk-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('@quicknode/sdk-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('@quicknode/sdk-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('@quicknode/sdk-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('@quicknode/sdk-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('@quicknode/sdk-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('@quicknode/sdk-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('@quicknode/sdk-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('@quicknode/sdk-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('@quicknode/sdk-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('@quicknode/sdk-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('@quicknode/sdk-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('@quicknode/sdk-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('@quicknode/sdk-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('@quicknode/sdk-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('@quicknode/sdk-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('@quicknode/sdk-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('@quicknode/sdk-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('@quicknode/sdk-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('@quicknode/sdk-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@quicknode/sdk-openharmony-arm64')
478
478
  const bindingPackageVersion = require('@quicknode/sdk-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@quicknode/sdk-openharmony-x64')
494
494
  const bindingPackageVersion = require('@quicknode/sdk-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('@quicknode/sdk-openharmony-arm')
510
510
  const bindingPackageVersion = require('@quicknode/sdk-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '3.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 3.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '3.8.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 3.8.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -592,3 +592,4 @@ module.exports.RpcApiClient = nativeBinding.RpcApiClient
592
592
  module.exports.SqlApiClient = nativeBinding.SqlApiClient
593
593
  module.exports.StreamsApiClient = nativeBinding.StreamsApiClient
594
594
  module.exports.WebhooksApiClient = nativeBinding.WebhooksApiClient
595
+ module.exports.generatePaymentWallet = nativeBinding.generatePaymentWallet
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quicknode/sdk",
3
- "version": "3.7.0",
3
+ "version": "3.8.1",
4
4
  "description": "Quicknode SDK",
5
5
  "repository": {
6
6
  "type": "git",
@@ -54,10 +54,10 @@
54
54
  },
55
55
  "license": "MIT",
56
56
  "optionalDependencies": {
57
- "@quicknode/sdk-linux-x64-gnu": "3.7.0",
58
- "@quicknode/sdk-linux-arm64-gnu": "3.7.0",
59
- "@quicknode/sdk-linux-x64-musl": "3.7.0",
60
- "@quicknode/sdk-linux-arm64-musl": "3.7.0",
61
- "@quicknode/sdk-darwin-arm64": "3.7.0"
57
+ "@quicknode/sdk-linux-x64-gnu": "3.8.1",
58
+ "@quicknode/sdk-linux-arm64-gnu": "3.8.1",
59
+ "@quicknode/sdk-linux-x64-musl": "3.8.1",
60
+ "@quicknode/sdk-linux-arm64-musl": "3.8.1",
61
+ "@quicknode/sdk-darwin-arm64": "3.8.1"
62
62
  }
63
63
  }
package/sdk.d.ts CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  XrplWalletFilterTemplate,
17
17
  HyperliquidWalletEventsFilterTemplate,
18
18
  StellarWalletTransactionsFilterTemplate,
19
+ RpcApiClient,
19
20
  } from "./index";
20
21
 
21
22
  // Stream destination attributes (input). The inner key is `attributes` rather
@@ -331,8 +332,97 @@ export type {
331
332
  CachedToken,
332
333
  ToolingAccessStatus,
333
334
  RpcApiClient,
335
+ // payment lane
336
+ PaymentConfig,
334
337
  } from "./index";
335
338
 
339
+ // A settlement receipt for the crypto-micropayment lane. Returned inside
340
+ // `RpcCallResponse.paymentReceipt` by `rpc.callWithReceipt`. `reference` is the
341
+ // settlement transaction hash. Present only on the MPP lane; `null` otherwise.
342
+ export interface PaymentReceipt {
343
+ method: string;
344
+ status: string;
345
+ timestamp: string;
346
+ reference: string;
347
+ }
348
+
349
+ // The result of `rpc.callWithReceipt`: the JSON-RPC `result` plus the optional
350
+ // settlement receipt (`null` for x402 and non-payment lanes).
351
+ export interface RpcCallResponse {
352
+ result: any;
353
+ paymentReceipt: PaymentReceipt | null;
354
+ }
355
+
356
+ // ── Payment lanes ──────────────────────────────────────────────
357
+ //
358
+ // Base-unit amounts are `string`, not `number`: they are u128 in the core and a
359
+ // JS number is an f64 that loses precision above 2^53. Pass and store them as
360
+ // decimal strings.
361
+
362
+ // An x402 gateway session (from `rpc.gatewayAuthenticate`). `token` is a live
363
+ // bearer credential — persist it, but keep it out of logs.
364
+ export interface GatewaySession {
365
+ token: string;
366
+ expUnix: number;
367
+ accountId: string;
368
+ }
369
+
370
+ // An x402 credit balance (`rpc.gatewayCredits` / `rpc.gatewayBuyCredits`).
371
+ export interface CreditBalance {
372
+ accountId: string;
373
+ credits: number;
374
+ }
375
+
376
+ // The faucet result (`rpc.gatewayDrip`): the on-chain funding transaction, NOT
377
+ // a balance. Call `rpc.gatewayCredits` afterwards to read the new balance.
378
+ export interface DripReceipt {
379
+ accountId: string;
380
+ transactionHash: string;
381
+ }
382
+
383
+ // Local state for an open MPP payment channel (`rpc.mppOpen` /
384
+ // `rpc.mppTopUp`). Persist this verbatim: the gateway has no read-only channel
385
+ // endpoint, so a lost record means opening a new channel.
386
+ export interface ChannelState {
387
+ channelId: string;
388
+ token: string;
389
+ payee: string;
390
+ salt: string;
391
+ authorizedSigner: string;
392
+ escrowContract: string;
393
+ /** Base units, decimal string. */
394
+ deposit: string;
395
+ /** Base units, decimal string. */
396
+ cumulativeSpent: string;
397
+ /** The gateway's per-call price, in base units, as a decimal string. */
398
+ perCall: string;
399
+ chainId: number;
400
+ }
401
+
402
+ // The gateway's view of a channel (`rpc.mppStatus`).
403
+ export interface ChannelStatus {
404
+ channelId: string;
405
+ /** Base units, decimal string. */
406
+ acceptedCumulative: string;
407
+ /** Base units, decimal string. */
408
+ spent: string;
409
+ }
410
+
411
+ // A freshly generated payment wallet (`generatePaymentWallet`). `key` is the raw
412
+ // private key, returned exactly once at generation — nothing in the SDK stores
413
+ // or re-derives it, so persist it before discarding the object.
414
+ export interface GeneratedWallet {
415
+ address: string;
416
+ chain: "evm" | "svm" | "tempo";
417
+ key: string;
418
+ }
419
+
420
+ /**
421
+ * Generates a fresh payment keypair. Offline: no network call, no funds.
422
+ * Randomness comes from the OS CSPRNG.
423
+ */
424
+ export function generatePaymentWallet(chain: "evm" | "svm" | "tempo"): GeneratedWallet;
425
+
336
426
  // const enums must use `export` (not `export type`) so they are usable as values
337
427
  export {
338
428
  StreamRegion,
@@ -397,6 +487,61 @@ export interface SqlApiClientTyped {
397
487
  getSchema(clusterId: string): Promise<ChainSchemaNode>;
398
488
  }
399
489
 
490
+ // Retypes the payment-lane returns from napi's `any` to the interfaces above.
491
+ // napi emits `any` for every method returning a `serde_json::Value`, so without
492
+ // this the declared payment interfaces would be documentation only and a
493
+ // mistyped field would not be an error. Keep method signatures in sync with the
494
+ // napi-generated RpcApiClient in ./index.d.ts.
495
+ export interface RpcApiClientTyped
496
+ extends Omit<
497
+ RpcApiClient,
498
+ | "callWithReceipt"
499
+ | "gatewayAuthenticate"
500
+ | "gatewayCredits"
501
+ | "gatewayBuyCredits"
502
+ | "gatewayDrip"
503
+ | "gatewayDrawdownCall"
504
+ | "mppOpen"
505
+ | "mppTopUp"
506
+ | "mppClose"
507
+ | "mppStatus"
508
+ | "mppSessionCall"
509
+ > {
510
+ callWithReceipt(
511
+ method: string,
512
+ params?: any | undefined | null,
513
+ network?: string | undefined | null,
514
+ endpointUrl?: string | undefined | null
515
+ ): Promise<RpcCallResponse>;
516
+ gatewayAuthenticate(): Promise<GatewaySession>;
517
+ gatewayCredits(session: GatewaySession): Promise<CreditBalance>;
518
+ gatewayBuyCredits(
519
+ session: GatewaySession,
520
+ network: string
521
+ ): Promise<CreditBalance>;
522
+ gatewayDrip(session: GatewaySession): Promise<DripReceipt>;
523
+ gatewayDrawdownCall(
524
+ method: string,
525
+ session: GatewaySession,
526
+ network: string,
527
+ params?: any | undefined | null
528
+ ): Promise<any>;
529
+ mppOpen(deposit: string): Promise<ChannelState>;
530
+ mppTopUp(
531
+ channel: ChannelState,
532
+ additionalDeposit: string
533
+ ): Promise<ChannelState>;
534
+ mppClose(channel: ChannelState): Promise<void>;
535
+ mppStatus(channel: ChannelState): Promise<ChannelStatus>;
536
+ mppSessionCall(
537
+ method: string,
538
+ network: string,
539
+ channel: ChannelState,
540
+ newCumulative: string,
541
+ params?: any | undefined | null
542
+ ): Promise<any>;
543
+ }
544
+
400
545
  export class QuicknodeSdk {
401
546
  constructor(config: SdkFullConfig);
402
547
  static fromEnv(): QuicknodeSdk;
@@ -405,7 +550,7 @@ export class QuicknodeSdk {
405
550
  webhooks: WebhooksApiClientTyped;
406
551
  kvstore: _QuicknodeSdk["kvstore"];
407
552
  sql: SqlApiClientTyped;
408
- rpc: _QuicknodeSdk["rpc"];
553
+ rpc: RpcApiClientTyped;
409
554
  }
410
555
 
411
556
  // Typed static factory methods producing each discriminated variant of
@@ -459,3 +604,13 @@ export class DecodeError extends QuicknodeError {
459
604
  export class RpcError extends QuicknodeError {
460
605
  code: number;
461
606
  }
607
+ // Payment-lane errors (crypto-micropayment `rpc.call`). Catch PaymentError to
608
+ // handle them all. PaymentIndeterminateError means the paid request was sent
609
+ // but its response was lost — the payment MAY have settled, so do NOT retry.
610
+ export class PaymentError extends QuicknodeError {}
611
+ export class PaymentUnsupportedError extends PaymentError {}
612
+ export class PaymentRejectedError extends PaymentError {
613
+ status: number;
614
+ body: string;
615
+ }
616
+ export class PaymentIndeterminateError extends PaymentError {}
package/sdk.js CHANGED
@@ -78,10 +78,20 @@ class TemplateArgs {
78
78
  }
79
79
  }
80
80
 
81
+ // Translate module-level napi errors; wrapClient only handles clients.
82
+ function generatePaymentWallet(chain) {
83
+ try {
84
+ return _index.generatePaymentWallet(chain);
85
+ } catch (e) {
86
+ throw errors.fromNapiError(e);
87
+ }
88
+ }
89
+
81
90
  module.exports = {
82
91
  ..._index,
83
92
  QuicknodeSdk,
84
93
  TemplateArgs,
94
+ generatePaymentWallet,
85
95
  QuicknodeError: errors.QuicknodeError,
86
96
  ConfigError: errors.ConfigError,
87
97
  HttpError: errors.HttpError,
@@ -90,4 +100,8 @@ module.exports = {
90
100
  ApiError: errors.ApiError,
91
101
  DecodeError: errors.DecodeError,
92
102
  RpcError: errors.RpcError,
103
+ PaymentError: errors.PaymentError,
104
+ PaymentUnsupportedError: errors.PaymentUnsupportedError,
105
+ PaymentRejectedError: errors.PaymentRejectedError,
106
+ PaymentIndeterminateError: errors.PaymentIndeterminateError,
93
107
  };
package/sdk.mjs CHANGED
@@ -26,6 +26,7 @@ export const {
26
26
  KvStoreApiClient,
27
27
  SqlApiClient,
28
28
  RpcApiClient,
29
+ generatePaymentWallet,
29
30
  QuicknodeError,
30
31
  ConfigError,
31
32
  HttpError,
@@ -34,4 +35,8 @@ export const {
34
35
  ApiError,
35
36
  DecodeError,
36
37
  RpcError,
38
+ PaymentError,
39
+ PaymentUnsupportedError,
40
+ PaymentRejectedError,
41
+ PaymentIndeterminateError,
37
42
  } = cjs;