import type { EvmExplorer } from '../../Explorer/EvmExplorer'; import { BroadcastedEvmTransaction } from './BroadcastedEvmTransaction'; /** Fee tier names returned by the API. */ export type EvmFeeTier = 'low' | 'normal' | 'high' | 'maximum'; /** EIP-1559 fee parameters in wei. */ export interface EvmFee { /** Max fee per gas (base fee cap + tip) in wei. */ maxFeePerGas: bigint; /** Max priority fee per gas (tip) in wei. */ maxPriorityFeePerGas: bigint; /** Gas limit override. When omitted the auto-estimated value is kept. */ gasLimit?: bigint; } /** A recommended fee tier with estimated confirmation time and balance check. */ export interface EvmRecommendedFee extends EvmFee { /** Estimated seconds until confirmation. */ estimatedConfirmationSecs: number; /** Whether the wallet has enough funds to cover the transfer amount plus this fee. */ enoughFunds: boolean; } /** All recommended fee tiers. */ export interface EvmRecommendedFees { low: EvmRecommendedFee; normal: EvmRecommendedFee; high: EvmRecommendedFee; maximum: EvmRecommendedFee; } /** * An unsigned EVM transaction prepared by {@link EvmConnector.transfer}. * * The transaction is created with "normal" recommended fees. Before sending, * you can inspect or change the fee: * * @example * ```ts * const amount = cg.networks.ethereum.amount('0.1'); * const tx = await eth.transfer(amount, '0xRecipient...'); * * // Inspect recommended fees * const fees = tx.recommendedFees(); * console.log(fees.normal.maxFeePerGas); * * // Override with a specific tier * tx.setFee(fees.high); * * // Or set a manual fee with optional gas limit override * tx.setFee({ maxFeePerGas: 30_000_000_000n, maxPriorityFeePerGas: 2_000_000_000n, gasLimit: 50_000n }); * * // Sign and broadcast * const broadcasted = await tx.signAndBroadcast(); * console.log(broadcasted.transactionId); * * // Wait for confirmation * const cancel = broadcasted.onConfirmed((details) => { * console.log('Confirmed in block', details.blockHeight); * }); * * // Stop waiting at any time: * cancel(); * ``` */ export declare class EvmTransaction { private readonly explorer; private readonly fromAddress; private readonly toAddress; private readonly valueWei; private readonly data; private readonly nonce; private gasLimit; private readonly chainId; private readonly balanceWei; private readonly feeRates; private readonly getPrivateKey; private currentFee; private sent; /** @internal */ constructor(params: { explorer: EvmExplorer; fromAddress: string; toAddress: string; valueWei: bigint; data: string; nonce: bigint; gasLimit: bigint; chainId: bigint; balanceWei: bigint; feeRates: EvmRecommendedFees; getPrivateKey: () => Promise; }); /** * Returns all recommended fee tiers (low, normal, high, maximum). * * Each tier includes `maxFeePerGas`, `maxPriorityFeePerGas` (both in wei), * and `estimatedConfirmationSecs`. */ recommendedFees(): EvmRecommendedFees; /** * Returns whether the wallet has enough funds to cover the transfer plus fee * at the current fee and gas limit. */ enoughFunds(): boolean; /** * Sets the fee for this transaction. * * Pass a tier object from {@link recommendedFees} or an object with manual * `maxFeePerGas`, `maxPriorityFeePerGas` (in wei), and an optional * `gasLimit` override. * * @throws {@link TransactionAlreadySentError} if the transaction has already been sent. */ setFee(fee: EvmRecommendedFee | EvmFee): void; /** * Signs the transaction with the wallet's private key and broadcasts it to the network. * * @returns A {@link BroadcastedEvmTransaction} that can be used to track confirmation. * @throws {@link TransactionAlreadySentError} if the transaction has already been sent. * @throws {@link NotEnoughFundsError} if the wallet does not have enough funds. * @throws {@link UnsupportedOperationError} if the wallet is view-only. */ signAndBroadcast(): Promise; /** @internal — used by EvmConnector.transfer to build the transaction. */ static create(params: { explorer: EvmExplorer; fromAddress: string; toAddress: string; valueWei: bigint; data?: string; getPrivateKey: () => Promise; }): Promise; }