useReadContract
A hook to read from a contract.
import { useReadContract } from "thirdweb/react";const { data, isLoading } = useReadContract({ contract, method: "totalSupply",});
function useReadContract( TransactionRequest, | "gas" | "value" | "accessList" | "to" | "data" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "nonce" | "from" > & { from?: string; method: method | PreparedMethod<ParseMethod<abi, method>>; } & ParamsOption< ParseMethod<ParseMethod<abi, method>>["inputs"] > & Omit< "client" | "chain" | "to" | "data" > & { queryOptions?: { enabled?: boolean; refetchInterval?: number; retry?: number; }; },): UseQueryResult<>;
The options for reading from a contract
TransactionRequest, | "gas" | "value" | "accessList" | "to" | "data" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "nonce" | "from"> & { from?: string; method: method | PreparedMethod<ParseMethod<abi, method>>; } & ParamsOption<ParseMethod<ParseMethod<abi, method>>["inputs"]> & Omit< "client" | "chain" | "to" | "data" > & { queryOptions?: { enabled?: boolean; refetchInterval?: number; retry?: number; }; };
let returnType: UseQueryResult<>;
a query object.
A hook to read from a contract.
import { useReadContract } from "thirdweb/react";import { getOwnedNFTs } form "thirdweb/extensions/erc721"const { data, isLoading } = useReadContract(getOwnedNFTs, { contract, owner: address });
function useReadContract( extension: ( ) => Promise<result>, queryOptions?: { enabled?: boolean; refetchInterval?: number; retry?: number; }; },): UseQueryResult<result>;
An extension to call.
let extension: () => Promise<result>;
The read extension params.
queryOptions?: { enabled?: boolean; refetchInterval?: number; retry?: number; }; };