uvd-x402-sdk 2.37.0 → 2.38.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 (2) hide show
  1. package/README.md +114 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -13,8 +13,10 @@ Users sign a message or transaction, and the Ultravioleta facilitator handles on
13
13
  - **Type-Safe**: Full TypeScript support
14
14
  - **React & Wagmi**: First-class integrations
15
15
  - **Signing Wallet Adapters**: EnvKeyAdapter (server/CLI), OWSWalletAdapter (Open Wallet Standard), or bring your own
16
- - **ERC-8004 Trustless Agents**: On-chain reputation and identity (EVM + Solana)
16
+ - **ERC-8004 Trustless Agents**: On-chain reputation and identity across 20 networks (18 EVM + 2 Solana)
17
17
  - **Escrow & Refunds**: Hold payments with dispute resolution
18
+ - **Advanced Escrow**: Full escrow lifecycle (authorize, release, refund, charge) with SigningWalletAdapter support
19
+ - **Commerce Scheme**: `'commerce'` scheme alias for marketplace integrations (identical to `'escrow'` on-chain)
18
20
  - **`/accepts` Negotiation**: Discover facilitator capabilities before constructing payments
19
21
  - **Bazaar Discovery**: Register and discover paid resources across the x402 network
20
22
  - **Facilitator Info**: Query version, supported networks, blacklist, and health
