uvd-x402-sdk 2.91.0 → 2.93.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 (108) hide show
  1. package/README.md +10 -4
  2. package/dist/adapters/index.d.mts +1 -1
  3. package/dist/adapters/index.d.ts +1 -1
  4. package/dist/adapters/index.js +130 -1
  5. package/dist/adapters/index.js.map +1 -1
  6. package/dist/adapters/index.mjs +130 -1
  7. package/dist/adapters/index.mjs.map +1 -1
  8. package/dist/backend/index.d.mts +2 -2
  9. package/dist/backend/index.d.ts +2 -2
  10. package/dist/backend/index.js +211 -11
  11. package/dist/backend/index.js.map +1 -1
  12. package/dist/backend/index.mjs +212 -12
  13. package/dist/backend/index.mjs.map +1 -1
  14. package/dist/erc8128/index.js +4 -0
  15. package/dist/erc8128/index.js.map +1 -1
  16. package/dist/erc8128/index.mjs +4 -0
  17. package/dist/erc8128/index.mjs.map +1 -1
  18. package/dist/{index-DAC3DRdT.d.mts → index-BGqIAgsJ.d.ts} +7 -6
  19. package/dist/{index-DbauIMV2.d.ts → index-CBjEM00M.d.mts} +11 -2
  20. package/dist/{index-DbauIMV2.d.mts → index-CBjEM00M.d.ts} +11 -2
  21. package/dist/{index-s6ot_Mu-.d.ts → index-DQorHgSa.d.ts} +1 -1
  22. package/dist/{index-DRk6i654.d.mts → index-DzCTT20R.d.mts} +1 -1
  23. package/dist/{index-DRSEcZ36.d.ts → index-H4dVoRFp.d.mts} +7 -6
  24. package/dist/index.d.mts +9 -4
  25. package/dist/index.d.ts +9 -4
  26. package/dist/index.js +362 -14
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +359 -16
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/providers/algorand/index.d.mts +1 -1
  31. package/dist/providers/algorand/index.d.ts +1 -1
  32. package/dist/providers/algorand/index.js +129 -1
  33. package/dist/providers/algorand/index.js.map +1 -1
  34. package/dist/providers/algorand/index.mjs +129 -1
  35. package/dist/providers/algorand/index.mjs.map +1 -1
  36. package/dist/providers/evm/index.d.mts +1 -1
  37. package/dist/providers/evm/index.d.ts +1 -1
  38. package/dist/providers/evm/index.js +129 -1
  39. package/dist/providers/evm/index.js.map +1 -1
  40. package/dist/providers/evm/index.mjs +129 -1
  41. package/dist/providers/evm/index.mjs.map +1 -1
  42. package/dist/providers/hedera/index.d.mts +84 -0
  43. package/dist/providers/hedera/index.d.ts +84 -0
  44. package/dist/providers/hedera/index.js +192 -0
  45. package/dist/providers/hedera/index.js.map +1 -0
  46. package/dist/providers/hedera/index.mjs +182 -0
  47. package/dist/providers/hedera/index.mjs.map +1 -0
  48. package/dist/providers/near/index.d.mts +1 -1
  49. package/dist/providers/near/index.d.ts +1 -1
  50. package/dist/providers/near/index.js +124 -1
  51. package/dist/providers/near/index.js.map +1 -1
  52. package/dist/providers/near/index.mjs +124 -1
  53. package/dist/providers/near/index.mjs.map +1 -1
  54. package/dist/providers/solana/index.d.mts +1 -1
  55. package/dist/providers/solana/index.d.ts +1 -1
  56. package/dist/providers/solana/index.js +124 -1
  57. package/dist/providers/solana/index.js.map +1 -1
  58. package/dist/providers/solana/index.mjs +124 -1
  59. package/dist/providers/solana/index.mjs.map +1 -1
  60. package/dist/providers/stellar/index.d.mts +1 -1
  61. package/dist/providers/stellar/index.d.ts +1 -1
  62. package/dist/providers/stellar/index.js +124 -1
  63. package/dist/providers/stellar/index.js.map +1 -1
  64. package/dist/providers/stellar/index.mjs +124 -1
  65. package/dist/providers/stellar/index.mjs.map +1 -1
  66. package/dist/providers/sui/index.d.mts +1 -1
  67. package/dist/providers/sui/index.d.ts +1 -1
  68. package/dist/providers/sui/index.js +124 -1
  69. package/dist/providers/sui/index.js.map +1 -1
  70. package/dist/providers/sui/index.mjs +124 -1
  71. package/dist/providers/sui/index.mjs.map +1 -1
  72. package/dist/providers/xrpl/index.d.mts +1 -1
  73. package/dist/providers/xrpl/index.d.ts +1 -1
  74. package/dist/providers/xrpl/index.js +124 -1
  75. package/dist/providers/xrpl/index.js.map +1 -1
  76. package/dist/providers/xrpl/index.mjs +124 -1
  77. package/dist/providers/xrpl/index.mjs.map +1 -1
  78. package/dist/react/index.d.mts +3 -3
  79. package/dist/react/index.d.ts +3 -3
  80. package/dist/react/index.js +155 -7
  81. package/dist/react/index.js.map +1 -1
  82. package/dist/react/index.mjs +155 -7
  83. package/dist/react/index.mjs.map +1 -1
  84. package/dist/react/picker/index.d.mts +1 -1
  85. package/dist/react/picker/index.d.ts +1 -1
  86. package/dist/react/picker/index.js +120 -2
  87. package/dist/react/picker/index.js.map +1 -1
  88. package/dist/react/picker/index.mjs +120 -2
  89. package/dist/react/picker/index.mjs.map +1 -1
  90. package/dist/utils/index.d.mts +2 -2
  91. package/dist/utils/index.d.ts +2 -2
  92. package/dist/utils/index.js +130 -1
  93. package/dist/utils/index.js.map +1 -1
  94. package/dist/utils/index.mjs +130 -1
  95. package/dist/utils/index.mjs.map +1 -1
  96. package/dist/{validity-C0z0GqH6.d.ts → validity-CHJ8HAVL.d.ts} +2 -2
  97. package/dist/{validity-BTMBMmuj.d.mts → validity-DZdjHKsU.d.mts} +2 -2
  98. package/package.json +21 -5
  99. package/src/backend/index.ts +15 -0
  100. package/src/chains/index.ts +116 -3
  101. package/src/client/X402Client.ts +25 -5
  102. package/src/facilitator.ts +6 -0
  103. package/src/index.ts +6 -2
  104. package/src/providers/hedera/index.ts +179 -0
  105. package/src/react/NetworkPicker.tsx +1 -0
  106. package/src/types/index.ts +11 -2
  107. package/src/utils/validation.ts +7 -1
  108. package/src/utils/x402.ts +1 -0
