chaingate
Version:
Multi-chain cryptocurrency SDK for TypeScript — unified API for Bitcoin, Ethereum, Litecoin, Dogecoin, Bitcoin Cash, Polygon, Arbitrum, and any EVM-compatible chain. Create wallets, query balances, send transactions, and manage tokens and NFTs across UTXO
93 lines (92 loc) • 3.39 kB
TypeScript
import { EvmNonceCache } from '../../utils/EvmNonceCache';
/** Fee data returned by {@link EvmRpcExplorer.getFeeData}. */
export interface RpcFeeData {
/** Whether the chain supports EIP-1559 (type-2 transactions). */
supportsEip1559: boolean;
/** Max fee per gas in wei (EIP-1559). `undefined` when the chain is legacy-only. */
maxFeePerGas?: bigint;
/** Max priority fee per gas in wei (EIP-1559). `undefined` when the chain is legacy-only. */
maxPriorityFeePerGas?: bigint;
/** Gas price in wei (legacy). Always present as a fallback. */
gasPrice: bigint;
}
/** Minimal transaction receipt returned by {@link EvmRpcExplorer.getTransactionReceipt}. */
export interface RpcTransactionReceipt {
/** Block number the transaction was included in. */
blockNumber: number;
/** `1` for success, `0` for revert. */
status: number;
}
/**
* Lightweight EVM explorer that communicates directly with a JSON-RPC 2.0
* endpoint. No dependency on the ChainGate API.
*
* Only exposes the subset of RPC methods needed by {@link EvmRpcConnector} and
* {@link EvmRpcTransaction}.
*/
export declare class EvmRpcExplorer {
/** JSON-RPC endpoint URL. */
readonly rpcUrl: string;
/** EVM chain ID. */
readonly chainId: number;
/** @internal Per-address nonce cache shared across explorers. */
readonly nonceCache: EvmNonceCache;
private nextId;
constructor(rpcUrl: string, chainId: number, nonceCache?: EvmNonceCache);
/**
* Returns the wei balance for an address (`eth_getBalance` at `"latest"`).
*/
getBalance(address: string): Promise<bigint>;
/**
* Returns the nonce / transaction count for an address
* (`eth_getTransactionCount` at `"latest"`).
*/
getTransactionCount(address: string): Promise<bigint>;
/**
* Returns the next nonce to use when sending a transaction from an address
* (`eth_getTransactionCount` at `"pending"`).
*/
getNonce(address: string): Promise<bigint>;
/**
* Estimates gas for a transaction (`eth_estimateGas`).
*/
estimateGas(params: {
from: string;
to: string;
value: bigint;
data?: string;
nonce?: bigint;
}): Promise<bigint>;
/**
* Returns fee data for the current block.
*
* Tries EIP-1559 (`eth_maxPriorityFeePerGas` + `baseFeePerGas` from the
* latest block). If the chain does not support EIP-1559, falls back to
* `eth_gasPrice`.
*/
getFeeData(): Promise<RpcFeeData>;
/**
* Broadcasts a signed raw transaction (`eth_sendRawTransaction`).
*
* @returns The transaction hash.
*/
sendRawTransaction(signedTxHex: string): Promise<string>;
/**
* Returns the transaction receipt, or `null` if the transaction is still
* pending (`eth_getTransactionReceipt`).
*/
getTransactionReceipt(txHash: string): Promise<RpcTransactionReceipt | null>;
/**
* Returns the number of decimals for an ERC-20 token contract.
*/
getTokenDecimals(contractAddress: string): Promise<number>;
/** Returns the current gas price via `eth_gasPrice`. */
private getGasPrice;
/**
* Sends a JSON-RPC 2.0 request to the configured endpoint.
*
* @throws {RpcError} if the response contains an `error` field or the HTTP
* request fails.
*/
private call;
}