@@ -756,10 +758,20 @@ try {
756
758
 
757
759
  ## ERC-8004 Trustless Agents
758
760
 
759
- Build verifiable on-chain reputation for AI agents and services. Supports **18 networks** (16 EVM + Solana + Solana devnet).
761
+ Build verifiable on-chain reputation for AI agents and services. Supports **20 networks** (18 EVM + 2 Solana).
760
762
 
761
763
  On EVM networks, agent IDs are sequential numbers. On Solana, agent IDs are base58 pubkey strings. The `AgentId` type (`number | string`) handles both.
762
764
 
765
+ ### EVM Networks (18)
766
+
767
+ ethereum, base-mainnet, polygon, arbitrum, optimism, celo, bsc, monad, avalanche, skale-base, ethereum-sepolia, base-sepolia, polygon-amoy, arbitrum-sepolia, optimism-sepolia, celo-sepolia, avalanche-fuji, skale-base-sepolia
768
+
769
+ ### Solana Networks (2)
770
+
771
+ solana, solana-devnet
772
+
773
+ ### Usage
774
+
763
775
  ```typescript
764
776
  import { Erc8004Client, AgentId } from 'uvd-x402-sdk/backend';
765
777
 
@@ -773,6 +785,10 @@ console.log(identity.agentUri);
773
785
  const solIdentity = await erc8004.getIdentity('solana', '8oo4dC4JvBLwy5...');
774
786
  console.log(solIdentity.agentUri);
775
787
 
788
+ // Look up agent by wallet owner address
789
+ const byOwner = await erc8004.getIdentityByOwner('base-mainnet', '0xOwnerAddress...');
790
+ console.log(byOwner.agentId, byOwner.identity.agentUri);
791
+
776
792
  // Get agent reputation
777
793
  const reputation = await erc8004.getReputation('ethereum', 42);
778
794
  console.log(`Score: ${reputation.summary.summaryValue}`);
@@ -851,6 +867,102 @@ const state = await escrow.getEscrowState({
851
867
  });
852
868
  ```
853
869
 
870
+ ## Advanced Escrow (AdvancedEscrowClient)
871
+
872
+ Full escrow lifecycle management for EVM chains. Supports both `ethers.Signer` and `SigningWalletAdapter` (EnvKey, OWS) for signing.
873
+
874
+ Supported on 10 EVM networks: Base, Base Sepolia, Ethereum, Ethereum Sepolia, Polygon, Arbitrum, Optimism, Celo, Monad, Avalanche.
875
+
876
+ ### With Private Key (ethers.Signer)
877
+
878
+ ```typescript
879
+ import { AdvancedEscrowClient } from 'uvd-x402-sdk/backend';
880
+
881
+ const client = new AdvancedEscrowClient(process.env.PRIVATE_KEY!, {
882
+ chainId: 8453, // Base
883
+ });
884
+ await client.init();
885
+
886
+ // Build payment info
887
+ const paymentInfo = client.buildPaymentInfo(
888
+ '0xWorkerAddress...', // receiver
889
+ '5000000', // amount in atomic units ($5.00 USDC)
890
+ 'standard', // tier: 'standard' | 'express' | 'premium'
891
+ );
892
+
893
+ // Authorize: lock funds in escrow
894
+ const auth = await client.authorize(paymentInfo);
895
+
896
+ // Release: capture escrowed funds to receiver
897
+ await client.release(paymentInfo);
898
+
899
+ // Or refund: return escrowed funds to payer
900
+ await client.refundInEscrow(paymentInfo);
901
+
902
+ // Query escrow state on-chain
903
+ const state = await client.queryEscrowState(paymentInfo);
904
+ ```
905
+
906
+ ### With SigningWalletAdapter (OWS)
907
+
908
+ ```typescript
909
+ import { AdvancedEscrowClient } from 'uvd-x402-sdk/backend';
910
+ import { OWSWalletAdapter } from 'uvd-x402-sdk';
911
+
912
+ const wallet = new OWSWalletAdapter(owsWalletInstance);
913
+ const client = new AdvancedEscrowClient(null, {
914
+ wallet,
915
+ rpcUrl: 'https://mainnet.base.org',
916
+ chainId: 8453,
917
+ });
918
+ await client.init();
919
+
920
+ const paymentInfo = client.buildPaymentInfo('0xWorker...', '5000000', 'standard');
921
+ const auth = await client.authorize(paymentInfo);
922
+ ```
923
+
924
+ ### Gasless Operations via Facilitator
925
+
926
+ Release and refund can be executed through the facilitator (no gas required):
927
+
928
+ ```typescript
929
+ // Gasless release
930
+ await client.releaseViaFacilitator(paymentInfo);
931
+
932
+ // Gasless refund
933
+ await client.refundViaFacilitator(paymentInfo);
934
+ ```
935
+
936
+ ### Direct Charge (No Escrow)
937
+
938
+ ```typescript
939
+ // Instant payment without escrow hold
940
+ await client.charge(paymentInfo);
941
+ ```
942
+
943
+ ## Commerce Scheme
944
+
945
+ The `'commerce'` scheme is a semantic alias for `'escrow'`, introduced for marketplace integrations (Execution Market, arbiter workflows). It uses the same contracts, ABI, and ERC-3009 flow as `'escrow'`.
946
+
947
+ ```typescript
948
+ import type { X402Scheme } from 'uvd-x402-sdk';
949
+
950
+ // All three schemes are valid
951
+ const scheme: X402Scheme = 'commerce'; // or 'exact' or 'escrow'
952
+
953
+ // PaymentRequirements and X402 headers accept all schemes
954
+ const header = {
955
+ x402Version: 2,
956
+ scheme: 'commerce',
957
+ network: 'eip155:8453',
958
+ payload: { /* ... */ },
959
+ };
960
+
961
+ // Default behavior unchanged: buildPaymentRequirements() defaults to 'exact'
962
+ ```
963
+
964
+ The facilitator's `/supported` endpoint advertises both `'escrow'` and `'commerce'` entries for all 11 escrow-capable networks (14 entries each).
965
+
854
966
  ## Bazaar Discovery
855
967
 
856
968
  Register and discover paid x402 resources across the network.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uvd-x402-sdk",
3
- "version": "2.37.0",
3
+ "version": "2.38.0",
4
4
  "description": "x402 Payment SDK - Gasless crypto payments across 21 blockchains via Ultravioleta facilitator. Supports EVM (including Scroll, SKALE Base), Solana, Fogo, Stellar, NEAR, Algorand, and Sui. Features: ERC-8004 Trustless Agents, Escrow/Refunds, multi-stablecoin (USDC, EURC, AUSD, PYUSD, USDT).",
5
5
  "author": "Ultravioleta DAO <ultravioletadao@gmail.com>",
6
6
  "license": "MIT",