package/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # uvd-x402-sdk
2
2
 
3
- Gasless crypto payments across 25 blockchain networks using the x402 protocol.
3
+ Gasless crypto payments across 29 blockchain networks using the x402 protocol.
4
4
 
5
5
  Users sign a message or transaction, and the Ultravioleta facilitator handles on-chain settlement. No gas fees for users.
6
6
 
7
+ **New in v2.93.0**: Native Hedera mainnet and testnet with sponsored HBAR/USDC payments, offline signing and buyer/merchant helpers. [Hedera guide](docs/networks/hedera.md). Arc USDC remains supported on mainnet and testnet.
8
+
7
9
  ## Features
8
10
 
9
- - **25 Networks**: EVM (15 including Scroll, SKALE Base, Robinhood Chain), Solana, Fogo, Stellar, NEAR, Algorand, Sui, XRP Ledger (mainnet + testnet)
11
+ - **29 Networks**: EVM (17 including Arc, Scroll, SKALE Base, Robinhood Chain), Solana, Fogo, Stellar, NEAR, Algorand, Sui, XRP Ledger, Hedera (mainnet + testnet)
10
12
  - **Multi-Stablecoin**: USDC, EURC, AUSD, PYUSD, USDT, USDG (Robinhood Chain)
11
- - **x402 v1 & v2**: Both protocol versions with auto-detection
13
+ - **x402 v1 & v2**: Protocol auto-detection; native Hedera supports v2/exact only
12
14
  - **Gasless**: Facilitator pays all network fees
