import type { EvmRpcExplorer, RpcFeeData } from './EvmRpcExplorer'; import { BroadcastedEvmRpcTransaction } from './BroadcastedEvmRpcTransaction'; /** Fee parameters in wei for an EVM RPC transaction. */ export interface EvmRpcFee { /** Max fee per gas in wei (EIP-1559) or gas price in wei (legacy). */ maxFeePerGas: bigint; /** Max priority fee per gas in wei (EIP-1559 only, ignored for legacy). */ maxPriorityFeePerGas: bigint; /** Gas limit override. When omitted the auto-estimated value is kept. */ gasLimit?: bigint; } /** * An unsigned EVM transaction prepared by {@link EvmRpcConnector.transfer}. * * Automatically selects EIP-1559 (type-2) or legacy (type-0) signing based on * the chain's capabilities detected via `eth_maxPriorityFeePerGas`. * * @example * ```ts * const network = cg.networks.evmRpc({ rpcUrl: '...', chainId: 56, name: 'BSC', symbol: 'BNB' }); * const conn = cg.connect(network, wallet); * const tx = await conn.transfer(network.amount('0.1'), '0xRecipient...'); * * // Inspect the current fee * const fee = tx.currentFee(); * * // Override with a custom fee and optional gas limit * tx.setFee({ maxFeePerGas: 5_000_000_000n, maxPriorityFeePerGas: 1_000_000_000n, gasLimit: 50_000n }); * * // Sign and broadcast * const broadcasted = await tx.signAndBroadcast(); * ``` */ export declare class EvmRpcTransaction { 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 supportsEip1559; private readonly getPrivateKey; private _currentFee; private sent; /** @internal */ constructor(params: { explorer: EvmRpcExplorer; fromAddress: string; toAddress: string; valueWei: bigint; data: string; nonce: bigint; gasLimit: bigint; chainId: bigint; balanceWei: bigint; feeData: RpcFeeData; getPrivateKey: () => Promise; }); /** * Returns the current fee parameters that will be used for signing. * * For EIP-1559 chains both `maxFeePerGas` and `maxPriorityFeePerGas` are * meaningful. For legacy chains `maxFeePerGas` represents the gas price and * `maxPriorityFeePerGas` is `0n`. */ currentFee(): Readonly; /** * Returns whether the wallet has enough funds to cover the transfer plus fee. */ enoughFunds(): boolean; /** * Overrides the fee for this transaction. * * Pass an object with `maxFeePerGas`, `maxPriorityFeePerGas` (in wei), * and an optional `gasLimit` override. * * @throws {@link TransactionAlreadySentError} if the transaction has already been sent. */ setFee(feeParams: EvmRpcFee): void; /** * Signs the transaction and broadcasts it to the network via JSON-RPC. * * @returns A {@link BroadcastedEvmRpcTransaction} 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. */ signAndBroadcast(): Promise; /** * Fetches all required on-chain data (nonce, gas, fees, balance) and * constructs the transaction. * * @internal — used by {@link EvmRpcConnector.transfer}. */ static create(params: { explorer: EvmRpcExplorer; fromAddress: string; toAddress: string; valueWei: bigint; data?: string; getPrivateKey: () => Promise; }): Promise; }