Comment connecter le frontend avec la solidité

//for reading data
async function YOUR_FUNCTION() {
    if (typeof window.ethereum !== "undefined") {
      const provider = new ethers.providers.Web3Provider(window.ethereum)
      const contract = new ethers.Contract(CONTRACT_ADDRESS, CONTRACT.abi, provider)
      try {
        const data = await contract.CONTRACT_FUNCTION()
        console.log(data)
      } catch (e) {
        console.log(e)
      }
    }
    
//writing data 
async function requestAccount() {
    await window.ethereum.request({ method: "eth_requestAccounts" })
  }

async function YOUR_FUNCTION() {
    if (typeof window.ethereum !== 'undefined') {
      await requestAccount()
      const provider = new ethers.providers.Web3Provider(window.ethereum)
      const signer = provider.getSigner()
      const contract = new ethers.Contract(YOUR_CONTRACT_ADDRESS, CONTRACT.abi, signer)
      const transaction = await contract.YOUR_CONTRACT('PARAMETER')
      await transaction.wait()
    }
  }
  
  //connect wallet
  
  async function connectWallet() {
const provider = new ethers.providers.Web3Provider(window.ethereum)

await provider.send("eth_requestAccounts", []);

const signer = provider.getSigner()
  }
Joel Mathew