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
74 lines (73 loc) • 3.13 kB
TypeScript
import { BaseEvmConnector } from './BaseEvmConnector';
import type { CreateEvmTransactionParams } from './BaseEvmConnector';
import type { AddressOptions } from '../Connector';
import { EvmExplorer } from '../../Explorer/EvmExplorer';
import type { Wallet } from '../../Wallet/Wallet';
import type { EvmAddressHistoryResponse, EvmAddressTxCountResponse } from '../../Client';
import { Amount } from '../../utils/Amount';
import type { BaseValue } from '../../utils/Amount';
import type { EvmNetworkDescriptor } from '../../ChainGate/networks';
import { EvmTransaction } from './EvmTransaction';
/**
* Connector for Ethereum (and EVM-compatible) networks.
*
* For network-level operations (blocks, gas, broadcasting, contract calls,
* tokens, NFTs, logos) use {@link EvmExplorer} via
* `cg.explore(cg.networks.ethereum)`.
*
* @example
* ```ts
* const cg = new ChainGate();
* const eth = cg.connect(cg.networks.ethereum, wallet);
*
* // Get the default address (index 0)
* const addr = await eth.address();
*
* // Get address at index 3
* const addr3 = await eth.address({ index: 3 });
*
* // Query balance (uses the wallet's default address)
* const balance = await eth.addressBalance();
*
* // Query balance at a specific index
* const balance3 = await eth.addressBalance({ index: 3 });
* ```
*/
export declare class EvmConnector extends BaseEvmConnector<EvmExplorer, EvmNetworkDescriptor, EvmTransaction> {
/** @internal */
constructor(wallet: Wallet, explorer: EvmExplorer, network: EvmNetworkDescriptor);
protected createTransaction(params: CreateEvmTransactionParams): Promise<EvmTransaction>;
/** Returns the confirmed and unconfirmed balance for this wallet's address. */
addressBalance(options?: AddressOptions): Promise<{
address: string;
confirmed: Amount;
unconfirmed: Amount;
}>;
/**
* Returns paginated transaction history for this wallet's address.
*
* @param page - Pagination cursor.
*/
addressHistory(page?: string, options?: AddressOptions): Promise<EvmAddressHistoryResponse>;
/**
* Returns all ERC-20/ERC-721/ERC-1155 token balances for this wallet's address.
*
* Each balance is an {@link Amount}. Use `isToken` and `isNFT` to distinguish types.
*/
addressTokenBalances(options?: AddressOptions): Promise<Amount[]>;
/** Returns the nonce (transaction count) for this wallet's address. */
addressTransactionCount(options?: AddressOptions): Promise<EvmAddressTxCountResponse>;
/**
* Creates an ERC-20 token transfer transaction.
*
* Token decimals are resolved automatically, so only the amount
* in human-readable units is required.
*
* @param contractAddress - Token contract address (with `0x` prefix).
* @param amount - Amount of tokens in human-readable units.
* @param toAddress - Recipient address.
*
* @throws {@link UnsupportedOperationError} if the wallet is view-only.
*/
transferToken(contractAddress: string, amount: BaseValue, toAddress: string, options?: AddressOptions): Promise<EvmTransaction>;
}