Skip to main content

useContract() function

Use this resolve a contract address to a smart contract instance.

Example

const { contract, isLoading, error } = useContract(
"{{contract_address}}",
"nft-drop",
);

Signature:

export declare function useContract<TContractType extends ContractType>(
contractAddress: RequiredParam<ContractAddress>,
_contractType: TContractType,
): UseContractResult<
TContractType extends PrebuiltContractType
? ContractForPrebuiltContractType<TContractType>
: SmartContract
>;

Parameters

ParameterTypeDescription
contractAddressRequiredParam<ContractAddress>the address of the deployed contract
_contractTypeTContractTypethe type of the contract

Returns:

UseContractResult<TContractType extends PrebuiltContractType ? ContractForPrebuiltContractType<TContractType> : SmartContract>

a response object that includes the contract once it is resolved