Types & Interfaces
This document provides comprehensive TypeScript type definitions for the VerifiedX Web SDK.
VFX Types
Section titled “VFX Types”Core Types
Section titled “Core Types”// Network enumerationenum Network { Mainnet = 'mainnet', Testnet = 'testnet'}
// Transaction type enumerationenum TxType { Transfer = 'transfer', Adnr = 'adnr'}Keypair Interface
Section titled “Keypair Interface”interface Keypair { private: string; // Private key in hexadecimal format public: string; // Public key in hexadecimal format address: string; // VFX address}Signer Interface
Section titled “Signer Interface”An external signing authority (HSM, MPC service, hardware wallet). Accepted
everywhere a Keypair is.
interface Signer { address: string; // VFX address the signature is verified against publicKey: string; // uncompressed secp256k1 public key, hex, 04 prefix optional // Sign the 32-byte SHA-256 digest (hex). Return DER as bytes, hex, or base64. signDigest(digestHex: string): Promise<Uint8Array | string> | Uint8Array | string;}
type KeypairOrSigner = Keypair | Signer;Reserve (Vault) Account Types
Section titled “Reserve (Vault) Account Types”interface ReserveKeypair extends Keypair { // address is the xRBX form; privateKey/publicKey are the vault's own key recoveryPrivateKey: string; recoveryPublicKey: string; recoveryAddress: string; // ordinary address that can sweep the vault restoreCode: string; // base64("<privateKey>//<recoveryPrivateKey>"), CLI/wallet compatible}
interface ReserveSendOptions { unlockHours?: number; // delay for a send from a vault; default 24, the network minimum}Fungible Token Types
Section titled “Fungible Token Types”interface FungibleToken { sc_identifier: string; name: string; ticker: string; description: string | null; owner_address: string; can_mint: boolean; can_burn: boolean; can_vote: boolean; created_at: string; initial_supply: number; circulating_supply: number; decimal_places: number; image_url: string | null; is_paused: boolean; banned_addresses: string[]; nsfw: boolean;}
interface FungibleTokenDetail { token: FungibleToken; holders: Record<string, number>; // address → balance}
interface FungibleTokenBalance { token: FungibleToken; balance: number;}
interface TokenImage { url: string; // publicly fetchable; becomes the contract's primary asset name?: string; // defaults to the last path segment of url extension?: string; // defaults to the extension of name fileSize?: number; thumbnailBase64?: string; // small inline image wallets display}
interface DeployTokenParams { name: string; ticker: string; // ≤ 20 chars, stored upper-case description?: string; // defaults to name decimalPlaces?: number; // 1–18, default 8 initialSupply?: number; // whole tokens; must be 0 when mintable mintable?: boolean; burnable?: boolean; voting?: boolean; image?: TokenImage;}
interface DeployTokenResult { transactionHash: string; scIdentifier: string;}
interface TokenVotingTopic { sc_identifier: string; token: FungibleToken; from_address: string; topic_id: string; name: string; description: string; vote_requirement: number; created_at: string; voting_ends_at: string; vote_data: unknown;}VFX Address Information
Section titled “VFX Address Information”interface VfxAddress { address: string; // The VFX address balance: number; // Balance in VFX tokens txCount: number; // Number of transactions adnr?: string; // Associated domain name (if any)}Transaction Interface
Section titled “Transaction Interface”interface Transaction { hash: string; // Transaction hash from: string; // Sender address to: string; // Recipient address amount: number; // Amount transferred fee: number; // Transaction fee timestamp: number; // Unix timestamp blockHeight?: number; // Block height (if confirmed) status: 'pending' | 'confirmed' | 'failed'; // Transaction status}Paginated Response
Section titled “Paginated Response”interface PaginatedResponse<T> { data: T[]; // Array of items total: number; // Total number of items page: number; // Current page number limit: number; // Items per page hasNext: boolean; // Whether there are more pages hasPrev: boolean; // Whether there are previous pages}Bitcoin Types
Section titled “Bitcoin Types”Bitcoin Keypair Types
Section titled “Bitcoin Keypair Types”// Basic Bitcoin keypairinterface BtcKeypair { privateKey: string; // Private key in hexadecimal format publicKey: string; // Public key in hexadecimal format wif: string; // Wallet Import Format address: string; // Default address (bech32) addresses: { p2pkh: string; // Legacy address (starts with 1/m) p2sh: string; // Nested SegWit (starts with 3/2) bech32: string; // Native SegWit (starts with bc1/tb1) bech32m: string; // Taproot (starts with bc1p/tb1p) };}
// Bitcoin keypair with mnemonicinterface BtcMnemonicKeypair extends BtcKeypair { mnemonic: string; // BIP39 mnemonic phrase}Bitcoin Address Information
Section titled “Bitcoin Address Information”interface BtcAddressInfo { address: string; // Bitcoin address balance: number; // Balance in satoshis totalRecieved: number; // Total received in satoshis totalSent: number; // Total sent in satoshis txCount: number; // Number of transactions}Bitcoin Transaction Types
Section titled “Bitcoin Transaction Types”// Transaction inputinterface BtcTransactionInput { txid: string; // Previous transaction ID vout: number; // Output index prevout?: { scriptpubkey: string; scriptpubkey_asm: string; scriptpubkey_type: string; scriptpubkey_address: string; value: number; }; scriptsig: string; scriptsig_asm: string; witness: string[]; is_coinbase: boolean; sequence: number;}
// Transaction outputinterface BtcTransactionOutput { scriptpubkey: string; scriptpubkey_asm: string; scriptpubkey_type: string; scriptpubkey_address: string; value: number; // Value in satoshis}
// Transaction statusinterface BtcTransactionStatus { confirmed: boolean; block_height?: number; block_hash?: string; block_time?: number;}
// Complete Bitcoin transactioninterface BtcTransaction { txid: string; // Transaction ID version: number; // Transaction version locktime: number; // Lock time vin: BtcTransactionInput[]; // Transaction inputs vout: BtcTransactionOutput[]; // Transaction outputs size: number; // Transaction size in bytes weight: number; // Transaction weight fee: number; // Transaction fee in satoshis status: BtcTransactionStatus; // Transaction status}Bitcoin Fee Rates
Section titled “Bitcoin Fee Rates”interface BtcFeeRates { fastestFee: number; // Fastest confirmation fee (sat/vB) halfHourFee: number; // ~30 minute confirmation fee (sat/vB) hourFee: number; // ~1 hour confirmation fee (sat/vB) economyFee: number; // Economy fee rate (sat/vB) minimumFee: number; // Minimum fee rate (sat/vB)}Transaction Result Types
Section titled “Transaction Result Types”// Generic transaction resultinterface TransactionResult { success: boolean; result?: string; // Transaction ID or raw transaction error?: string; // Error message if failed}
// Bitcoin transaction creation resultinterface BtcTransactionCreateResult extends TransactionResult { result?: string; // Raw transaction hex}
// Bitcoin transaction broadcast resultinterface BtcTransactionBroadcastResult extends TransactionResult { result?: string; // Transaction ID}Utility Types
Section titled “Utility Types”Network Types
Section titled “Network Types”// Supported networkstype NetworkType = 'mainnet' | 'testnet';
// VFX Network enumeration valuestype VfxNetworkType = Network.Mainnet | Network.Testnet;Address Types
Section titled “Address Types”// VFX address (starts with 'VFX')type VfxAddressString = string;
// Bitcoin address typestype BitcoinLegacyAddress = string; // P2PKH (1... or m/n...)type BitcoinSegWitAddress = string; // P2SH (3... or 2...)type BitcoinBech32Address = string; // Native SegWit (bc1... or tb1...)type BitcoinTaprootAddress = string; // Taproot (bc1p... or tb1p...)
type BitcoinAddress = | BitcoinLegacyAddress | BitcoinSegWitAddress | BitcoinBech32Address | BitcoinTaprootAddress;Key Types
Section titled “Key Types”// Private key in hexadecimal formattype PrivateKey = string;
// Public key in hexadecimal formattype PublicKey = string;
// Wallet Import Formattype WIF = string;
// BIP39 mnemonic phrasetype Mnemonic = string;Amount Types
Section titled “Amount Types”// VFX amount (integer)type VfxAmount = number;
// Bitcoin amount in satoshistype SatoshiAmount = number;
// Bitcoin amount in BTCtype BtcAmount = number;
// Fee rate in satoshis per virtual bytetype FeeRate = number;Error Types
Section titled “Error Types”Base Error Types
Section titled “Base Error Types”// Generic SDK errorinterface SdkError extends Error { code?: string; details?: any;}
// Network-related errorsinterface NetworkError extends SdkError { code: 'NETWORK_ERROR'; statusCode?: number;}
// Validation errorsinterface ValidationError extends SdkError { code: 'VALIDATION_ERROR'; field?: string;}
// Transaction errorsinterface TransactionError extends SdkError { code: 'TRANSACTION_ERROR'; txHash?: string;}Specific Error Types
Section titled “Specific Error Types”// Insufficient balance errorinterface InsufficientBalanceError extends TransactionError { code: 'INSUFFICIENT_BALANCE'; required: number; available: number;}
// Invalid address errorinterface InvalidAddressError extends ValidationError { code: 'INVALID_ADDRESS'; address: string;}
// Domain errorsinterface DomainError extends SdkError { code: 'DOMAIN_ERROR'; domain: string;}
interface DomainNotAvailableError extends DomainError { code: 'DOMAIN_NOT_AVAILABLE';}
interface DomainNotFoundError extends DomainError { code: 'DOMAIN_NOT_FOUND';}Constants and Enums
Section titled “Constants and Enums”Bitcoin Constants
Section titled “Bitcoin Constants”// Conversion constantsconst BTC_TO_SATOSHI_MULTIPLIER = 100000000;const SATOSHI_TO_BTC_MULTIPLIER = 0.00000001;
// Address type identifiersenum BitcoinAddressType { P2PKH = 'p2pkh', // Legacy P2SH = 'p2sh', // Nested SegWit BECH32 = 'bech32', // Native SegWit BECH32M = 'bech32m' // Taproot}Transaction Types
Section titled “Transaction Types”// VFX transaction typesenum VfxTransactionType { TRANSFER = 'transfer', DOMAIN = 'adnr'}
// Bitcoin transaction typesenum BtcTransactionType { P2PKH = 'p2pkh', P2SH = 'p2sh', P2WPKH = 'v0_p2wpkh', P2WSH = 'v0_p2wsh', P2TR = 'v1_p2tr'}Advanced Types
Section titled “Advanced Types”Generic Response Types
Section titled “Generic Response Types”// API response wrapperinterface ApiResponse<T> { success: boolean; data?: T; error?: string; timestamp: number;}
// Async operation resulttype AsyncResult<T> = Promise<T>;
// Optional result (may be null)type OptionalResult<T> = T | null;Configuration Types
Section titled “Configuration Types”// Client configurationinterface ClientConfig { network: NetworkType; timeout?: number; retries?: number; apiKey?: string;}
// VFX client configurationinterface VfxClientConfig extends ClientConfig { dryRun?: boolean;}
// Bitcoin client configurationinterface BtcClientConfig extends ClientConfig { feeRate?: number; rbf?: boolean; // Replace-by-fee}Event Types
Section titled “Event Types”// Transaction eventinterface TransactionEvent { type: 'transaction'; txHash: string; status: 'pending' | 'confirmed' | 'failed'; timestamp: number;}
// Balance change eventinterface BalanceChangeEvent { type: 'balance_change'; address: string; oldBalance: number; newBalance: number; timestamp: number;}
// Domain eventinterface DomainEvent { type: 'domain'; action: 'purchased' | 'transferred'; domain: string; address: string; timestamp: number;}
type SdkEvent = TransactionEvent | BalanceChangeEvent | DomainEvent;Type Guards
Section titled “Type Guards”Utility type guards for runtime type checking
Section titled “Utility type guards for runtime type checking”// Check if value is a valid VFX addressfunction isVfxAddress(value: any): value is VfxAddressString { return typeof value === 'string' && value.startsWith('VFX');}
// Check if value is a valid Bitcoin addressfunction isBitcoinAddress(value: any): value is BitcoinAddress { if (typeof value !== 'string') return false;
// Simplified check - in practice, use proper validation return /^[13bc1tb1]/.test(value);}
// Check if object is a valid keypairfunction isKeypair(value: any): value is Keypair { return ( typeof value === 'object' && typeof value.private === 'string' && typeof value.public === 'string' && typeof value.address === 'string' );}
// Check if object is a Bitcoin keypairfunction isBtcKeypair(value: any): value is BtcKeypair { return ( typeof value === 'object' && typeof value.privateKey === 'string' && typeof value.publicKey === 'string' && typeof value.wif === 'string' && typeof value.address === 'string' && typeof value.addresses === 'object' );}Module Exports
Section titled “Module Exports”Complete type exports from the SDK
Section titled “Complete type exports from the SDK”// VFX exportsexport { VfxClient, Network, TxType, type Keypair, type VfxAddress, type Transaction, type PaginatedResponse};
// Bitcoin exportsexport namespace btc { export { BtcClient, type BtcKeypair, type BtcMnemonicKeypair, type BtcAddressInfo, type BtcTransaction, type BtcFeeRates, type TransactionResult };}
// Utility exportsexport { type NetworkType, type VfxNetworkType, type PrivateKey, type PublicKey, type WIF, type Mnemonic, type VfxAmount, type SatoshiAmount, type BtcAmount, type FeeRate};These type definitions provide complete TypeScript support for the VerifiedX Web SDK, enabling full type safety and IntelliSense support in your applications.