/** Handle returned by WebSocket subscription methods; call `unsubscribe()` to stop. */ type Subscription = { unsubscribe: () => void }; type WsEvent = "block" | "mempool" | "tx_update" | "address_tx_update" | "address_balance_update" | "nft_event" | "nft_asset_event" | "nft_collection_event"; type WsSubscribeParams = { event: WsEvent tx_id?: string address?: string asset_identifier?: string value?: string }; type BlockNotification = { canonical: boolean height: number hash: string index_block_hash: string parent_block_hash: string burn_block_height: number burn_block_hash: string parent_burn_block_hash: string parent_burn_block_height: number parent_index_block_hash: string txs: string[] }; type MempoolNotification = { tx_id: string tx_type: string tx_status: string receipt_time: number receipt_time_iso: string fee_rate: string sender_address: string sponsor_address?: string nonce: number contract_call?: { contract_id: string function_name: string function_signature: string } token_transfer?: { recipient_address: string amount: string memo: string } }; type TxUpdateNotification = { tx_id: string tx_type: string tx_status: string block_hash?: string block_height?: number burn_block_height?: number burn_block_time?: number tx_result?: { hex: string repr: string } }; type AddressTxNotification = { address: string tx_id: string tx_type: string tx_status: string stx_sent: string stx_received: string stx_transfers: Array<{ amount: string sender: string recipient: string }> ft_transfers: Array<{ amount: string asset_identifier: string sender: string recipient: string }> nft_transfers: Array<{ asset_identifier: string sender: string recipient: string value: { hex: string repr: string } }> }; type AddressBalanceNotification = { address: string balance: string total_sent: string total_received: string total_fees_sent: string total_miner_rewards_received: string lock_tx_id: string locked: string lock_height: number burnchain_lock_height: number burnchain_unlock_height: number }; type NftEventNotification = { sender: string recipient: string asset_identifier: string asset_event_type: string value: { hex: string repr: string } tx_id: string block_height: number }; /** Account derived from a local private key (mnemonic or raw key). */ type LocalAccount = { type: "local" address: string /** Compressed public key (hex) */ publicKey: string /** Raw ECDSA sign over a hash */ sign(hash: Uint8Array): Uint8Array /** Sign a raw UTF-8 / byte message (`sha256(bytes)`). Not SIP-018. */ signMessage(message: string | Uint8Array): string }; /** Account with a user-provided signing function (sync or async). */ type CustomAccount = { type: "custom" address: string publicKey: string sign(hash: Uint8Array): Promise | Uint8Array }; /** Browser wallet provider interface (e.g. Leather, Xverse). */ type StacksProvider = { request(method: string, params?: any): Promise }; /** Account backed by a browser wallet {@link StacksProvider}. */ type ProviderAccount = { type: "provider" address: string publicKey: string provider: StacksProvider }; /** Allocates mempool-safe sequential nonces across rapid broadcasts from one account. */ type NonceManager = { consume(params: { client: Client address: string }): Promise reset(params: { client: Client address: string }): void | Promise /** * Give back a nonce from {@link NonceManager.consume} whose transaction * was never accepted by the node. No-op unless it is the latest issued. */ release(params: { client: Client address: string nonce: bigint }): void | Promise /** Next nonce that {@link NonceManager.consume} would return without consuming it, or `undefined` if untracked. */ peek(params: { client: Client address: string }): Promise }; /** Full chain descriptor used by clients and transports for network-aware operations. */ type StacksChain = { /** Chain ID (e.g. 0x00000001 for mainnet) */ id: number /** Human-readable name */ name: string /** Network type */ network: "mainnet" | "testnet" /** Transaction version byte for serialization */ transactionVersion: number /** Peer network ID for P2P broadcasting */ peerNetworkId: number /** Address version bytes */ addressVersion: { singleSig: number multiSig: number } /** Magic bytes for network identification */ magicBytes: string /** Boot address (system contracts deployer) */ bootAddress: string /** Native currency info */ nativeCurrency: { name: string symbol: string decimals: number } /** Default RPC URLs */ rpcUrls: { default: { http: string[] ws?: string[] } } /** Block explorer URLs */ blockExplorers?: { default: { name: string url: string } } }; /** Function that sends an HTTP request to a Stacks node API path. */ type RequestFn = (path: string, options?: RequestOptions) => Promise; /** Options for a transport-level HTTP request. */ type RequestOptions = { method?: "GET" | "POST" | "PUT" | "DELETE" body?: unknown headers?: Record /** * Cancel the request from the caller's side. An aborted signal rejects * with the signal's reason immediately and never retries; it is combined * with the transport's own per-attempt timeout. */ signal?: AbortSignal /** * Override the transport's retry budget for this one request. Broadcasts * pass `0`: re-sending a transaction the node may already hold trades a * transient failure for a confusing nonce conflict. */ retryCount?: number }; /** Shared configuration for all transport types. */ type TransportConfig = { url?: string /** * Per-attempt deadline in ms covering headers AND body. A stalled body * rejects with `TimeoutError` instead of hanging. Default 30_000. */ timeout?: number retryCount?: number retryDelay?: number fetchOptions?: RequestInit /** Sent as `x-api-key`. Held in the request closure and stripped from * `Transport.config` so it never prints with the client. */ apiKey?: string }; /** A resolved transport instance with a bound request function. */ type Transport = { type: string request: RequestFn config: TransportConfig destroy?: () => void }; /** Union of all supported account types (local key, custom signer, or browser provider). */ type Account = LocalAccount | CustomAccount | ProviderAccount; /** * Core client instance that holds chain context, transport, and extensible actions. * Created via {@link createClient}, {@link createPublicClient}, or {@link createWalletClient}. */ type Client = Record> = { chain?: StacksChain account?: Account transport: Transport request: RequestFn /** Optional nonce manager for mempool-safe sequential nonces across rapid broadcasts. */ nonceManager?: NonceManager extend: >(fn: (client: Client) => TNew) => Client & TNew } & TExtended; type WatchBlocksParams = { onBlock: (block: BlockNotification) => void }; declare function watchBlocks(client: Client, params: WatchBlocksParams): Promise; type WatchMempoolParams = { onTransaction: (tx: MempoolNotification) => void }; declare function watchMempool(client: Client, params: WatchMempoolParams): Promise; type WatchTransactionParams = { txId: string onUpdate: (update: TxUpdateNotification) => void }; declare function watchTransaction(client: Client, params: WatchTransactionParams): Promise; type WatchAddressParams = { address: string onTransaction: (tx: AddressTxNotification) => void }; declare function watchAddress(client: Client, params: WatchAddressParams): Promise; type WatchAddressBalanceParams = { address: string onBalance: (balance: AddressBalanceNotification) => void }; declare function watchAddressBalance(client: Client, params: WatchAddressBalanceParams): Promise; type WatchNftEventParams = { onEvent: (event: NftEventNotification) => void assetIdentifier?: string value?: string }; declare function watchNftEvent(client: Client, params: WatchNftEventParams): Promise; export { watchTransaction, watchNftEvent, watchMempool, watchBlocks, watchAddressBalance, watchAddress, WsSubscribeParams, WsEvent, WatchTransactionParams, WatchNftEventParams, WatchMempoolParams, WatchBlocksParams, WatchAddressParams, WatchAddressBalanceParams, TxUpdateNotification, Subscription, NftEventNotification, MempoolNotification, BlockNotification, AddressTxNotification, AddressBalanceNotification };