react.usecontract
Home > @openformat/react > useContract
useContract() function
Create a contract instance from it's address
Signature:
export declare function useContract(address: string): import("@tanstack/react-query").UseQueryResult<import("@openformat/sdk").OpenFormatContract, unknown>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| address | string | Address of the contract |
Returns:
import("@tanstack/react-query").UseQueryResult<import("@openformat/sdk").OpenFormatContract, unknown>
{ERC721Base}
Example
const contractAddress = "0x3a151f807ee4370ea173a051cb6ba0790ce10da7";
const NFT = useContract(contractAddress);
function mint() {
if (NFT) {
NFT.mint(params);
}
}