import type { MarketsResponse } from '../Client'; import { UtxoExplorer } from '../Explorer/UtxoExplorer'; import { EvmExplorer } from '../Explorer/EvmExplorer'; import { GlobalExplorer } from '../Explorer/GlobalExplorer'; import { EvmConnector } from '../Connector/EvmConnector/EvmConnector'; import { EvmRpcConnector } from '../Connector/EvmRpcConnector/EvmRpcConnector'; import { EvmRpcExplorer } from '../Connector/EvmRpcConnector/EvmRpcExplorer'; import { UtxoConnector } from '../Connector/UtxoConnector/UtxoConnector'; import { BchConnector } from '../Connector/UtxoConnector/BchConnector/BchConnector'; import { UtxoNetworkDescriptor, BchNetworkDescriptor, EvmNetworkDescriptor, EvmRpcNetworkDescriptor } from './networks'; import type { NetworkCollection } from './networks'; import type { Wallet } from '../Wallet/Wallet'; import { TTLCache } from '../utils/TTLCache'; import { UtxoLocalCache } from '../utils/UtxoLocalCache'; import { RpcUrls } from './RpcUrls'; /** Shared state created by {@link ChainGate} and threaded into explorers/connectors. */ export interface ChainGateGlobal { marketsCache: TTLCache; utxoCache: UtxoLocalCache; } /** * Main client for the ChainGate blockchain API. * * Provides access to the ChainGate API for querying blockchain data * across EVM and UTXO networks. * * @example * ```ts * import { ChainGate } from 'chaingate'; * * const cg = new ChainGate({ apiKey: 'your-api-key' }); * * const btc = cg.explore(cg.networks.bitcoin); // UtxoExplorer * const eth = cg.explore(cg.networks.ethereum); // EvmExplorer * ``` */ export declare class ChainGate { private readonly client; private readonly apiKey; private readonly _networks; private readonly _rpcUrls; /** @internal Shared state passed to explorers and connectors. */ readonly global: ChainGateGlobal; /** * Returns a `UtxoExplorer` for the given UTXO network. */ explore(network: UtxoNetworkDescriptor): UtxoExplorer; /** * Returns an `EvmExplorer` for the given EVM network. */ explore(network: EvmNetworkDescriptor): EvmExplorer; /** * Returns an `EvmRpcExplorer` for a custom EVM RPC network. */ explore(network: EvmRpcNetworkDescriptor): EvmRpcExplorer; /** * Returns a {@link GlobalExplorer} for querying cross-network data such as * market prices, fiat exchange rates, real-time network information, and * network logos — including networks that don't have dedicated `/evm` or * `/utxo` endpoints. * * @example * ```ts * const global = cg.exploreGlobal(); * * const markets = await global.getMarkets(); * const info = await global.getNetworksInfo(); * const logoUrl = global.getNetworkLogoUrl('berachain'); * ``` */ exploreGlobal(): GlobalExplorer; /** * Returns the collection of all supported networks. * * The returned object is iterable (like an array) **and** has named * properties for direct access: * * ```ts * // Direct access * cg.networks.bitcoin // UtxoNetworkDescriptor * cg.networks.ethereum // EvmNetworkDescriptor * * // Iteration * for (const net of cg.networks) { ... } * ``` */ get networks(): NetworkCollection; /** * Pre-built JSON-RPC endpoint URLs for every network supported by the * ChainGate RPC proxy, with the API key already appended. * * Useful for passing to external libraries (ethers, viem, etc.) or to * {@link NetworkCollection.evmRpc | `cg.networks.evmRpc()`}. * * @example * ```ts * // Use with evmRpc connector * const polygon = cg.networks.evmRpc({ * rpcUrl: cg.rpcUrls.polygon, * chainId: 137, * name: 'Polygon', * symbol: 'POL', * }); * * // Or pass to any JSON-RPC library * const provider = new ethers.JsonRpcProvider(cg.rpcUrls.ethereum); * ``` */ get rpcUrls(): RpcUrls; /** * Connects a wallet to a network, returning a connector with address derivation, * balance queries, transaction broadcasting, and smart contract calls. * * @example * ```ts * const connector = cg.connect(cg.networks.ethereum, wallet); * const address = await connector.getAddress(); * ``` */ connect(network: BchNetworkDescriptor, wallet: Wallet): BchConnector; connect(network: EvmNetworkDescriptor, wallet: Wallet): EvmConnector; connect(network: EvmRpcNetworkDescriptor, wallet: Wallet): EvmRpcConnector; connect(network: UtxoNetworkDescriptor, wallet: Wallet): UtxoConnector; /** * @param options - Configuration options. * @param options.apiKey - Your ChainGate API key. */ constructor({ apiKey }: { apiKey: string; }); }