Import "ethers" and create a method "getContractInstance" to acquire a "contract" instance so that it can be used to call a contract. Note that the contract in this example is deployed on the mumbai network, so make sure that Metamask is switched to this network.
import{ethers,providers}from'ethers'// The name to be registeredconstregisterName='test-'+Date.now()constgetContractInstance=()=>{ // The contract addressconstcontractAddress='0x6A22794A1e2aBdEC057a6dc24A6BFB53F9518016'constprovider=newproviders.Web3Provider(window.ethereum)constsigner=provider.getSigner()constcontract=newethers.Contract(contractAddress,abi,signer)returncontract}