import { type Address, Amount, type ExecuteOptions, type Token } from "../types/index.js"; import type { WalletInterface } from "../wallet/index.js"; import { type BigNumberish, type Call, type RpcProvider } from "starknet"; import type { Tx } from "../tx/index.js"; /** * ERC20 token interaction helper. * * Provides methods for common ERC20 operations: approvals, transfers, * and balance queries. Handles both `balance_of` (snake_case) and * `balanceOf` (camelCase) entrypoints for maximum compatibility. * * Instances are cached per-token on the wallet via `wallet.erc20(token)`. * * @example * ```ts * // Via wallet (recommended) * const balance = await wallet.balanceOf(USDC); * const tx = await wallet.transfer(USDC, [ * { to: recipient, amount: Amount.parse("100", USDC) }, * ]); * * // Direct usage * const erc20 = new Erc20(USDC, provider); * const balance = await erc20.balanceOf(wallet); * ``` */ export declare class Erc20 { readonly token: Token; private readonly contract; constructor(token: Token, provider: RpcProvider); /** * Build an ERC20 approve Call without executing. * * @internal Used by {@link TxBuilder} — not part of the public API. */ populateApprove(spender: Address, amount: Amount): Call; /** * Build transfer Call(s) without executing. * * @internal Used by {@link TxBuilder} — not part of the public API. */ populateTransfer(transfers: { to: Address; amount: Amount; }[]): Call[]; /** * Transfer tokens to one or more addresses. * @param from - Wallet to transfer tokens from * @param transfers - Array of transfer objects, each containing a to address and an Amount * @param options - Optional execution options * * @example * ```ts * const erc20 = wallet.erc20(USDC); * const amount = Amount.parse("100", USDC); * * const tx = await erc20.transfer(wallet, [ * { to: recipientAddress, amount }, * ]); * await tx.wait(); * ``` * * @throws Error if any amount's decimals or symbol don't match the token */ transfer(from: WalletInterface, transfers: { to: Address; amount: Amount; }[], options?: ExecuteOptions): Promise; /** * Get the balance in a wallet. * @param walletOrAddress - Wallet (or address value) to check the balance of * @returns Amount representing the token balance * * @example * ```ts * const erc20 = wallet.erc20(USDC); * const balance = await erc20.balanceOf(wallet); * * console.log(balance.toUnit()); // "100.5" * console.log(balance.toFormatted()); // "100.5 USDC" * ``` */ balanceOf(walletOrAddress: WalletInterface | Address | BigNumberish): Promise; /** * Create an `Erc20` instance from a contract address alone, resolving token * metadata (name, symbol, decimals) automatically. * * Resolution order: * 1. Known preset tokens for the connected chain are checked first. * 2. If not found in presets, metadata is fetched on-chain via the ERC20 * `name`, `symbol`, and `decimals` entrypoints. * * @param address - The Starknet ERC20 contract address * @param provider - An `RpcProvider` connected to the target network * @returns A ready-to-use `Erc20` instance with resolved token metadata * @throws Error if the token metadata cannot be resolved for the given address * * @example * ```ts * const erc20 = await Erc20.fromAddress( * "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8" as Address, * provider * ); * * const balance = await erc20.balanceOf(wallet); * console.log(balance.toFormatted()); // "100 USDC" * ``` */ static fromAddress(address: Address, provider: RpcProvider): Promise; } //# sourceMappingURL=erc20.d.ts.map