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
64 lines (63 loc) • 2.5 kB
TypeScript
import type { EvmRpcExplorer } from './EvmRpcExplorer';
/** Details passed to the confirmation callback. */
export interface EvmRpcConfirmationDetails {
/** Transaction hash. */
transactionId: string;
/** Block number the transaction was included in. */
blockHeight: number;
/** Whether the transaction succeeded or was reverted by the EVM. */
status: 'success' | 'reverted';
}
/**
* Represents a transaction that has been signed and broadcast to an EVM
* network via a direct JSON-RPC connection.
*
* Use {@link onConfirmed} to register a callback that fires when the
* transaction is confirmed on-chain. If the transaction is already confirmed
* at the time of registration, the callback fires immediately.
*
* `onConfirmed` returns a `cancel` function to stop polling.
*
* @example
* ```ts
* const broadcasted = await tx.signAndBroadcast();
* console.log('TX sent:', broadcasted.transactionId);
*
* const cancel = broadcasted.onConfirmed((details) => {
* console.log('Confirmed in block', details.blockHeight);
* console.log('Status:', details.status);
* });
*
* // Stop waiting for confirmation at any time:
* cancel();
* ```
*/
export declare class BroadcastedEvmRpcTransaction {
/** The transaction hash returned by the network. */
readonly transactionId: string;
private readonly explorer;
private confirmationDetails;
private polling;
private cancelled;
private callbacks;
/** @internal */
constructor(transactionId: string, explorer: EvmRpcExplorer);
/**
* Registers a callback to be invoked when the transaction is confirmed.
*
* - If the transaction is already confirmed, the callback fires immediately
* (asynchronously, in the next microtask).
* - Multiple callbacks can be registered; they all fire once on confirmation.
* - Polling starts automatically on the first call and stops after confirmation
* or when the returned `cancel` function is called.
*
* @param callback - Function invoked with confirmation details.
* @returns A function that, when called, removes this callback and stops
* polling if no other callbacks remain.
*/
onConfirmed(callback: (details: EvmRpcConfirmationDetails) => void): () => void;
/** Polls the RPC node for transaction confirmation until confirmed or cancelled. */
private poll;
/** Invokes all registered callbacks and clears the list. */
private fireCallbacks;
}