13
15
  - **Buyer Policy**: Per-payment and cumulative budgets, payee allowlist and offer expiry, evaluated against the offer in hand **before signing** — six closed refusal codes in a fixed order
14
16
  - **Type-Safe**: Full TypeScript support
@@ -723,7 +725,7 @@ const header = svm.encodePaymentHeader(payload, chainConfig);
723
725
 
724
726
  ## Supported Networks
725
727
 
726
- ### EVM (15)
728
+ ### EVM (16)
727
729
 
728
730
  | Network | Chain ID | Tokens |
729
731
  |---------|----------|--------|
@@ -742,6 +744,10 @@ const header = svm.encodePaymentHeader(payload, chainConfig);
742
744
  | SKALE Base Sepolia | 324705682 | USDC.e |
743
745
  | Robinhood Chain | 4663 | USDG |
744
746
  | Robinhood Chain Testnet | 46630 | USDG |
747
+ | Arc | 5042 | USDC |
748
+ | Arc Testnet | 5042002 | USDC |
749
+
750
+ > **Arc mainnet and testnet:** payment amounts use 6 decimals and the `USDC` / `2` domain. Native gas uses 18 decimals on the same balance. Use `arc` / `eip155:5042` for mainnet and `arc-testnet` / `eip155:5042002` for testnet. See [Arc usage and validation](docs/networks/arc.md).
745
751
 
746
752
  > **Robinhood Chain / USDG:** Robinhood Chain has no USDC — the settlement stablecoin is Paxos **USDG** (Global Dollar, 6 decimals, EIP-3009). Its on-chain `version()` getter reverts, so the EIP-712 domain `{ name: "Global Dollar", version: "1" }` can never be resolved on-chain. The SDK carries this domain in the chain config; when constructing `PaymentRequirements` yourself, send it in `extra`: `{ "name": "Global Dollar", "version": "1" }`. Use `tokenType: 'usdg'` (or the default, which resolves to USDG on these networks).
747
753
 
@@ -1,4 +1,4 @@
1
- import { X as X402Version, a as PaymentResult } from '../index-DbauIMV2.mjs';
1
+ import { X as X402Version, a as PaymentResult } from '../index-CBjEM00M.mjs';
2
2
  export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-Z9v4GxOZ.mjs';
3
3
  import '../wallet-w7BnImDG.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { X as X402Version, a as PaymentResult } from '../index-DbauIMV2.js';
1
+ import { X as X402Version, a as PaymentResult } from '../index-CBjEM00M.js';
2
2
  export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-C-KmORG9.js';
3
3
  import '../wallet-w7BnImDG.js';
4
4
 
@@ -5,8 +5,40 @@ var ethers = require('ethers');
5
5
  // src/chains/index.ts
6
6
  var DEFAULT_FACILITATOR_URL = "https://facilitator.ultravioletadao.xyz";
