UNPKG

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

62 lines (61 loc) 2.61 kB
import { BaseEvmConnector } from '../EvmConnector/BaseEvmConnector'; import type { CreateEvmTransactionParams } from '../EvmConnector/BaseEvmConnector'; import type { AddressOptions } from '../Connector'; import { EvmRpcExplorer } from './EvmRpcExplorer'; import type { Wallet } from '../../Wallet/Wallet'; import { Amount } from '../../utils/Amount'; import type { BaseValue } from '../../utils/Amount'; import type { EvmRpcNetworkDescriptor } from '../../ChainGate/networks'; import { EvmRpcTransaction } from './EvmRpcTransaction'; /** * Connector for any EVM-compatible network via a direct JSON-RPC connection. * * Supported operations: `address()`, `addressBalance()`, `transfer()`, * `transferToken()`, `transferNft()`, `transferErc1155()`, `callContract()`. * For transaction history, token-balance discovery, and fiat conversion use * {@link EvmConnector} instead. * * @example * ```ts * const cg = new ChainGate(); * const network = cg.networks.evmRpc({ * rpcUrl: 'https://bsc-dataseed.binance.org', * chainId: 56, * name: 'BNB Smart Chain', * symbol: 'BNB', * }); * * const conn = cg.connect(network, wallet); * const addr = await conn.address(); * const balance = await conn.addressBalance(); * const tx = await conn.transfer(network.amount('0.1'), '0x...'); * const broadcasted = await tx.signAndBroadcast(); * ``` */ export declare class EvmRpcConnector extends BaseEvmConnector<EvmRpcExplorer, EvmRpcNetworkDescriptor, EvmRpcTransaction> { /** @internal */ constructor(wallet: Wallet, explorer: EvmRpcExplorer, network: EvmRpcNetworkDescriptor); protected createTransaction(params: CreateEvmTransactionParams): Promise<EvmRpcTransaction>; /** * Returns the native coin balance for this wallet's address. * * The returned `Amount` uses the network's decimals and native token metadata. * Fiat conversion is not supported here — use {@link EvmConnector} when needed. */ addressBalance(options?: AddressOptions): Promise<{ address: string; balance: Amount; }>; /** * Creates an ERC-20 token transfer transaction. * * Token decimals are resolved automatically. * * @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<EvmRpcTransaction>; }