@0xarchive/sdk 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -636,6 +636,110 @@ const client = new OxArchive({
636
636
  });
637
637
  ```
638
638
 
639
+ ### Web3 Authentication
640
+
641
+ Get API keys programmatically using an Ethereum wallet — no browser or email required.
642
+
643
+ #### Free Tier (SIWE)
644
+
645
+ ```typescript
646
+ import { createWalletClient, http } from 'viem';
647
+ import { privateKeyToAccount } from 'viem/accounts';
648
+ import { mainnet } from 'viem/chains';
649
+
650
+ const account = privateKeyToAccount('0xYOUR_PRIVATE_KEY');
651
+ const walletClient = createWalletClient({ account, chain: mainnet, transport: http() });
652
+
653
+ // 1. Get SIWE challenge
654
+ const challenge = await client.web3.challenge(account.address);
655
+
656
+ // 2. Sign with personal_sign (EIP-191)
657
+ const signature = await walletClient.signMessage({ message: challenge.message });
658
+
659
+ // 3. Submit → receive API key
660
+ const result = await client.web3.signup(challenge.message, signature);
661
+ console.log(result.apiKey); // "0xa_..."
662
+ ```
663
+
664
+ #### Paid Tier (x402 USDC on Base)
665
+
666
+ ```typescript
667
+ import { createWalletClient, http, encodePacked } from 'viem';
668
+ import { privateKeyToAccount } from 'viem/accounts';
669
+ import { base } from 'viem/chains';
670
+ import crypto from 'crypto';
671
+
672
+ const account = privateKeyToAccount('0xYOUR_PRIVATE_KEY');
673
+ const walletClient = createWalletClient({ account, chain: base, transport: http() });
674
+
675
+ const USDC_ADDRESS = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
676
+
677
+ // 1. Get pricing
678
+ const quote = await client.web3.subscribeQuote('build');
679
+ // quote.amount = "49000000" ($49 USDC), quote.payTo = "0x..."
680
+
681
+ // 2. Build & sign EIP-3009 transferWithAuthorization
682
+ const nonce = `0x${crypto.randomBytes(32).toString('hex')}` as `0x${string}`;
683
+ const validAfter = 0n;
684
+ const validBefore = BigInt(Math.floor(Date.now() / 1000) + 3600);
685
+
686
+ const signature = await walletClient.signTypedData({
687
+ domain: {
688
+ name: 'USD Coin',
689
+ version: '2',
690
+ chainId: 8453,
691
+ verifyingContract: USDC_ADDRESS,
692
+ },
693
+ types: {
694
+ TransferWithAuthorization: [
695
+ { name: 'from', type: 'address' },
696
+ { name: 'to', type: 'address' },
697
+ { name: 'value', type: 'uint256' },
698
+ { name: 'validAfter', type: 'uint256' },
699
+ { name: 'validBefore', type: 'uint256' },
700
+ { name: 'nonce', type: 'bytes32' },
701
+ ],
702
+ },
703
+ primaryType: 'TransferWithAuthorization',
704
+ message: {
705
+ from: account.address,
706
+ to: quote.payTo as `0x${string}`,
707
+ value: BigInt(quote.amount),
708
+ validAfter,
709
+ validBefore,
710
+ nonce,
711
+ },
712
+ });
713
+
714
+ // 3. Build x402 payment envelope and base64-encode
715
+ const paymentPayload = btoa(JSON.stringify({
716
+ x402Version: 2,
717
+ payload: {
718
+ signature,
719
+ authorization: {
720
+ from: account.address,
721
+ to: quote.payTo,
722
+ value: quote.amount,
723
+ validAfter: '0',
724
+ validBefore: validBefore.toString(),
725
+ nonce,
726
+ },
727
+ },
728
+ }));
729
+
730
+ // 4. Submit payment → receive API key + subscription
731
+ const sub = await client.web3.subscribe('build', paymentPayload);
732
+ console.log(sub.apiKey, sub.tier, sub.expiresAt);
733
+ ```
734
+
735
+ #### Key Management
736
+
737
+ ```typescript
738
+ // List and revoke keys (requires a fresh SIWE signature)
739
+ const keys = await client.web3.listKeys(challenge.message, signature);
740
+ await client.web3.revokeKey(challenge.message, signature, keys.keys[0].id);
741
+ ```
742
+
639
743
  ### Legacy API (Deprecated)
640
744
 
641
745
  The following legacy methods are deprecated and will be removed in v2.0. They default to Hyperliquid data:
package/dist/index.d.mts CHANGED
@@ -736,6 +736,77 @@ interface WsEventHandlers {
736
736
  onMessage?: (message: WsServerMessage) => void;
737
737
  onStateChange?: (state: WsConnectionState) => void;
738
738
  }
739
+ /** SIWE challenge message returned by the challenge endpoint */
740
+ interface SiweChallenge {
741
+ /** The SIWE message to sign with personal_sign (EIP-191) */
742
+ message: string;
743
+ /** Single-use nonce (expires after 10 minutes) */
744
+ nonce: string;
745
+ }
746
+ /** Result of creating a free-tier account via wallet signature */
747
+ interface Web3SignupResult {
748
+ /** The generated API key */
749
+ apiKey: string;
750
+ /** Account tier (e.g., 'free') */
751
+ tier: string;
752
+ /** The wallet address that owns this key */
753
+ walletAddress: string;
754
+ }
755
+ /** An API key record returned by the keys endpoint */
756
+ interface Web3ApiKey {
757
+ /** Unique key ID (UUID) */
758
+ id: string;
759
+ /** Key name */
760
+ name: string;
761
+ /** First characters of the key for identification */
762
+ keyPrefix: string;
763
+ /** Whether the key is currently active */
764
+ isActive: boolean;
765
+ /** Last usage timestamp (ISO 8601) */
766
+ lastUsedAt?: string;
767
+ /** Creation timestamp (ISO 8601) */
768
+ createdAt: string;
769
+ }
770
+ /** List of API keys for a wallet */
771
+ interface Web3KeysList {
772
+ /** All API keys belonging to this wallet */
773
+ keys: Web3ApiKey[];
774
+ /** The wallet address */
775
+ walletAddress: string;
776
+ }
777
+ /** Result of revoking an API key */
778
+ interface Web3RevokeResult {
779
+ /** Confirmation message */
780
+ message: string;
781
+ /** The wallet address that owned the key */
782
+ walletAddress: string;
783
+ }
784
+ /** x402 payment details returned by subscribe (402 response) */
785
+ interface Web3PaymentRequired {
786
+ /** Amount in smallest unit (e.g., "49000000" for $49 USDC) */
787
+ amount: string;
788
+ /** Payment asset (e.g., "USDC") */
789
+ asset: string;
790
+ /** Blockchain network (e.g., "base") */
791
+ network: string;
792
+ /** Address to send payment to */
793
+ payTo: string;
794
+ /** Token contract address */
795
+ assetAddress: string;
796
+ }
797
+ /** Result of a successful x402 subscription */
798
+ interface Web3SubscribeResult {
799
+ /** The generated API key */
800
+ apiKey: string;
801
+ /** Subscription tier */
802
+ tier: string;
803
+ /** Expiration timestamp (ISO 8601) */
804
+ expiresAt: string;
805
+ /** The wallet address that owns the subscription */
806
+ walletAddress: string;
807
+ /** On-chain transaction hash */
808
+ txHash?: string;
809
+ }
739
810
  /**
740
811
  * API error response
741
812
  */
@@ -1051,6 +1122,10 @@ declare class HttpClient {
1051
1122
  constructor(options: HttpClientOptions);
1052
1123
  /** Whether validation is enabled */
1053
1124
  get validationEnabled(): boolean;
1125
+ /** Base URL for raw requests (used by web3 subscribe) */
1126
+ getBaseUrl(): string;
1127
+ /** Timeout in ms for raw requests (used by web3 subscribe) */
1128
+ getTimeout(): number;
1054
1129
  /**
1055
1130
  * Make a GET request to the API
1056
1131
  *
@@ -1059,6 +1134,14 @@ declare class HttpClient {
1059
1134
  * @param schema - Optional Zod schema for validation (used when validation is enabled)
1060
1135
  */
1061
1136
  get<T>(path: string, params?: Record<string, unknown>, schema?: z.ZodType<T>): Promise<T>;
1137
+ /**
1138
+ * Make a POST request to the API
1139
+ *
1140
+ * @param path - API endpoint path
1141
+ * @param body - JSON request body
1142
+ * @param schema - Optional Zod schema for validation (used when validation is enabled)
1143
+ */
1144
+ post<T>(path: string, body?: Record<string, unknown>, schema?: z.ZodType<T>): Promise<T>;
1062
1145
  }
1063
1146
 
1064
1147
  /**
@@ -1979,6 +2062,82 @@ declare class DataQualityResource {
1979
2062
  sla(params?: SlaParams): Promise<SlaResponse>;
1980
2063
  }
1981
2064
 
2065
+ /**
2066
+ * Wallet-based authentication: get API keys via SIWE signature.
2067
+ *
2068
+ * No API key is required for these endpoints. Use an Ethereum wallet to
2069
+ * create a free-tier account, list keys, or revoke keys — all programmatically.
2070
+ *
2071
+ * @example
2072
+ * ```typescript
2073
+ * const client = new OxArchive({ apiKey: 'placeholder' });
2074
+ *
2075
+ * // Step 1: Get a challenge
2076
+ * const challenge = await client.web3.challenge('0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18');
2077
+ *
2078
+ * // Step 2: Sign the message with your wallet, then submit
2079
+ * const result = await client.web3.signup(challenge.message, signature);
2080
+ * console.log(`API key: ${result.apiKey}`);
2081
+ * ```
2082
+ */
2083
+ declare class Web3Resource {
2084
+ private http;
2085
+ constructor(http: HttpClient);
2086
+ /**
2087
+ * Get a SIWE challenge message to sign.
2088
+ *
2089
+ * @param address - Ethereum wallet address
2090
+ * @returns SIWE message and nonce. Sign the message with personal_sign (EIP-191).
2091
+ */
2092
+ challenge(address: string): Promise<SiweChallenge>;
2093
+ /**
2094
+ * Create a free-tier account and get an API key.
2095
+ *
2096
+ * @param message - The SIWE message from {@link challenge}
2097
+ * @param signature - Hex-encoded signature from personal_sign
2098
+ * @returns API key, tier, and wallet address
2099
+ */
2100
+ signup(message: string, signature: string): Promise<Web3SignupResult>;
2101
+ /**
2102
+ * List all API keys for the authenticated wallet.
2103
+ *
2104
+ * @param message - The SIWE message from {@link challenge}
2105
+ * @param signature - Hex-encoded signature from personal_sign
2106
+ * @returns List of API keys and wallet address
2107
+ */
2108
+ listKeys(message: string, signature: string): Promise<Web3KeysList>;
2109
+ /**
2110
+ * Revoke a specific API key.
2111
+ *
2112
+ * @param message - The SIWE message from {@link challenge}
2113
+ * @param signature - Hex-encoded signature from personal_sign
2114
+ * @param keyId - UUID of the key to revoke
2115
+ * @returns Confirmation message and wallet address
2116
+ */
2117
+ revokeKey(message: string, signature: string, keyId: string): Promise<Web3RevokeResult>;
2118
+ /**
2119
+ * Get pricing info for a paid subscription (x402 flow, step 1).
2120
+ *
2121
+ * Returns the payment details needed to sign a USDC transfer on Base.
2122
+ * After signing, pass the payment signature to {@link subscribe}.
2123
+ *
2124
+ * @param tier - Subscription tier: 'build' ($49/mo) or 'pro' ($199/mo)
2125
+ * @returns Payment details (amount, asset, network, pay-to address)
2126
+ */
2127
+ subscribeQuote(tier: 'build' | 'pro'): Promise<Web3PaymentRequired>;
2128
+ /**
2129
+ * Complete a paid subscription with a signed x402 payment (step 2).
2130
+ *
2131
+ * Requires a payment signature from signing a USDC transfer (EIP-3009)
2132
+ * for the amount returned by {@link subscribeQuote}.
2133
+ *
2134
+ * @param tier - Subscription tier: 'build' or 'pro'
2135
+ * @param paymentSignature - Signed x402 payment (from EIP-3009 USDC transfer on Base)
2136
+ * @returns API key, tier, expiration, and wallet address
2137
+ */
2138
+ subscribe(tier: 'build' | 'pro', paymentSignature: string): Promise<Web3SubscribeResult>;
2139
+ }
2140
+
1982
2141
  /**
1983
2142
  * Hyperliquid exchange client
1984
2143
  *
@@ -2228,6 +2387,10 @@ declare class OxArchive {
2228
2387
  * Data quality metrics: status, coverage, incidents, latency, SLA
2229
2388
  */
2230
2389
  readonly dataQuality: DataQualityResource;
2390
+ /**
2391
+ * Wallet-based auth: get API keys via SIWE signature
2392
+ */
2393
+ readonly web3: Web3Resource;
2231
2394
  /**
2232
2395
  * @deprecated Use client.hyperliquid.orderbook instead
2233
2396
  */
@@ -5080,4 +5243,4 @@ type ValidatedCandle = z.infer<typeof CandleSchema>;
5080
5243
  type ValidatedLiquidation = z.infer<typeof LiquidationSchema>;
5081
5244
  type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
5082
5245
 
5083
- export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type Candle, CandleArrayResponseSchema, type CandleHistoryParams, type CandleInterval, CandleIntervalSchema, CandleSchema, type ClientOptions, type CoinFreshness, CoinFreshnessResponseSchema, CoinFreshnessSchema, type CoinSummary, CoinSummaryResponseSchema, CoinSummarySchema, type CompletenessMetrics, type CoverageGap, type CoverageResponse, type CursorResponse, type DataCadence, type DataFreshness, type DataTypeCoverage, type DataTypeFreshnessInfo, DataTypeFreshnessInfoSchema, type DataTypeStatus, type ExchangeCoverage, type ExchangeLatency, type ExchangeStatus, type FundingHistoryParams, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, Hip3Client, type Hip3Instrument, HyperliquidClient, type Incident, type IncidentSeverityValue, type IncidentStatusValue, type IncidentsResponse, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, type LatencyResponse, LighterClient, type LighterGranularity, type LighterInstrument, type Liquidation, LiquidationArrayResponseSchema, type LiquidationHistoryParams, LiquidationSchema, LiquidationSideSchema, type LiquidationVolume, LiquidationVolumeArrayResponseSchema, type LiquidationVolumeParams, LiquidationVolumeSchema, type LiquidationsByUserParams, type ListIncidentsParams, type OiFundingInterval, type OpenInterest, OpenInterestArrayResponseSchema, type OpenInterestHistoryParams, OpenInterestResponseSchema, OpenInterestSchema, type OrderBook, OrderBookArrayResponseSchema, type OrderBookHistoryParams, OrderBookReconstructor, OrderBookResponseSchema, OrderBookSchema, type OrderbookDelta, OxArchive, OxArchiveError, OxArchiveWs, type Pagination, type PriceHistoryParams, type PriceLevel, PriceLevelSchema, type PriceSnapshot, PriceSnapshotArrayResponseSchema, PriceSnapshotSchema, type ReconstructOptions, type ReconstructedOrderBook, type RestApiLatency, type SlaActual, type SlaParams, type SlaResponse, type SlaTargets, type StatusResponse, type SymbolCoverageOptions, type SymbolCoverageResponse, type SymbolDataTypeCoverage, type SystemStatusValue, type TickData, type TickHistoryParams, type Timestamp, type TimestampedRecord, TimestampedRecordSchema, type Trade, TradeArrayResponseSchema, type TradeDirection, TradeDirectionSchema, TradeSchema, type TradeSide, TradeSideSchema, type ValidatedApiMeta, type ValidatedCandle, type ValidatedFundingRate, type ValidatedInstrument, type ValidatedLiquidation, type ValidatedOpenInterest, type ValidatedOrderBook, type ValidatedPriceLevel, type ValidatedTrade, type ValidatedWsServerMessage, type WebSocketLatency, type WsChannel, WsChannelSchema, type WsClientMessage, type WsConnectionState, WsConnectionStateSchema, type WsData, WsDataSchema, type WsError, WsErrorSchema, type WsEventHandlers, type WsGapDetected, type WsHistoricalBatch, WsHistoricalBatchSchema, type WsHistoricalData, WsHistoricalDataSchema, type WsHistoricalTickData, type WsOptions, type WsPing, type WsPong, WsPongSchema, type WsReplay, type WsReplayCompleted, WsReplayCompletedSchema, type WsReplayPause, type WsReplayPaused, WsReplayPausedSchema, type WsReplayResume, type WsReplayResumed, WsReplayResumedSchema, type WsReplaySeek, type WsReplaySnapshot, WsReplaySnapshotSchema, type WsReplayStarted, WsReplayStartedSchema, type WsReplayStop, type WsReplayStopped, WsReplayStoppedSchema, type WsServerMessage, WsServerMessageSchema, type WsStream, type WsStreamCompleted, WsStreamCompletedSchema, type WsStreamProgress, WsStreamProgressSchema, type WsStreamStarted, WsStreamStartedSchema, type WsStreamStop, type WsStreamStopped, WsStreamStoppedSchema, type WsSubscribe, type WsSubscribed, WsSubscribedSchema, type WsUnsubscribe, type WsUnsubscribed, WsUnsubscribedSchema, OxArchive as default, reconstructFinal, reconstructOrderBook };
5246
+ export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type Candle, CandleArrayResponseSchema, type CandleHistoryParams, type CandleInterval, CandleIntervalSchema, CandleSchema, type ClientOptions, type CoinFreshness, CoinFreshnessResponseSchema, CoinFreshnessSchema, type CoinSummary, CoinSummaryResponseSchema, CoinSummarySchema, type CompletenessMetrics, type CoverageGap, type CoverageResponse, type CursorResponse, type DataCadence, type DataFreshness, type DataTypeCoverage, type DataTypeFreshnessInfo, DataTypeFreshnessInfoSchema, type DataTypeStatus, type ExchangeCoverage, type ExchangeLatency, type ExchangeStatus, type FundingHistoryParams, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, Hip3Client, type Hip3Instrument, HyperliquidClient, type Incident, type IncidentSeverityValue, type IncidentStatusValue, type IncidentsResponse, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, type LatencyResponse, LighterClient, type LighterGranularity, type LighterInstrument, type Liquidation, LiquidationArrayResponseSchema, type LiquidationHistoryParams, LiquidationSchema, LiquidationSideSchema, type LiquidationVolume, LiquidationVolumeArrayResponseSchema, type LiquidationVolumeParams, LiquidationVolumeSchema, type LiquidationsByUserParams, type ListIncidentsParams, type OiFundingInterval, type OpenInterest, OpenInterestArrayResponseSchema, type OpenInterestHistoryParams, OpenInterestResponseSchema, OpenInterestSchema, type OrderBook, OrderBookArrayResponseSchema, type OrderBookHistoryParams, OrderBookReconstructor, OrderBookResponseSchema, OrderBookSchema, type OrderbookDelta, OxArchive, OxArchiveError, OxArchiveWs, type Pagination, type PriceHistoryParams, type PriceLevel, PriceLevelSchema, type PriceSnapshot, PriceSnapshotArrayResponseSchema, PriceSnapshotSchema, type ReconstructOptions, type ReconstructedOrderBook, type RestApiLatency, type SiweChallenge, type SlaActual, type SlaParams, type SlaResponse, type SlaTargets, type StatusResponse, type SymbolCoverageOptions, type SymbolCoverageResponse, type SymbolDataTypeCoverage, type SystemStatusValue, type TickData, type TickHistoryParams, type Timestamp, type TimestampedRecord, TimestampedRecordSchema, type Trade, TradeArrayResponseSchema, type TradeDirection, TradeDirectionSchema, TradeSchema, type TradeSide, TradeSideSchema, type ValidatedApiMeta, type ValidatedCandle, type ValidatedFundingRate, type ValidatedInstrument, type ValidatedLiquidation, type ValidatedOpenInterest, type ValidatedOrderBook, type ValidatedPriceLevel, type ValidatedTrade, type ValidatedWsServerMessage, type Web3ApiKey, type Web3KeysList, type Web3PaymentRequired, type Web3RevokeResult, type Web3SignupResult, type Web3SubscribeResult, type WebSocketLatency, type WsChannel, WsChannelSchema, type WsClientMessage, type WsConnectionState, WsConnectionStateSchema, type WsData, WsDataSchema, type WsError, WsErrorSchema, type WsEventHandlers, type WsGapDetected, type WsHistoricalBatch, WsHistoricalBatchSchema, type WsHistoricalData, WsHistoricalDataSchema, type WsHistoricalTickData, type WsOptions, type WsPing, type WsPong, WsPongSchema, type WsReplay, type WsReplayCompleted, WsReplayCompletedSchema, type WsReplayPause, type WsReplayPaused, WsReplayPausedSchema, type WsReplayResume, type WsReplayResumed, WsReplayResumedSchema, type WsReplaySeek, type WsReplaySnapshot, WsReplaySnapshotSchema, type WsReplayStarted, WsReplayStartedSchema, type WsReplayStop, type WsReplayStopped, WsReplayStoppedSchema, type WsServerMessage, WsServerMessageSchema, type WsStream, type WsStreamCompleted, WsStreamCompletedSchema, type WsStreamProgress, WsStreamProgressSchema, type WsStreamStarted, WsStreamStartedSchema, type WsStreamStop, type WsStreamStopped, WsStreamStoppedSchema, type WsSubscribe, type WsSubscribed, WsSubscribedSchema, type WsUnsubscribe, type WsUnsubscribed, WsUnsubscribedSchema, OxArchive as default, reconstructFinal, reconstructOrderBook };
package/dist/index.d.ts CHANGED
@@ -736,6 +736,77 @@ interface WsEventHandlers {
736
736
  onMessage?: (message: WsServerMessage) => void;
737
737
  onStateChange?: (state: WsConnectionState) => void;
738
738
  }
739
+ /** SIWE challenge message returned by the challenge endpoint */
740
+ interface SiweChallenge {
741
+ /** The SIWE message to sign with personal_sign (EIP-191) */
742
+ message: string;
743
+ /** Single-use nonce (expires after 10 minutes) */
744
+ nonce: string;
745
+ }
746
+ /** Result of creating a free-tier account via wallet signature */
747
+ interface Web3SignupResult {
748
+ /** The generated API key */
749
+ apiKey: string;
750
+ /** Account tier (e.g., 'free') */
751
+ tier: string;
752
+ /** The wallet address that owns this key */
753
+ walletAddress: string;
754
+ }
755
+ /** An API key record returned by the keys endpoint */
756
+ interface Web3ApiKey {
757
+ /** Unique key ID (UUID) */
758
+ id: string;
759
+ /** Key name */
760
+ name: string;
761
+ /** First characters of the key for identification */
762
+ keyPrefix: string;
763
+ /** Whether the key is currently active */
764
+ isActive: boolean;
765
+ /** Last usage timestamp (ISO 8601) */
766
+ lastUsedAt?: string;
767
+ /** Creation timestamp (ISO 8601) */
768
+ createdAt: string;
769
+ }
770
+ /** List of API keys for a wallet */
771
+ interface Web3KeysList {
772
+ /** All API keys belonging to this wallet */
773
+ keys: Web3ApiKey[];
774
+ /** The wallet address */
775
+ walletAddress: string;
776
+ }
777
+ /** Result of revoking an API key */
778
+ interface Web3RevokeResult {
779
+ /** Confirmation message */
780
+ message: string;
781
+ /** The wallet address that owned the key */
782
+ walletAddress: string;
783
+ }
784
+ /** x402 payment details returned by subscribe (402 response) */
785
+ interface Web3PaymentRequired {
786
+ /** Amount in smallest unit (e.g., "49000000" for $49 USDC) */
787
+ amount: string;
788
+ /** Payment asset (e.g., "USDC") */
789
+ asset: string;
790
+ /** Blockchain network (e.g., "base") */
791
+ network: string;
792
+ /** Address to send payment to */
793
+ payTo: string;
794
+ /** Token contract address */
795
+ assetAddress: string;
796
+ }
797
+ /** Result of a successful x402 subscription */
798
+ interface Web3SubscribeResult {
799
+ /** The generated API key */
800
+ apiKey: string;
801
+ /** Subscription tier */
802
+ tier: string;
803
+ /** Expiration timestamp (ISO 8601) */
804
+ expiresAt: string;
805
+ /** The wallet address that owns the subscription */
806
+ walletAddress: string;
807
+ /** On-chain transaction hash */
808
+ txHash?: string;
809
+ }
739
810
  /**
740
811
  * API error response
741
812
  */
@@ -1051,6 +1122,10 @@ declare class HttpClient {
1051
1122
  constructor(options: HttpClientOptions);
1052
1123
  /** Whether validation is enabled */
1053
1124
  get validationEnabled(): boolean;
1125
+ /** Base URL for raw requests (used by web3 subscribe) */
1126
+ getBaseUrl(): string;
1127
+ /** Timeout in ms for raw requests (used by web3 subscribe) */
1128
+ getTimeout(): number;
1054
1129
  /**
1055
1130
  * Make a GET request to the API
1056
1131
  *
@@ -1059,6 +1134,14 @@ declare class HttpClient {
1059
1134
  * @param schema - Optional Zod schema for validation (used when validation is enabled)
1060
1135
  */
1061
1136
  get<T>(path: string, params?: Record<string, unknown>, schema?: z.ZodType<T>): Promise<T>;
1137
+ /**
1138
+ * Make a POST request to the API
1139
+ *
1140
+ * @param path - API endpoint path
1141
+ * @param body - JSON request body
1142
+ * @param schema - Optional Zod schema for validation (used when validation is enabled)
1143
+ */
1144
+ post<T>(path: string, body?: Record<string, unknown>, schema?: z.ZodType<T>): Promise<T>;
1062
1145
  }
1063
1146
 
1064
1147
  /**
@@ -1979,6 +2062,82 @@ declare class DataQualityResource {
1979
2062
  sla(params?: SlaParams): Promise<SlaResponse>;
1980
2063
  }
1981
2064
 
2065
+ /**
2066
+ * Wallet-based authentication: get API keys via SIWE signature.
2067
+ *
2068
+ * No API key is required for these endpoints. Use an Ethereum wallet to
2069
+ * create a free-tier account, list keys, or revoke keys — all programmatically.
2070
+ *
2071
+ * @example
2072
+ * ```typescript
2073
+ * const client = new OxArchive({ apiKey: 'placeholder' });
2074
+ *
2075
+ * // Step 1: Get a challenge
2076
+ * const challenge = await client.web3.challenge('0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18');
2077
+ *
2078
+ * // Step 2: Sign the message with your wallet, then submit
2079
+ * const result = await client.web3.signup(challenge.message, signature);
2080
+ * console.log(`API key: ${result.apiKey}`);
2081
+ * ```
2082
+ */
2083
+ declare class Web3Resource {
2084
+ private http;
2085
+ constructor(http: HttpClient);
2086
+ /**
2087
+ * Get a SIWE challenge message to sign.
2088
+ *
2089
+ * @param address - Ethereum wallet address
2090
+ * @returns SIWE message and nonce. Sign the message with personal_sign (EIP-191).
2091
+ */
2092
+ challenge(address: string): Promise<SiweChallenge>;
2093
+ /**
2094
+ * Create a free-tier account and get an API key.
2095
+ *
2096
+ * @param message - The SIWE message from {@link challenge}
2097
+ * @param signature - Hex-encoded signature from personal_sign
2098
+ * @returns API key, tier, and wallet address
2099
+ */
2100
+ signup(message: string, signature: string): Promise<Web3SignupResult>;
2101
+ /**
2102
+ * List all API keys for the authenticated wallet.
2103
+ *
2104
+ * @param message - The SIWE message from {@link challenge}
2105
+ * @param signature - Hex-encoded signature from personal_sign
2106
+ * @returns List of API keys and wallet address
2107
+ */
2108
+ listKeys(message: string, signature: string): Promise<Web3KeysList>;
2109
+ /**
2110
+ * Revoke a specific API key.
2111
+ *
2112
+ * @param message - The SIWE message from {@link challenge}
2113
+ * @param signature - Hex-encoded signature from personal_sign
2114
+ * @param keyId - UUID of the key to revoke
2115
+ * @returns Confirmation message and wallet address
2116
+ */
2117
+ revokeKey(message: string, signature: string, keyId: string): Promise<Web3RevokeResult>;
2118
+ /**
2119
+ * Get pricing info for a paid subscription (x402 flow, step 1).
2120
+ *
2121
+ * Returns the payment details needed to sign a USDC transfer on Base.
2122
+ * After signing, pass the payment signature to {@link subscribe}.
2123
+ *
2124
+ * @param tier - Subscription tier: 'build' ($49/mo) or 'pro' ($199/mo)
2125
+ * @returns Payment details (amount, asset, network, pay-to address)
2126
+ */
2127
+ subscribeQuote(tier: 'build' | 'pro'): Promise<Web3PaymentRequired>;
2128
+ /**
2129
+ * Complete a paid subscription with a signed x402 payment (step 2).
2130
+ *
2131
+ * Requires a payment signature from signing a USDC transfer (EIP-3009)
2132
+ * for the amount returned by {@link subscribeQuote}.
2133
+ *
2134
+ * @param tier - Subscription tier: 'build' or 'pro'
2135
+ * @param paymentSignature - Signed x402 payment (from EIP-3009 USDC transfer on Base)
2136
+ * @returns API key, tier, expiration, and wallet address
2137
+ */
2138
+ subscribe(tier: 'build' | 'pro', paymentSignature: string): Promise<Web3SubscribeResult>;
2139
+ }
2140
+
1982
2141
  /**
1983
2142
  * Hyperliquid exchange client
1984
2143
  *
@@ -2228,6 +2387,10 @@ declare class OxArchive {
2228
2387
  * Data quality metrics: status, coverage, incidents, latency, SLA
2229
2388
  */
2230
2389
  readonly dataQuality: DataQualityResource;
2390
+ /**
2391
+ * Wallet-based auth: get API keys via SIWE signature
2392
+ */
2393
+ readonly web3: Web3Resource;
2231
2394
  /**
2232
2395
  * @deprecated Use client.hyperliquid.orderbook instead
2233
2396
  */
@@ -5080,4 +5243,4 @@ type ValidatedCandle = z.infer<typeof CandleSchema>;
5080
5243
  type ValidatedLiquidation = z.infer<typeof LiquidationSchema>;
5081
5244
  type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
5082
5245
 
5083
- export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type Candle, CandleArrayResponseSchema, type CandleHistoryParams, type CandleInterval, CandleIntervalSchema, CandleSchema, type ClientOptions, type CoinFreshness, CoinFreshnessResponseSchema, CoinFreshnessSchema, type CoinSummary, CoinSummaryResponseSchema, CoinSummarySchema, type CompletenessMetrics, type CoverageGap, type CoverageResponse, type CursorResponse, type DataCadence, type DataFreshness, type DataTypeCoverage, type DataTypeFreshnessInfo, DataTypeFreshnessInfoSchema, type DataTypeStatus, type ExchangeCoverage, type ExchangeLatency, type ExchangeStatus, type FundingHistoryParams, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, Hip3Client, type Hip3Instrument, HyperliquidClient, type Incident, type IncidentSeverityValue, type IncidentStatusValue, type IncidentsResponse, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, type LatencyResponse, LighterClient, type LighterGranularity, type LighterInstrument, type Liquidation, LiquidationArrayResponseSchema, type LiquidationHistoryParams, LiquidationSchema, LiquidationSideSchema, type LiquidationVolume, LiquidationVolumeArrayResponseSchema, type LiquidationVolumeParams, LiquidationVolumeSchema, type LiquidationsByUserParams, type ListIncidentsParams, type OiFundingInterval, type OpenInterest, OpenInterestArrayResponseSchema, type OpenInterestHistoryParams, OpenInterestResponseSchema, OpenInterestSchema, type OrderBook, OrderBookArrayResponseSchema, type OrderBookHistoryParams, OrderBookReconstructor, OrderBookResponseSchema, OrderBookSchema, type OrderbookDelta, OxArchive, OxArchiveError, OxArchiveWs, type Pagination, type PriceHistoryParams, type PriceLevel, PriceLevelSchema, type PriceSnapshot, PriceSnapshotArrayResponseSchema, PriceSnapshotSchema, type ReconstructOptions, type ReconstructedOrderBook, type RestApiLatency, type SlaActual, type SlaParams, type SlaResponse, type SlaTargets, type StatusResponse, type SymbolCoverageOptions, type SymbolCoverageResponse, type SymbolDataTypeCoverage, type SystemStatusValue, type TickData, type TickHistoryParams, type Timestamp, type TimestampedRecord, TimestampedRecordSchema, type Trade, TradeArrayResponseSchema, type TradeDirection, TradeDirectionSchema, TradeSchema, type TradeSide, TradeSideSchema, type ValidatedApiMeta, type ValidatedCandle, type ValidatedFundingRate, type ValidatedInstrument, type ValidatedLiquidation, type ValidatedOpenInterest, type ValidatedOrderBook, type ValidatedPriceLevel, type ValidatedTrade, type ValidatedWsServerMessage, type WebSocketLatency, type WsChannel, WsChannelSchema, type WsClientMessage, type WsConnectionState, WsConnectionStateSchema, type WsData, WsDataSchema, type WsError, WsErrorSchema, type WsEventHandlers, type WsGapDetected, type WsHistoricalBatch, WsHistoricalBatchSchema, type WsHistoricalData, WsHistoricalDataSchema, type WsHistoricalTickData, type WsOptions, type WsPing, type WsPong, WsPongSchema, type WsReplay, type WsReplayCompleted, WsReplayCompletedSchema, type WsReplayPause, type WsReplayPaused, WsReplayPausedSchema, type WsReplayResume, type WsReplayResumed, WsReplayResumedSchema, type WsReplaySeek, type WsReplaySnapshot, WsReplaySnapshotSchema, type WsReplayStarted, WsReplayStartedSchema, type WsReplayStop, type WsReplayStopped, WsReplayStoppedSchema, type WsServerMessage, WsServerMessageSchema, type WsStream, type WsStreamCompleted, WsStreamCompletedSchema, type WsStreamProgress, WsStreamProgressSchema, type WsStreamStarted, WsStreamStartedSchema, type WsStreamStop, type WsStreamStopped, WsStreamStoppedSchema, type WsSubscribe, type WsSubscribed, WsSubscribedSchema, type WsUnsubscribe, type WsUnsubscribed, WsUnsubscribedSchema, OxArchive as default, reconstructFinal, reconstructOrderBook };
5246
+ export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type Candle, CandleArrayResponseSchema, type CandleHistoryParams, type CandleInterval, CandleIntervalSchema, CandleSchema, type ClientOptions, type CoinFreshness, CoinFreshnessResponseSchema, CoinFreshnessSchema, type CoinSummary, CoinSummaryResponseSchema, CoinSummarySchema, type CompletenessMetrics, type CoverageGap, type CoverageResponse, type CursorResponse, type DataCadence, type DataFreshness, type DataTypeCoverage, type DataTypeFreshnessInfo, DataTypeFreshnessInfoSchema, type DataTypeStatus, type ExchangeCoverage, type ExchangeLatency, type ExchangeStatus, type FundingHistoryParams, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, Hip3Client, type Hip3Instrument, HyperliquidClient, type Incident, type IncidentSeverityValue, type IncidentStatusValue, type IncidentsResponse, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, type LatencyResponse, LighterClient, type LighterGranularity, type LighterInstrument, type Liquidation, LiquidationArrayResponseSchema, type LiquidationHistoryParams, LiquidationSchema, LiquidationSideSchema, type LiquidationVolume, LiquidationVolumeArrayResponseSchema, type LiquidationVolumeParams, LiquidationVolumeSchema, type LiquidationsByUserParams, type ListIncidentsParams, type OiFundingInterval, type OpenInterest, OpenInterestArrayResponseSchema, type OpenInterestHistoryParams, OpenInterestResponseSchema, OpenInterestSchema, type OrderBook, OrderBookArrayResponseSchema, type OrderBookHistoryParams, OrderBookReconstructor, OrderBookResponseSchema, OrderBookSchema, type OrderbookDelta, OxArchive, OxArchiveError, OxArchiveWs, type Pagination, type PriceHistoryParams, type PriceLevel, PriceLevelSchema, type PriceSnapshot, PriceSnapshotArrayResponseSchema, PriceSnapshotSchema, type ReconstructOptions, type ReconstructedOrderBook, type RestApiLatency, type SiweChallenge, type SlaActual, type SlaParams, type SlaResponse, type SlaTargets, type StatusResponse, type SymbolCoverageOptions, type SymbolCoverageResponse, type SymbolDataTypeCoverage, type SystemStatusValue, type TickData, type TickHistoryParams, type Timestamp, type TimestampedRecord, TimestampedRecordSchema, type Trade, TradeArrayResponseSchema, type TradeDirection, TradeDirectionSchema, TradeSchema, type TradeSide, TradeSideSchema, type ValidatedApiMeta, type ValidatedCandle, type ValidatedFundingRate, type ValidatedInstrument, type ValidatedLiquidation, type ValidatedOpenInterest, type ValidatedOrderBook, type ValidatedPriceLevel, type ValidatedTrade, type ValidatedWsServerMessage, type Web3ApiKey, type Web3KeysList, type Web3PaymentRequired, type Web3RevokeResult, type Web3SignupResult, type Web3SubscribeResult, type WebSocketLatency, type WsChannel, WsChannelSchema, type WsClientMessage, type WsConnectionState, WsConnectionStateSchema, type WsData, WsDataSchema, type WsError, WsErrorSchema, type WsEventHandlers, type WsGapDetected, type WsHistoricalBatch, WsHistoricalBatchSchema, type WsHistoricalData, WsHistoricalDataSchema, type WsHistoricalTickData, type WsOptions, type WsPing, type WsPong, WsPongSchema, type WsReplay, type WsReplayCompleted, WsReplayCompletedSchema, type WsReplayPause, type WsReplayPaused, WsReplayPausedSchema, type WsReplayResume, type WsReplayResumed, WsReplayResumedSchema, type WsReplaySeek, type WsReplaySnapshot, WsReplaySnapshotSchema, type WsReplayStarted, WsReplayStartedSchema, type WsReplayStop, type WsReplayStopped, WsReplayStoppedSchema, type WsServerMessage, WsServerMessageSchema, type WsStream, type WsStreamCompleted, WsStreamCompletedSchema, type WsStreamProgress, WsStreamProgressSchema, type WsStreamStarted, WsStreamStartedSchema, type WsStreamStop, type WsStreamStopped, WsStreamStoppedSchema, type WsSubscribe, type WsSubscribed, WsSubscribedSchema, type WsUnsubscribe, type WsUnsubscribed, WsUnsubscribedSchema, OxArchive as default, reconstructFinal, reconstructOrderBook };