7
7
  var SUPPORTED_CHAINS = {
8
+ "hedera:mainnet": {
9
+ chainId: 0,
10
+ chainIdHex: "0x0",
11
+ name: "hedera:mainnet",
12
+ displayName: "Hedera",
13
+ networkType: "hedera",
14
+ rpcUrl: "https://mainnet-public.mirrornode.hedera.com",
15
+ explorerUrl: "https://hashscan.io/mainnet",
16
+ nativeCurrency: { name: "HBAR", symbol: "HBAR", decimals: 8 },
17
+ usdc: { address: "0.0.456858", decimals: 6, name: "USDC", version: "" },
18
+ tokens: {
19
+ usdc: { address: "0.0.456858", decimals: 6, name: "USDC", version: "" },
20
+ hbar: { address: "0.0.0", decimals: 8, name: "HBAR", version: "", usdPegged: false }
21
+ },
22
+ x402: { facilitatorUrl: DEFAULT_FACILITATOR_URL, enabled: true }
23
+ },
24
+ "hedera:testnet": {
25
+ chainId: 0,
26
+ chainIdHex: "0x0",
27
+ name: "hedera:testnet",
28
+ displayName: "Hedera Testnet",
29
+ networkType: "hedera",
30
+ rpcUrl: "https://testnet.mirrornode.hedera.com",
31
+ explorerUrl: "https://hashscan.io/testnet",
32
+ nativeCurrency: { name: "HBAR", symbol: "HBAR", decimals: 8 },
33
+ usdc: { address: "0.0.429274", decimals: 6, name: "USDC", version: "" },
34
+ tokens: {
35
+ usdc: { address: "0.0.429274", decimals: 6, name: "USDC", version: "" },
36
+ hbar: { address: "0.0.0", decimals: 8, name: "HBAR", version: "", usdPegged: false }
37
+ },
38
+ x402: { facilitatorUrl: DEFAULT_FACILITATOR_URL, enabled: true }
39
+ },
8
40
  // ============================================================================
9
- // EVM CHAINS (15 networks)
41
+ // EVM CHAINS (16 enabled + BSC, disabled)
10
42
  // ============================================================================
11
43
  base: {
12
44
  chainId: 8453,
@@ -636,6 +668,91 @@ var SUPPORTED_CHAINS = {
636
668
  enabled: true
637
669
  }
638
670
  },
671
+ // Arc testnet (Circle). The stablecoin IS the chain's native asset, so the SAME
672
+ // balance is readable at TWO precisions:
673
+ // - native / gas, via eth_getBalance and EIP-1559 fees: 18 decimals
674
+ // - ERC-20 interface, via balanceOf and transferWithAuthorization: 6 decimals
675
+ // (the ERC-20 view is floor(native / 10^12))
676
+ // An x402 payment is an EIP-3009 authorization against the ERC-20 interface, so
677
+ // its `value` is ALWAYS in the 6 of `tokens.usdc.decimals`. Scaling a price with
678
+ // `nativeCurrency.decimals` instead charges 10^12 times the amount: $0.01 would
679
+ // be signed as 10000000000000000 units, i.e. 10 billion USDC. `nativeCurrency`
680
+ // below is correct where it is actually used -- the wallet_addEthereumChain
681
+ // params -- and must never reach `parseUnits` for a payment.
682
+ // Pinned by src/arc-testnet.test.ts.
683
+ //
684
+ // Mainnet (5042) and testnet (5042002) were verified independently against
685
+ // their official RPCs on 2026-09-16. EURC is not registered without its E2E proof.
686
+ arc: {
687
+ chainId: 5042,
688
+ chainIdHex: "0x13b2",
689
+ name: "arc",
690
+ displayName: "Arc",
691
+ networkType: "evm",
692
+ rpcUrl: "https://rpc.mainnet.arc.io",
693
+ explorerUrl: "https://explorer.arc.io",
694
+ nativeCurrency: {
695
+ name: "USD Coin",
696
+ symbol: "USDC",
697
+ decimals: 18
698
+ // gas precision ONLY -- never the scale of a payment
699
+ },
700
+ usdc: {
701
+ address: "0x3600000000000000000000000000000000000000",
702
+ decimals: 6,
703
+ // ERC-20 interface, which is what an EIP-3009 value is denominated in
704
+ name: "USDC",
705
+ // on-chain name(); must match the EIP-712 domain exactly
706
+ version: "2"
707
+ },
708
+ tokens: {
709
+ usdc: {
710
+ address: "0x3600000000000000000000000000000000000000",
711
+ decimals: 6,
712
+ name: "USDC",
713
+ version: "2"
714
+ }
715
+ },
716
+ x402: {
717
+ facilitatorUrl: DEFAULT_FACILITATOR_URL,
718
+ enabled: true
719
+ }
720
+ },
721
+ "arc-testnet": {
722
+ chainId: 5042002,
723
+ chainIdHex: "0x4cef52",
724
+ name: "arc-testnet",
725
+ displayName: "Arc Testnet",
726
+ networkType: "evm",
727
+ rpcUrl: "https://rpc.testnet.arc.io",
728
+ explorerUrl: "https://explorer.testnet.arc.io",
729
+ nativeCurrency: {
730
+ name: "USD Coin",
731
+ symbol: "USDC",
732
+ decimals: 18
733
+ // gas precision ONLY -- never the scale of a payment
734
+ },
735
+ usdc: {
736
+ address: "0x3600000000000000000000000000000000000000",
737
+ decimals: 6,
738
+ // ERC-20 interface, which is what an EIP-3009 value is denominated in
739
+ name: "USDC",
740
+ // on-chain name(); must match the EIP-712 domain exactly
741
+ version: "2"
742
+ },
743
+ tokens: {
744
+ usdc: {
745
+ address: "0x3600000000000000000000000000000000000000",
746
+ decimals: 6,
747
+ name: "USDC",
748
+ version: "2"
749
+ }
750
+ },
751
+ x402: {
752
+ facilitatorUrl: DEFAULT_FACILITATOR_URL,
753
+ enabled: true
754
+ }
755
+ },
639
756
  // ============================================================================
640
757
  // SVM CHAINS (2 networks) - Solana Virtual Machine
641
758
  // ============================================================================
@@ -989,6 +1106,8 @@ var SUPPORTED_CHAINS = {
989
1106
  }
990
1107
  };
