import { type Abi, type AbiFunction, type ExtractAbiFunctionNames } from "abitype"; import type { TransactionRequest } from "viem"; import type { ThirdwebContract } from "../contract/contract.js"; import { type PreparedMethod } from "../utils/abi/prepare-method.js"; import { type PrepareTransactionOptions } from "./prepare-transaction.js"; import type { BaseTransactionOptions, ParamsOption, ParseMethod } from "./types.js"; export type PrepareContractCallOptions) => Promise) = TAbi extends { length: 0; } ? AbiFunction | string : ExtractAbiFunctionNames, TPreparedMethod extends PreparedMethod> = PreparedMethod>> = BaseTransactionOptions & { contract: ThirdwebContract; method: TMethod | TPreparedMethod; } & ParamsOption & Omit, TAbi>; /** * Prepares a contract call by resolving the ABI function, parameters and encoded data. Optionally specify other properties such as value or gas price. * @param options - The options for preparing the contract call. * @returns A promise that resolves to the prepared transaction. * @transaction * @example * * ### Usage with a human-readable method signature: * * ```ts * import { prepareContractCall } from "thirdweb"; * * const transaction = prepareContractCall({ * contract, * method: "function transfer(address to, uint256 value)", * params: [to, value], * }); * ``` * * ### Usage with explicit gas price and/or value: * * ```ts * import { prepareContractCall } from "thirdweb"; * import { toWei } from "thirdweb/utils"; * * const transaction = prepareContractCall({ * contract, * method: "function transfer(address to, uint256 value)", * params: [to, value], * maxFeePerGas: 30n, * maxPriorityFeePerGas: 1n, * value: toWei("0.01"), * }); * ``` * * ### Usage with ERC20 value: * * For transactions that transfer ERC20 tokens, you can specify the value as the amount of tokens to transfer. * * You can use this in conjuction with the [`getApprovalForTransaction`](https://portal.thirdweb.com/references/typescript/v5/getApprovalForTransaction) function to easily create approval transactions for ERC20 tokens. * * This value will also be read by the react hooks and UI components to present to total cost to the user. * * ```ts * import { prepareContractCall } from "thirdweb"; * import { toWei } from "thirdweb/utils"; * * const transaction = prepareContractCall({ * contract, * method: "function payWithCoin()", * params: [], * erc20Value: { * tokenAddress: "0x...", // the address of the ERC20 token * amountWei: toWei("0.1"), // the amount of tokens to transfer in wei * }, * }); * ``` * * ### Usage with a JSON ABI function object: * * ```ts * import { prepareContractCall } from "thirdweb"; * * const transaction = prepareContractCall({ * contract, * method: { * name: "transfer", * type: "function", * inputs: [ * { name: "to", type: "address" }, * { name: "value", type: "uint256" }, * ], * outputs: [], * stateMutability: "payable" * }, * params: [to, value], * }); * ``` * * ### Usage with the ABI defined on the contract: * * ```ts * import { getContract, prepareContractCall } from "thirdweb"; * const contract = getContract({ * ..., // chain, address, client * abi: [...] // ABI with a "transfer" method * }); * const transaction = prepareContractCall({ * contract, * method: "transfer", // <- this gets inferred from the contract * params: [to, value], * }); * ``` * * ### Passing extra call data to the transaction * ```ts * import { getContract, prepareContractCall } from "thirdweb"; * const contract = getContract({ * ..., // chain, address, client * }); * * const transaction = prepareContractCall({ * contract, * method: "function transfer(address to, uint256 value)", * params: [...], * // The extra call data MUST be encoded to hex before passing * extraCallData: "0x......." * }); * ``` */ export declare function prepareContractCall) => Promise) : ExtractAbiFunctionNames, const TPreparedMethod extends PreparedMethod> = PreparedMethod>>(options: PrepareContractCallOptions): import("./prepare-transaction.js").PreparedTransaction, PrepareTransactionOptions>; //# sourceMappingURL=prepare-contract-call.d.ts.map