uvd-x402-sdk 2.90.0 → 2.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +88 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +88 -1
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/backend/index.d.mts +2 -2
- package/dist/backend/index.d.ts +2 -2
- package/dist/backend/index.js +88 -1
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +88 -1
- package/dist/backend/index.mjs.map +1 -1
- package/dist/erc8128/index.js +2 -0
- package/dist/erc8128/index.js.map +1 -1
- package/dist/erc8128/index.mjs +2 -0
- package/dist/erc8128/index.mjs.map +1 -1
- package/dist/{index-B5B9EK3x.d.ts → index-B-iLEkAH.d.mts} +4 -3
- package/dist/{index-CAJg-_cr.d.mts → index-DRk6i654.d.mts} +1 -1
- package/dist/{index-BWN0Haa0.d.mts → index-DbauIMV2.d.mts} +41 -0
- package/dist/{index-BWN0Haa0.d.ts → index-DbauIMV2.d.ts} +41 -0
- package/dist/{index-13ZUDF7c.d.mts → index-DkoNhJfq.d.ts} +4 -3
- package/dist/{index-Cd1Mpznb.d.ts → index-s6ot_Mu-.d.ts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +131 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -4
- package/dist/index.mjs.map +1 -1
- package/dist/providers/algorand/index.d.mts +1 -1
- package/dist/providers/algorand/index.d.ts +1 -1
- package/dist/providers/algorand/index.js +88 -1
- package/dist/providers/algorand/index.js.map +1 -1
- package/dist/providers/algorand/index.mjs +88 -1
- package/dist/providers/algorand/index.mjs.map +1 -1
- package/dist/providers/evm/index.d.mts +1 -1
- package/dist/providers/evm/index.d.ts +1 -1
- package/dist/providers/evm/index.js +111 -2
- package/dist/providers/evm/index.js.map +1 -1
- package/dist/providers/evm/index.mjs +111 -2
- package/dist/providers/evm/index.mjs.map +1 -1
- package/dist/providers/near/index.d.mts +1 -1
- package/dist/providers/near/index.d.ts +1 -1
- package/dist/providers/near/index.js +88 -1
- package/dist/providers/near/index.js.map +1 -1
- package/dist/providers/near/index.mjs +88 -1
- package/dist/providers/near/index.mjs.map +1 -1
- package/dist/providers/solana/index.d.mts +1 -1
- package/dist/providers/solana/index.d.ts +1 -1
- package/dist/providers/solana/index.js +88 -1
- package/dist/providers/solana/index.js.map +1 -1
- package/dist/providers/solana/index.mjs +88 -1
- package/dist/providers/solana/index.mjs.map +1 -1
- package/dist/providers/stellar/index.d.mts +1 -1
- package/dist/providers/stellar/index.d.ts +1 -1
- package/dist/providers/stellar/index.js +88 -1
- package/dist/providers/stellar/index.js.map +1 -1
- package/dist/providers/stellar/index.mjs +88 -1
- package/dist/providers/stellar/index.mjs.map +1 -1
- package/dist/providers/sui/index.d.mts +1 -1
- package/dist/providers/sui/index.d.ts +1 -1
- package/dist/providers/sui/index.js +88 -1
- package/dist/providers/sui/index.js.map +1 -1
- package/dist/providers/sui/index.mjs +88 -1
- package/dist/providers/sui/index.mjs.map +1 -1
- package/dist/providers/xrpl/index.d.mts +1 -1
- package/dist/providers/xrpl/index.d.ts +1 -1
- package/dist/providers/xrpl/index.js +88 -1
- package/dist/providers/xrpl/index.js.map +1 -1
- package/dist/providers/xrpl/index.mjs +88 -1
- package/dist/providers/xrpl/index.mjs.map +1 -1
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +129 -3
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +129 -3
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/picker/index.d.mts +1 -1
- package/dist/react/picker/index.d.ts +1 -1
- package/dist/react/picker/index.js +86 -1
- package/dist/react/picker/index.js.map +1 -1
- package/dist/react/picker/index.mjs +86 -1
- package/dist/react/picker/index.mjs.map +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +117 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +114 -2
- package/dist/utils/index.mjs.map +1 -1
- package/dist/{validation-B95g0MqC.d.mts → validity-BTMBMmuj.d.mts} +101 -2
- package/dist/{validation-_Tcjm2gu.d.ts → validity-C0z0GqH6.d.ts} +101 -2
- package/package.json +3 -2
- package/src/chains/index.ts +85 -3
- package/src/client/X402Client.ts +32 -2
- package/src/index.ts +7 -2
- package/src/providers/evm/index.ts +4 -2
- package/src/types/index.ts +43 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/validity.ts +135 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# uvd-x402-sdk
|
|
2
2
|
|
|
3
|
-
Gasless crypto payments across
|
|
3
|
+
Gasless crypto payments across 27 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
|
|
|
@@ -670,6 +670,38 @@ getSupportedTokens('base'); // ['usdc', 'eurc']
|
|
|
670
670
|
isTokenSupported('base', 'eurc'); // true
|
|
671
671
|
```
|
|
672
672
|
|
|
673
|
+
## Validity window (`validitySeconds`)
|
|
674
|
+
|
|
675
|
+
An EIP-3009 authorization can only be settled until `validBefore = now + validitySeconds`. A seller that settles **after** handing over the resource needs the authorization alive long enough for that settlement to land.
|
|
676
|
+
|
|
677
|
+
| Where | Scope | Default |
|
|
678
|
+
|---|---|---|
|
|
679
|
+
| `X402ClientConfig.validitySeconds` | every payment this client signs | `300` |
|
|
680
|
+
| `PaymentInfo.validitySeconds` | one payment; wins over the client | — |
|
|
681
|
+
| `maxTimeoutSeconds` in the seller's 402 | `client.fetch()` signs the seller's declared window | — |
|
|
682
|
+
|
|
683
|
+
```typescript
|
|
684
|
+
import { X402Client, DEFAULT_VALIDITY_SECONDS, MAX_VALIDITY_SECONDS } from 'uvd-x402-sdk';
|
|
685
|
+
|
|
686
|
+
// Every payment from this client stays settleable for 10 minutes...
|
|
687
|
+
const client = new X402Client({ defaultChain: 'avalanche', validitySeconds: 600 });
|
|
688
|
+
|
|
689
|
+
// ...except this one, which the seller settles in batches
|
|
690
|
+
const result = await client.createPayment({
|
|
691
|
+
recipient: '0x...',
|
|
692
|
+
amount: '1.00',
|
|
693
|
+
validitySeconds: 1800,
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
DEFAULT_VALIDITY_SECONDS; // 300
|
|
697
|
+
MAX_VALIDITY_SECONDS; // 3600
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
- A value that is not a whole number between 1 and `MAX_VALIDITY_SECONDS` throws `INVALID_CONFIG`: from the constructor for the client config, and before anything is signed for a single payment.
|
|
701
|
+
- `client.fetch()` signs the `maxTimeoutSeconds` the seller's 402 declares, clamped to 1–3600 s. When the 402 declares none, the client's window applies.
|
|
702
|
+
- The facilitator keeps a 6 s clock-skew grace, so the payer really has `validitySeconds - 6` seconds. It never rejects a window for being long.
|
|
703
|
+
- Before 2.91.0 the window was 300 s on Base and 60 s on every other EVM network, and there was no way to change it.
|
|
704
|
+
|
|
673
705
|
## AUSD on Solana (Token2022)
|
|
674
706
|
|
|
675
707
|
```typescript
|
|
@@ -691,7 +723,7 @@ const header = svm.encodePaymentHeader(payload, chainConfig);
|
|
|
691
723
|
|
|
692
724
|
## Supported Networks
|
|
693
725
|
|
|
694
|
-
### EVM (
|
|
726
|
+
### EVM (16)
|
|
695
727
|
|
|
696
728
|
| Network | Chain ID | Tokens |
|
|
697
729
|
|---------|----------|--------|
|
|
@@ -710,6 +742,10 @@ const header = svm.encodePaymentHeader(payload, chainConfig);
|
|
|
710
742
|
| SKALE Base Sepolia | 324705682 | USDC.e |
|
|
711
743
|
| Robinhood Chain | 4663 | USDG |
|
|
712
744
|
| Robinhood Chain Testnet | 46630 | USDG |
|
|
745
|
+
| Arc | 5042 | USDC |
|
|
746
|
+
| Arc Testnet | 5042002 | USDC |
|
|
747
|
+
|
|
748
|
+
> **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).
|
|
713
749
|
|
|
714
750
|
> **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).
|
|
715
751
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { X as X402Version, a as PaymentResult } from '../index-
|
|
1
|
+
import { X as X402Version, a as PaymentResult } from '../index-DbauIMV2.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
|
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { X as X402Version, a as PaymentResult } from '../index-
|
|
1
|
+
import { X as X402Version, a as PaymentResult } from '../index-DbauIMV2.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
|
|
package/dist/adapters/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var ethers = require('ethers');
|
|
|
6
6
|
var DEFAULT_FACILITATOR_URL = "https://facilitator.ultravioletadao.xyz";
|
|
7
7
|
var SUPPORTED_CHAINS = {
|
|
8
8
|
// ============================================================================
|
|
9
|
-
// EVM CHAINS (
|
|
9
|
+
// EVM CHAINS (16 enabled + BSC, disabled)
|
|
10
10
|
// ============================================================================
|
|
11
11
|
base: {
|
|
12
12
|
chainId: 8453,
|
|
@@ -636,6 +636,91 @@ var SUPPORTED_CHAINS = {
|
|
|
636
636
|
enabled: true
|
|
637
637
|
}
|
|
638
638
|
},
|
|
639
|
+
// Arc testnet (Circle). The stablecoin IS the chain's native asset, so the SAME
|
|
640
|
+
// balance is readable at TWO precisions:
|
|
641
|
+
// - native / gas, via eth_getBalance and EIP-1559 fees: 18 decimals
|
|
642
|
+
// - ERC-20 interface, via balanceOf and transferWithAuthorization: 6 decimals
|
|
643
|
+
// (the ERC-20 view is floor(native / 10^12))
|
|
644
|
+
// An x402 payment is an EIP-3009 authorization against the ERC-20 interface, so
|
|
645
|
+
// its `value` is ALWAYS in the 6 of `tokens.usdc.decimals`. Scaling a price with
|
|
646
|
+
// `nativeCurrency.decimals` instead charges 10^12 times the amount: $0.01 would
|
|
647
|
+
// be signed as 10000000000000000 units, i.e. 10 billion USDC. `nativeCurrency`
|
|
648
|
+
// below is correct where it is actually used -- the wallet_addEthereumChain
|
|
649
|
+
// params -- and must never reach `parseUnits` for a payment.
|
|
650
|
+
// Pinned by src/arc-testnet.test.ts.
|
|
651
|
+
//
|
|
652
|
+
// Mainnet (5042) and testnet (5042002) were verified independently against
|
|
653
|
+
// their official RPCs on 2026-09-16. EURC is not registered without its E2E proof.
|
|
654
|
+
arc: {
|
|
655
|
+
chainId: 5042,
|
|
656
|
+
chainIdHex: "0x13b2",
|
|
657
|
+
name: "arc",
|
|
658
|
+
displayName: "Arc",
|
|
659
|
+
networkType: "evm",
|
|
660
|
+
rpcUrl: "https://rpc.mainnet.arc.io",
|
|
661
|
+
explorerUrl: "https://explorer.arc.io",
|
|
662
|
+
nativeCurrency: {
|
|
663
|
+
name: "USD Coin",
|
|
664
|
+
symbol: "USDC",
|
|
665
|
+
decimals: 18
|
|
666
|
+
// gas precision ONLY -- never the scale of a payment
|
|
667
|
+
},
|
|
668
|
+
usdc: {
|
|
669
|
+
address: "0x3600000000000000000000000000000000000000",
|
|
670
|
+
decimals: 6,
|
|
671
|
+
// ERC-20 interface, which is what an EIP-3009 value is denominated in
|
|
672
|
+
name: "USDC",
|
|
673
|
+
// on-chain name(); must match the EIP-712 domain exactly
|
|
674
|
+
version: "2"
|
|
675
|
+
},
|
|
676
|
+
tokens: {
|
|
677
|
+
usdc: {
|
|
678
|
+
address: "0x3600000000000000000000000000000000000000",
|
|
679
|
+
decimals: 6,
|
|
680
|
+
name: "USDC",
|
|
681
|
+
version: "2"
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
x402: {
|
|
685
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
686
|
+
enabled: true
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
"arc-testnet": {
|
|
690
|
+
chainId: 5042002,
|
|
691
|
+
chainIdHex: "0x4cef52",
|
|
692
|
+
name: "arc-testnet",
|
|
693
|
+
displayName: "Arc Testnet",
|
|
694
|
+
networkType: "evm",
|
|
695
|
+
rpcUrl: "https://rpc.testnet.arc.io",
|
|
696
|
+
explorerUrl: "https://explorer.testnet.arc.io",
|
|
697
|
+
nativeCurrency: {
|
|
698
|
+
name: "USD Coin",
|
|
699
|
+
symbol: "USDC",
|
|
700
|
+
decimals: 18
|
|
701
|
+
// gas precision ONLY -- never the scale of a payment
|
|
702
|
+
},
|
|
703
|
+
usdc: {
|
|
704
|
+
address: "0x3600000000000000000000000000000000000000",
|
|
705
|
+
decimals: 6,
|
|
706
|
+
// ERC-20 interface, which is what an EIP-3009 value is denominated in
|
|
707
|
+
name: "USDC",
|
|
708
|
+
// on-chain name(); must match the EIP-712 domain exactly
|
|
709
|
+
version: "2"
|
|
710
|
+
},
|
|
711
|
+
tokens: {
|
|
712
|
+
usdc: {
|
|
713
|
+
address: "0x3600000000000000000000000000000000000000",
|
|
714
|
+
decimals: 6,
|
|
715
|
+
name: "USDC",
|
|
716
|
+
version: "2"
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
x402: {
|
|
720
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
721
|
+
enabled: true
|
|
722
|
+
}
|
|
723
|
+
},
|
|
639
724
|
// ============================================================================
|
|
640
725
|
// SVM CHAINS (2 networks) - Solana Virtual Machine
|
|
641
726
|
// ============================================================================
|
|
@@ -1016,6 +1101,8 @@ var CAIP2_IDENTIFIERS = {
|
|
|
1016
1101
|
"skale-base-sepolia": "eip155:324705682",
|
|
1017
1102
|
robinhood: "eip155:4663",
|
|
1018
1103
|
"robinhood-testnet": "eip155:46630",
|
|
1104
|
+
arc: "eip155:5042",
|
|
1105
|
+
"arc-testnet": "eip155:5042002",
|
|
1019
1106
|
// SVM chains
|
|
1020
1107
|
solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
1021
1108
|
fogo: "svm:fogo",
|