1

enter image description here

Error:

0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266   To:                 
0xe7f1725e7734ce288f8367e1bb143e90bb3f0512

  Error: VM Exception while processing transaction: reverted with
reason string 'You Don't have enough funds to donate'
      at FundMe.fund (contracts/FundMe.sol:61)
      at FundMe.<fallback> (contracts/FundMe.sol:57)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at HardhatNode.runCall (/home/deepak/blockchain-dev/hardhat-fund-me/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:652:20)
      at EthModule._callAction (/home/deepak/blockchain-dev/hardhat-fund-me/node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:354:9)
      at HardhatNetworkProvider._sendWithLogging (/home/deepak/blockchain-dev/hardhat-fund-me/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:139:22)
      at HardhatNetworkProvider.request (/home/deepak/blockchain-dev/hardhat-fund-me/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:116:18)
      at JsonRpcHandler._handleRequest (/home/deepak/blockchain-dev/hardhat-fund-me/node_modules/hardhat/src/internal/hardhat-network/jsonrpc/handler.ts:188:20)
      at JsonRpcHandler._handleSingleRequest (/home/deepak/blockchain-dev/hardhat-fund-me/node_modules/hardhat/src/internal/hardhat-network/jsonrpc/handler.ts:167:17)

eth_blockNumber eth_getBlockByNumber eth_feeHistory

index.js

       import { ethers } from "./ethers-5.6.esm.min.js"
    import { abi, contractAddress } from "./constants.js"
    
    let connectButton = document.getElementById("connect-Btn")
    let fundButton = document.getElementById("fund-Btn")
    
    connectButton.onclick = connect
    fundButton.onclick = fund
    
    async function connect() {
      if (typeof window.ethereum !== "undefined") {
        try {
          await window.ethereum.request({ method: "eth_requestAccounts" })
        } catch (error) {
          console.log(error)
        }
        connectButton.innerText = "Connected!"
        const accounts = await ethereum.request({ method: "eth_accounts" })
        console.log(accounts)
      } else {
        connectButton.innerText = "Please Install Metamask"
      }
    }
    
    //*fund
    
    async function fund() {
      const ethAmount = "0.1"
      console.log(`Funding with ${ethAmount}....`)
      if (typeof window.ethereum !== "undefined") {
        //? What we need to send a transaction
        //* provider/connection to blockchain
        const provider = new ethers.providers.Web3Provider(window.ethereum)
        //*signer/wallet/someone with some gas
        const signer = provider.getSigner()
        //* contract that we are interacting with
        const contract = new ethers.Contract(contractAddress, abi, signer)
        //* ABI & Address
        const transactionResponse = await contract.fund({
          value: ethers.utils.parseEther(ethAmount),
        })
      }
    }
```

github link to smartcontract which im importing in frontend : https://github.com/deepak2301/hardhat-FundMe

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.