import type { Address } from 'abitype'; import type { Account } from '../../accounts/types.js'; import type { Client } from '../../clients/createClient.js'; import type { Transport } from '../../clients/transports/createTransport.js'; import { erc20Abi } from '../../constants/abis.js'; import type { BaseErrorType } from '../../errors/base.js'; import type { Tokens } from '../../tokens/defineToken.js'; import type { Chain } from '../../types/chain.js'; import type { Log } from '../../types/log.js'; import { type SimulateContractReturnType } from '../public/simulateContract.js'; import type { WriteContractReturnType } from '../wallet/writeContract.js'; import { writeContract } from '../wallet/writeContract.js'; import type { writeContractSync } from '../wallet/writeContractSync.js'; import { type AmountInput, type TokenParameter, type WriteParameters } from './internal.js'; /** * Approves a spender to transfer ERC-20 tokens on behalf of the caller. * * @example * ```ts * import { createClient, http } from 'viem' * import { mainnet } from 'viem/chains' * import { privateKeyToAccount } from 'viem/accounts' * import { token } from 'viem/actions' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: mainnet, * transport: http(), * }) * * const hash = await token.approve(client, { * amount: 100000000n, * spender: '0x...', * token: '0x...', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function approve(client: Client, parameters: approve.Parameters): Promise; export declare namespace approve { type Args = { /** Amount to approve in base units, or as a formatted helper. */ amount: AmountInput; /** Address of the spender. */ spender: Address; } & TokenParameter; type Parameters = WriteParameters & Args; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: approve.Parameters): Promise>; /** * Defines a call to the `approve` function. * * Can be passed as a parameter to `estimateContractGas`, `simulateContract`, * `sendCalls`, `sendTransaction` (`calls`), or `multicall`. The token is * selected by `token`, which is either a token symbol (resolved from the * client's `tokens` array) or a contract `address`; `amount.decimals` * is inferred from declared client tokens when omitted. * * @param client - Client. * @param parameters - Parameters. * @returns The call. */ function call(client: Client, parameters: Args): { abi: [{ readonly type: "function"; readonly name: "approve"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly name: "spender"; readonly type: "address"; }, { readonly name: "amount"; readonly type: "uint256"; }]; readonly outputs: readonly [{ readonly type: "bool"; }]; }]; functionName: "approve"; } & { args: readonly [spender: `0x${string}`, amount: bigint]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; /** * Estimates the gas required to approve a spender. `amount.decimals` is * inferred from declared client tokens when omitted. * * @param client - Client. * @param parameters - Parameters. * @returns The gas estimate. */ function estimateGas(client: Client, parameters: approve.Parameters): Promise; /** * Simulates an approval of a spender. `amount.decimals` is inferred from * declared client tokens when omitted. * * @param client - Client. * @param parameters - Parameters. * @returns The simulation result and write request. */ function simulate(client: Client, parameters: approve.Parameters): Promise>; /** * Extracts the `Approval` event from logs. * * @param logs - The logs. * @returns The `Approval` event. */ function extractEvent(logs: Log[]): Log; } //# sourceMappingURL=approve.d.ts.map