991
1108
  var CHAIN_ALIASES = {
1109
+ hedera: "hedera:mainnet",
1110
+ "hedera-testnet": "hedera:testnet",
992
1111
  // Renamed in 2.85.0: the facilitator advertises the mainnet as `xrpl`.
993
1112
  "xrpl-mainnet": "xrpl"
994
1113
  };
@@ -999,6 +1118,8 @@ function getChainByName(name) {
999
1118
 
1000
1119
  // src/types/index.ts
1001
1120
  var CAIP2_IDENTIFIERS = {
1121
+ "hedera:mainnet": "hedera:mainnet",
1122
+ "hedera:testnet": "hedera:testnet",
1002
1123
  // EVM chains
1003
1124
  base: "eip155:8453",
1004
1125
  ethereum: "eip155:1",
@@ -1016,6 +1137,8 @@ var CAIP2_IDENTIFIERS = {
1016
1137
  "skale-base-sepolia": "eip155:324705682",
1017
1138
  robinhood: "eip155:4663",
1018
1139
  "robinhood-testnet": "eip155:46630",
1140
+ arc: "eip155:5042",
1141
+ "arc-testnet": "eip155:5042002",
1019
1142
  // SVM chains
1020
1143
  solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
1021
1144
  fogo: "svm:fogo",
@@ -1082,6 +1205,7 @@ function encodeX402Header(header) {
1082
1205
  return encodeBase64Json(header);
1083
1206
  }
1084
1207
  function createX402V1Header(network, payload) {
1208
+ if (getChainByName(network)?.networkType === "hedera") throw new Error("Native Hedera supports only x402 v2");
1085
1209
  return {
1086
1210
  x402Version: 1,
1087
1211
  scheme: "exact",
@@ -1154,6 +1278,11 @@ function validateRecipient(recipient, networkType) {
1154
1278
  );
1155
1279
  }
1156
1280
  break;
1281
+ case "hedera":
1282
+ if (!/^0\.0\.[1-9][0-9]*$/.test(trimmed)) {
1283
+ throw new X402Error("Hedera recipient must be a native numeric account ID", "INVALID_RECIPIENT");
1284
+ }
1285
+ break;
1157
1286
  case "xrpl":
1158
1287
  if (!XRPL_ADDRESS_REGEX.test(trimmed)) {
1159
1288
  throw new X402Error(