@veridex/sdk 1.0.0-beta.15 → 1.0.0-beta.17

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
@@ -82,7 +82,7 @@ const customSdk = createSDK('base', {
82
82
 
83
83
  ```typescript
84
84
  const sdk = createSDK('base', {
85
- relayerUrl: 'https://relayer.veridex.io',
85
+ relayerUrl: 'https://relayer.veridex.network',
86
86
  relayerApiKey: 'your-api-key',
87
87
  });
88
88
 
@@ -1,5 +1,5 @@
1
1
  import { Aptos } from '@aptos-labs/ts-sdk';
2
- import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature, D as DispatchResult, V as VaultCreationResult } from '../../types-ChIsqCiw.mjs';
2
+ import { f as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, w as WebAuthnSignature, D as DispatchResult, j as VaultCreationResult } from '../../types-DE2ICQik.mjs';
3
3
 
4
4
  /**
5
5
  * Veridex Protocol SDK - Aptos Chain Client
@@ -1,5 +1,5 @@
1
1
  import { Aptos } from '@aptos-labs/ts-sdk';
2
- import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature, D as DispatchResult, V as VaultCreationResult } from '../../types-ChIsqCiw.js';
2
+ import { f as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, w as WebAuthnSignature, D as DispatchResult, j as VaultCreationResult } from '../../types-DE2ICQik.js';
3
3
 
4
4
  /**
5
5
  * Veridex Protocol SDK - Aptos Chain Client
@@ -1,5 +1,5 @@
1
- export { a as EVMClient, b as EVMClientConfig, E as EVMHubClientAdapter } from '../../index-DkrLIDgS.mjs';
1
+ export { E as EVMClient, e as EVMClientConfig, c as EVMHubClientAdapter } from '../../index-CYOyIE3b.mjs';
2
2
  import '../../types.mjs';
3
3
  import 'ethers';
4
- import '../../types-ChIsqCiw.mjs';
5
- import '../../types-FJL7j6gQ.mjs';
4
+ import '../../types-DE2ICQik.mjs';
5
+ import '../../types-DvFRnIBd.mjs';
@@ -1,5 +1,5 @@
1
- export { a as EVMClient, b as EVMClientConfig, E as EVMHubClientAdapter } from '../../index-BJlmzSvm.js';
1
+ export { E as EVMClient, e as EVMClientConfig, c as EVMHubClientAdapter } from '../../index-BXcR_ypI.js';
2
2
  import '../../types.js';
3
3
  import 'ethers';
4
- import '../../types-ChIsqCiw.js';
5
- import '../../types-FJL7j6gQ.js';
4
+ import '../../types-DE2ICQik.js';
5
+ import '../../types-DvFRnIBd.js';
@@ -1,6 +1,6 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
2
  import { Connection, PublicKey } from '@solana/web3.js';
3
- import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature, D as DispatchResult, V as VaultCreationResult } from '../../types-ChIsqCiw.mjs';
3
+ import { f as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, w as WebAuthnSignature, D as DispatchResult, j as VaultCreationResult } from '../../types-DE2ICQik.mjs';
4
4
 
5
5
  interface SolanaClientConfig {
6
6
  wormholeChainId: number;
@@ -1,6 +1,6 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
2
  import { Connection, PublicKey } from '@solana/web3.js';
3
- import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature, D as DispatchResult, V as VaultCreationResult } from '../../types-ChIsqCiw.js';
3
+ import { f as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, w as WebAuthnSignature, D as DispatchResult, j as VaultCreationResult } from '../../types-DE2ICQik.js';
4
4
 
5
5
  interface SolanaClientConfig {
6
6
  wormholeChainId: number;
@@ -0,0 +1,559 @@
1
+ import { a as SessionKey } from '../../types-DvFRnIBd.mjs';
2
+ import { f as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, w as WebAuthnSignature, D as DispatchResult, j as VaultCreationResult, x as RegisterSessionParams, y as RevokeSessionParams, S as SessionValidationResult } from '../../types-DE2ICQik.mjs';
3
+
4
+ /**
5
+ * Veridex Protocol SDK - Stacks Chain Client
6
+ *
7
+ * Production-grade implementation of ChainClient interface for Stacks.
8
+ * Supports direct relay with native sponsored transactions.
9
+ *
10
+ * Security:
11
+ * - Native secp256r1-verify for Passkey (P-256) validation
12
+ * - Native secp256k1-verify for session key validation
13
+ * - Protocol-level Post-Conditions for spending safety
14
+ * - Nonce-based replay protection
15
+ * - Block-height based session expiry
16
+ *
17
+ * Architecture:
18
+ * - Phase 1: Direct relay (relayer sponsors Stacks transactions)
19
+ * - Phase 2: Wormhole cross-chain messaging (VAA + CCQ)
20
+ * - Vaults are map-based (Clarity doesn't support factory patterns)
21
+ * - All identities stored in veridex-spoke.clar
22
+ * - STX/sBTC custody in veridex-vault.clar (direct) + veridex-vault-vaa.clar (cross-chain)
23
+ * - Guardian signature verification in veridex-wormhole-verifier.clar
24
+ */
25
+
26
+ /** Stacks action types matching veridex-spoke.clar constants */
27
+ declare const STACKS_ACTION_TYPES: {
28
+ readonly TRANSFER_STX: 1;
29
+ readonly TRANSFER_SBTC: 2;
30
+ readonly CONTRACT_CALL: 3;
31
+ };
32
+ interface StacksClientConfig {
33
+ /** Wormhole chain ID (60 for Stacks) */
34
+ wormholeChainId: number;
35
+ /** Stacks RPC URL (Hiro API) */
36
+ rpcUrl: string;
37
+ /** Spoke contract principal (e.g., "ST1PQHQKV...veridex-spoke") */
38
+ spokeContractAddress?: string;
39
+ /** Vault contract principal (e.g., "ST1PQHQKV...veridex-vault") */
40
+ vaultContractAddress?: string;
41
+ /** Wormhole verifier contract principal (Phase 2) */
42
+ wormholeVerifierAddress?: string;
43
+ /** VAA-authorized vault contract principal (Phase 2) */
44
+ vaultVaaContractAddress?: string;
45
+ /** Network type */
46
+ network?: 'mainnet' | 'testnet';
47
+ /** Hub RPC URL for cross-chain session management */
48
+ hubRpcUrl?: string;
49
+ /** Hub contract address for cross-chain session management */
50
+ hubContractAddress?: string;
51
+ }
52
+ declare class StacksClient implements ChainClient {
53
+ private config;
54
+ private rpcUrl;
55
+ private spokeContract;
56
+ private vaultContract;
57
+ private wormholeVerifierContract;
58
+ private vaultVaaContract;
59
+ private networkType;
60
+ constructor(clientConfig: StacksClientConfig);
61
+ getConfig(): ChainConfig;
62
+ /**
63
+ * Get the current nonce for a user identity from the spoke contract.
64
+ * Calls the read-only function `get-nonce` on veridex-spoke.
65
+ */
66
+ getNonce(userKeyHash: string): Promise<bigint>;
67
+ /**
68
+ * Get the Wormhole message fee.
69
+ * Phase 1: No Wormhole integration, returns 0.
70
+ */
71
+ getMessageFee(): Promise<bigint>;
72
+ buildTransferPayload(params: TransferParams): Promise<string>;
73
+ buildExecutePayload(params: ExecuteParams): Promise<string>;
74
+ buildBridgePayload(params: BridgeParams): Promise<string>;
75
+ /**
76
+ * Direct dispatch is not supported on Stacks in Phase 1.
77
+ * Stacks actions are executed via sponsored transactions through the relayer.
78
+ */
79
+ dispatch(_signature: WebAuthnSignature, _publicKeyX: bigint, _publicKeyY: bigint, _targetChain: number, _actionPayload: string, _nonce: bigint, _signer: unknown): Promise<DispatchResult>;
80
+ /**
81
+ * Dispatch an action via the relayer (gasless/sponsored).
82
+ *
83
+ * Flow:
84
+ * 1. User signs action with Passkey (on client)
85
+ * 2. SDK submits to relayer with targetChain=60 (Stacks)
86
+ * 3. Relayer builds Clarity contract-call transaction
87
+ * 4. Relayer sponsors the transaction (pays STX gas)
88
+ * 5. Relayer broadcasts to Stacks network
89
+ * 6. Transaction confirmed on Stacks
90
+ */
91
+ dispatchGasless(signature: WebAuthnSignature, publicKeyX: bigint, publicKeyY: bigint, targetChain: number, actionPayload: string, nonce: bigint, relayerUrl: string): Promise<DispatchResult>;
92
+ /**
93
+ * Get vault address for a user.
94
+ * On Stacks, vaults are map-based within the vault contract.
95
+ * The "vault address" is the vault contract principal itself.
96
+ */
97
+ getVaultAddress(userKeyHash: string): Promise<string | null>;
98
+ /**
99
+ * Compute vault address deterministically.
100
+ * On Stacks, all vaults live in the same contract (map-based).
101
+ */
102
+ computeVaultAddress(_userKeyHash: string): string;
103
+ /**
104
+ * Check if a vault (identity) exists for a user.
105
+ * Queries the spoke contract's `identity-exists` read-only function.
106
+ */
107
+ vaultExists(userKeyHash: string): Promise<boolean>;
108
+ /**
109
+ * Create a vault (register identity) on Stacks.
110
+ * Must be done via Hub dispatch or relayer in Phase 1.
111
+ */
112
+ createVault(userKeyHash: string, _signer: unknown): Promise<VaultCreationResult>;
113
+ /**
114
+ * Create a vault with a sponsor wallet.
115
+ * On Stacks, this registers an identity via sponsored transaction.
116
+ */
117
+ createVaultSponsored?(userKeyHash: string, _sponsorPrivateKey: string, _rpcUrl?: string): Promise<VaultCreationResult>;
118
+ /**
119
+ * Create a vault via the relayer (sponsored/gasless).
120
+ * The relayer will sponsor the register-identity transaction.
121
+ */
122
+ createVaultViaRelayer(userKeyHash: string, relayerUrl: string): Promise<VaultCreationResult>;
123
+ estimateVaultCreationGas(_userKeyHash: string): Promise<bigint>;
124
+ getFactoryAddress(): string | undefined;
125
+ getImplementationAddress(): string | undefined;
126
+ /**
127
+ * Get native STX balance for an address.
128
+ */
129
+ getNativeBalance(address: string): Promise<bigint>;
130
+ /**
131
+ * Get vault STX balance for an identity.
132
+ * Queries the vault contract's `get-stx-balance` read-only function.
133
+ */
134
+ getVaultStxBalance(keyHash: string): Promise<bigint>;
135
+ /**
136
+ * Get vault sBTC balance for an identity.
137
+ */
138
+ getVaultSbtcBalance(keyHash: string): Promise<bigint>;
139
+ /**
140
+ * Get identity info from the spoke contract.
141
+ */
142
+ getIdentity(keyHash: string): Promise<{
143
+ compressedPubkey: string;
144
+ owner: string;
145
+ nonce: bigint;
146
+ createdAt: bigint;
147
+ } | null>;
148
+ /**
149
+ * Get session info from the spoke contract.
150
+ */
151
+ getSession(keyHash: string, sessionHash: string): Promise<{
152
+ sessionPubkey: string;
153
+ expiry: bigint;
154
+ maxValue: bigint;
155
+ spent: bigint;
156
+ revoked: boolean;
157
+ createdAt: bigint;
158
+ } | null>;
159
+ /**
160
+ * Check if a session is currently active.
161
+ */
162
+ checkSessionActive(keyHash: string, sessionHash: string): Promise<boolean>;
163
+ /**
164
+ * Get remaining spending budget for a session.
165
+ */
166
+ getRemainingBudget(keyHash: string, sessionHash: string): Promise<bigint>;
167
+ /**
168
+ * Check if the spoke contract is paused.
169
+ */
170
+ isProtocolPaused(): Promise<boolean>;
171
+ /**
172
+ * Get global identity count.
173
+ */
174
+ getIdentityCount(): Promise<bigint>;
175
+ /**
176
+ * Get total STX deposited across all vaults.
177
+ */
178
+ getTotalStxDeposited(): Promise<bigint>;
179
+ /**
180
+ * Register a session key on the Stacks spoke.
181
+ * On Stacks, sessions are managed directly on the spoke contract
182
+ * (unlike EVM spokes where sessions are on the Hub).
183
+ */
184
+ registerSession(_params: RegisterSessionParams): Promise<void>;
185
+ /**
186
+ * Revoke a session key on the Stacks spoke.
187
+ */
188
+ revokeSession(_params: RevokeSessionParams): Promise<void>;
189
+ /**
190
+ * Check if a session is active.
191
+ */
192
+ isSessionActive(userKeyHash: string, sessionKeyHash: string): Promise<SessionValidationResult>;
193
+ /**
194
+ * Get all sessions for a user.
195
+ * Note: Clarity maps don't support enumeration, so this requires
196
+ * off-chain indexing or event log parsing.
197
+ */
198
+ getUserSessions(_userKeyHash: string): Promise<SessionKey[]>;
199
+ /**
200
+ * Get the status of a Stacks transaction.
201
+ */
202
+ getTransactionStatus(txId: string): Promise<{
203
+ status: 'pending' | 'success' | 'failed' | 'not_found';
204
+ blockHeight?: number;
205
+ error?: string;
206
+ }>;
207
+ /**
208
+ * Wait for a transaction to be confirmed.
209
+ *
210
+ * @param txId - Transaction ID
211
+ * @param maxAttempts - Maximum polling attempts (default: 60)
212
+ * @param pollIntervalMs - Polling interval in milliseconds (default: 5000)
213
+ */
214
+ waitForConfirmation(txId: string, maxAttempts?: number, pollIntervalMs?: number): Promise<{
215
+ confirmed: boolean;
216
+ blockHeight?: number;
217
+ }>;
218
+ /**
219
+ * Get Stacks network info (block height, network version, etc.).
220
+ */
221
+ getNetworkInfo(): Promise<{
222
+ networkId: number;
223
+ stacksBlockHeight: number;
224
+ burnBlockHeight: number;
225
+ serverVersion: string;
226
+ }>;
227
+ /**
228
+ * Get the current Stacks block height.
229
+ * Used for session expiry calculations.
230
+ */
231
+ getCurrentBlockHeight(): Promise<number>;
232
+ /**
233
+ * Call a read-only Clarity function via the Hiro API.
234
+ * Uses the /v2/contracts/call-read endpoint.
235
+ */
236
+ private callReadOnly;
237
+ /**
238
+ * Parse a hex-encoded Clarity value from the API response.
239
+ * This is a simplified parser for common Clarity types.
240
+ */
241
+ private parseClarityValue;
242
+ }
243
+
244
+ /**
245
+ * Veridex Protocol SDK - Stacks Signature Format Conversion
246
+ *
247
+ * Converts WebAuthn/Passkey signatures to Clarity-compatible formats.
248
+ *
249
+ * Key conversions:
250
+ * - WebAuthn DER-encoded signature → 64-byte compact (buff 64) for secp256r1-verify
251
+ * - Uncompressed pubkey (x, y) → 33-byte compressed (buff 33)
252
+ * - Session key signing via secp256k1 → 65-byte recoverable (buff 65)
253
+ */
254
+ /**
255
+ * Compress a P-256 public key from (x, y) coordinates to 33-byte compressed format.
256
+ * The prefix byte is 0x02 if y is even, 0x03 if y is odd.
257
+ *
258
+ * @param x - P-256 public key X coordinate
259
+ * @param y - P-256 public key Y coordinate
260
+ * @returns 33-byte compressed public key
261
+ */
262
+ declare function compressPublicKey(x: bigint, y: bigint): Uint8Array;
263
+ /**
264
+ * Convert (r, s) bigint pair to 64-byte compact signature for secp256r1-verify.
265
+ * Applies low-S normalization (required by Clarity's secp256r1-verify).
266
+ *
267
+ * @param r - Signature r component
268
+ * @param s - Signature s component
269
+ * @returns 64-byte compact signature buffer
270
+ */
271
+ declare function rsToCompactSignature(r: bigint, s: bigint): Uint8Array;
272
+ /**
273
+ * Parse a DER-encoded ECDSA signature into (r, s) components.
274
+ * WebAuthn signatures are typically DER-encoded.
275
+ *
276
+ * DER format: 0x30 [total-len] 0x02 [r-len] [r] 0x02 [s-len] [s]
277
+ *
278
+ * @param der - DER-encoded signature bytes
279
+ * @returns Object with r and s as bigints
280
+ */
281
+ declare function parseDERSignature(der: Uint8Array): {
282
+ r: bigint;
283
+ s: bigint;
284
+ };
285
+ /**
286
+ * Convert a DER-encoded signature to 64-byte compact format.
287
+ * Combines DER parsing with compact encoding and low-S normalization.
288
+ *
289
+ * @param der - DER-encoded signature bytes
290
+ * @returns 64-byte compact signature buffer
291
+ */
292
+ declare function derToCompactSignature(der: Uint8Array): Uint8Array;
293
+ /**
294
+ * Compute the key hash (SHA-256 of compressed public key).
295
+ * This matches the Clarity contract's `(sha256 compressed-pubkey)`.
296
+ *
297
+ * @param compressedPubkey - 33-byte compressed public key
298
+ * @returns 32-byte key hash as hex string (with 0x prefix)
299
+ */
300
+ declare function computeKeyHash(compressedPubkey: Uint8Array): Promise<string>;
301
+ /**
302
+ * Compute the key hash from (x, y) public key coordinates.
303
+ * Compresses the key first, then SHA-256 hashes it.
304
+ *
305
+ * @param x - P-256 public key X coordinate
306
+ * @param y - P-256 public key Y coordinate
307
+ * @returns 32-byte key hash as hex string (with 0x prefix)
308
+ */
309
+ declare function computeKeyHashFromCoords(x: bigint, y: bigint): Promise<string>;
310
+ /**
311
+ * Build a registration message hash.
312
+ * Format: SHA-256("veridex:register:<nonce>")
313
+ *
314
+ * @param nonce - Registration nonce (typically 0 for first registration)
315
+ * @returns 32-byte message hash
316
+ */
317
+ declare function buildRegistrationHash(nonce: number): Promise<Uint8Array>;
318
+ /**
319
+ * Build a session registration message hash.
320
+ * Format: SHA-256("veridex:session:<session-key-hash>:<duration>:<max-value>:<nonce>")
321
+ *
322
+ * @param sessionKeyHash - Hex string of session key hash
323
+ * @param duration - Session duration in blocks
324
+ * @param maxValue - Maximum spending value in microSTX
325
+ * @param nonce - Identity nonce
326
+ * @returns 32-byte message hash
327
+ */
328
+ declare function buildSessionRegistrationHash(sessionKeyHash: string, duration: number, maxValue: bigint, nonce: number): Promise<Uint8Array>;
329
+ /**
330
+ * Build a session revocation message hash.
331
+ * Format: SHA-256("veridex:revoke:<session-hash>:<nonce>")
332
+ *
333
+ * @param sessionHash - Hex string of session hash to revoke
334
+ * @param nonce - Identity nonce
335
+ * @returns 32-byte message hash
336
+ */
337
+ declare function buildRevocationHash(sessionHash: string, nonce: number): Promise<Uint8Array>;
338
+ /**
339
+ * Build an execute action message hash.
340
+ * Format: SHA-256("veridex:execute:<action-type>:<amount>:<recipient>:<nonce>")
341
+ *
342
+ * @param actionType - Action type (1=STX transfer, 2=sBTC transfer)
343
+ * @param amount - Amount in base units
344
+ * @param recipient - Stacks principal address
345
+ * @param nonce - Identity nonce
346
+ * @returns 32-byte message hash
347
+ */
348
+ declare function buildExecuteHash(actionType: number, amount: bigint, recipient: string, nonce: number): Promise<Uint8Array>;
349
+ /**
350
+ * Build a withdrawal message hash.
351
+ * Format: SHA-256("veridex:withdraw:<amount>:<recipient>:<nonce>")
352
+ *
353
+ * @param amount - Amount in microSTX
354
+ * @param recipient - Stacks principal address
355
+ * @param nonce - Identity nonce (from spoke contract, not used for passkey withdrawals but kept for consistency)
356
+ * @returns 32-byte message hash
357
+ */
358
+ declare function buildWithdrawalHash(amount: bigint, recipient: string, nonce: number): Promise<Uint8Array>;
359
+ /**
360
+ * Convert a byte array to a hex string (no prefix).
361
+ */
362
+ declare function bytesToHex(bytes: Uint8Array): string;
363
+ /**
364
+ * Convert a hex string to a byte array.
365
+ */
366
+ declare function hexToBytes(hex: string): Uint8Array;
367
+
368
+ /**
369
+ * Veridex Protocol SDK - Stacks Address Utilities
370
+ *
371
+ * Validates and manipulates Stacks principal addresses.
372
+ * Stacks uses c32check encoding for addresses.
373
+ *
374
+ * Address formats:
375
+ * - Standard principal: SP/ST + 33 chars (mainnet/testnet)
376
+ * - Contract principal: SP/ST + 33 chars + "." + contract-name
377
+ */
378
+ /** Stacks mainnet address prefix */
379
+ declare const STACKS_MAINNET_PREFIX = "SP";
380
+ /** Stacks testnet address prefix */
381
+ declare const STACKS_TESTNET_PREFIX = "ST";
382
+ /**
383
+ * Validate a Stacks principal address (standard or contract).
384
+ *
385
+ * @param address - Address to validate
386
+ * @returns true if the address is a valid Stacks principal
387
+ */
388
+ declare function isValidStacksPrincipal(address: string): boolean;
389
+ /**
390
+ * Validate a standard Stacks principal (not contract).
391
+ *
392
+ * @param address - Standard principal address
393
+ * @returns true if valid
394
+ */
395
+ declare function isValidStandardPrincipal(address: string): boolean;
396
+ /**
397
+ * Validate a Clarity contract name.
398
+ * Contract names must be 1-128 chars, alphanumeric + hyphens, starting with alpha.
399
+ *
400
+ * @param name - Contract name to validate
401
+ * @returns true if valid
402
+ */
403
+ declare function isValidContractName(name: string): boolean;
404
+ /**
405
+ * Get the network type from a Stacks address.
406
+ *
407
+ * @param address - Stacks principal address
408
+ * @returns 'mainnet' or 'testnet'
409
+ */
410
+ declare function getNetworkFromAddress(address: string): 'mainnet' | 'testnet';
411
+ /**
412
+ * Build a contract principal from deployer address and contract name.
413
+ *
414
+ * @param deployerAddress - Standard principal of the deployer
415
+ * @param contractName - Name of the contract
416
+ * @returns Contract principal in "address.contract-name" format
417
+ */
418
+ declare function getContractPrincipal(deployerAddress: string, contractName: string): string;
419
+ /**
420
+ * Parse a contract principal into deployer address and contract name.
421
+ *
422
+ * @param contractPrincipal - Full contract principal (e.g., "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.veridex-spoke")
423
+ * @returns Object with address and contractName
424
+ */
425
+ declare function parseContractPrincipal(contractPrincipal: string): {
426
+ address: string;
427
+ contractName: string;
428
+ };
429
+ /**
430
+ * Check if an address is a contract principal.
431
+ *
432
+ * @param address - Address to check
433
+ * @returns true if the address contains a contract name
434
+ */
435
+ declare function isContractPrincipal(address: string): boolean;
436
+ /**
437
+ * Get the explorer URL for a Stacks transaction.
438
+ *
439
+ * @param txId - Transaction ID (hex string)
440
+ * @param network - 'mainnet' or 'testnet'
441
+ * @returns Full explorer URL
442
+ */
443
+ declare function getStacksExplorerTxUrl(txId: string, network?: 'mainnet' | 'testnet'): string;
444
+ /**
445
+ * Get the explorer URL for a Stacks address.
446
+ *
447
+ * @param address - Stacks principal address
448
+ * @param network - 'mainnet' or 'testnet'
449
+ * @returns Full explorer URL
450
+ */
451
+ declare function getStacksExplorerAddressUrl(address: string, network?: 'mainnet' | 'testnet'): string;
452
+
453
+ /**
454
+ * Veridex Protocol SDK - Stacks Post-Condition Builder
455
+ *
456
+ * Stacks Post-Conditions are a unique protocol-level safety feature.
457
+ * They enforce spending constraints at the blockchain level, independent
458
+ * of smart contract logic. This provides a third layer of protection:
459
+ *
460
+ * 1. SDK-level spending limits (off-chain, first check)
461
+ * 2. Contract-level spending limits (on-chain, enforced in veridex-spoke sessions)
462
+ * 3. Protocol-level Post-Conditions (Stacks-native, attached by SDK at tx broadcast)
463
+ *
464
+ * Post-conditions are attached to transactions before broadcast and are
465
+ * validated by the Stacks node itself — they cannot be bypassed by contracts.
466
+ */
467
+ /** Post-condition comparison type */
468
+ type PostConditionComparison = 'eq' | 'gte' | 'lte' | 'gt' | 'lt';
469
+ /** STX post-condition */
470
+ interface StxPostCondition {
471
+ type: 'stx';
472
+ principal: string;
473
+ comparison: PostConditionComparison;
474
+ amount: bigint;
475
+ }
476
+ /** Fungible token post-condition */
477
+ interface FtPostCondition {
478
+ type: 'ft';
479
+ principal: string;
480
+ comparison: PostConditionComparison;
481
+ amount: bigint;
482
+ contractAddress: string;
483
+ contractName: string;
484
+ tokenName: string;
485
+ }
486
+ /** Non-fungible token post-condition */
487
+ interface NftPostCondition {
488
+ type: 'nft';
489
+ principal: string;
490
+ contractAddress: string;
491
+ contractName: string;
492
+ tokenName: string;
493
+ assetId: string;
494
+ owns: boolean;
495
+ }
496
+ type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition;
497
+ /**
498
+ * Build STX transfer post-conditions for vault withdrawals.
499
+ * Ensures the contract sends exactly the specified amount.
500
+ *
501
+ * @param contractPrincipal - The vault contract principal (e.g., "ST1PQHQKV...veridex-vault")
502
+ * @param amount - Exact amount in microSTX
503
+ * @returns Array of post-conditions to attach to the transaction
504
+ */
505
+ declare function buildStxWithdrawalPostConditions(contractPrincipal: string, amount: bigint): StxPostCondition[];
506
+ /**
507
+ * Build STX deposit post-conditions.
508
+ * Ensures the sender sends exactly the specified amount to the vault.
509
+ *
510
+ * @param senderPrincipal - The depositor's principal address
511
+ * @param amount - Exact amount in microSTX
512
+ * @returns Array of post-conditions
513
+ */
514
+ declare function buildStxDepositPostConditions(senderPrincipal: string, amount: bigint): StxPostCondition[];
515
+ /**
516
+ * Build sBTC transfer post-conditions for vault withdrawals.
517
+ *
518
+ * @param contractPrincipal - The vault contract principal
519
+ * @param amount - Exact amount in satoshis
520
+ * @param sbtcContractAddress - sBTC token contract deployer address
521
+ * @param sbtcContractName - sBTC token contract name (default: 'sbtc-token')
522
+ * @returns Array of post-conditions
523
+ */
524
+ declare function buildSbtcWithdrawalPostConditions(contractPrincipal: string, amount: bigint, sbtcContractAddress?: string, sbtcContractName?: string): FtPostCondition[];
525
+ /**
526
+ * Build post-conditions for a session-authorized execute action.
527
+ * Combines STX or sBTC post-conditions based on action type.
528
+ *
529
+ * @param actionType - 1 = STX transfer, 2 = sBTC transfer
530
+ * @param contractPrincipal - The spoke/vault contract principal
531
+ * @param amount - Amount in base units
532
+ * @returns Array of post-conditions
533
+ */
534
+ declare function buildExecutePostConditions(actionType: number, contractPrincipal: string, amount: bigint): PostCondition[];
535
+ /**
536
+ * Validate that a set of post-conditions is present and reasonable.
537
+ * Used to reject transactions that lack post-conditions for asset transfers.
538
+ *
539
+ * @param postConditions - Array of post-conditions to validate
540
+ * @param expectedAmount - Expected transfer amount
541
+ * @returns Validation result with error message if invalid
542
+ */
543
+ declare function validatePostConditions(postConditions: PostCondition[], expectedAmount: bigint): {
544
+ valid: boolean;
545
+ error?: string;
546
+ };
547
+ /**
548
+ * Get the contract address and name from a principal for post-condition construction.
549
+ * Handles both standard and contract principals.
550
+ *
551
+ * @param principal - Stacks principal (standard or contract)
552
+ * @returns Object with address and optional contractName
553
+ */
554
+ declare function principalForPostCondition(principal: string): {
555
+ address: string;
556
+ contractName?: string;
557
+ };
558
+
559
+ export { type FtPostCondition, type NftPostCondition, type PostCondition, type PostConditionComparison, STACKS_ACTION_TYPES, STACKS_MAINNET_PREFIX, STACKS_TESTNET_PREFIX, StacksClient, type StacksClientConfig, type StxPostCondition, buildExecuteHash, buildExecutePostConditions, buildRegistrationHash, buildRevocationHash, buildSbtcWithdrawalPostConditions, buildSessionRegistrationHash, buildStxDepositPostConditions, buildStxWithdrawalPostConditions, buildWithdrawalHash, bytesToHex, compressPublicKey, computeKeyHash, computeKeyHashFromCoords, derToCompactSignature, getContractPrincipal, getNetworkFromAddress, getStacksExplorerAddressUrl, getStacksExplorerTxUrl, hexToBytes, isContractPrincipal, isValidContractName, isValidStacksPrincipal, isValidStandardPrincipal, parseContractPrincipal, parseDERSignature, principalForPostCondition, rsToCompactSignature, validatePostConditions };