adrianhajdin / project_crowdfunding

With a stunning design, connected to the blockchain, metamask pairing, interaction with smart contracts, sending Ethereum through the blockchain network, and writing solidity code.
https://jsmastery.pro
708 stars 382 forks source link

Error: Could not fetch bytecode for contract at 0xA48... on chain 11155111, double check that the address and chainId are correct. #83

Open Luan4560 opened 8 months ago

Luan4560 commented 8 months ago

I'm usign sepolia as test net but im getting this error.

Here my main.tsx

import React from 'react'
import ReactDOM from 'react-dom/client'
import { BrowserRouter as Router } from 'react-router-dom'
import { ThirdwebProvider } from '@thirdweb-dev/react'
import { App } from './App'
import './index.css'
import { StateContextProvider } from './context'
import { Sepolia } from "@thirdweb-dev/chains";

ReactDOM.createRoot(document.getElementById('root')!).render(
  <ThirdwebProvider activeChain={Sepolia} clientId='my-client-id'
  >
    <Router>
      <StateContextProvider>
        <App />
      </StateContextProvider>
    </Router>
  </ThirdwebProvider>
)

Someone could help ?

CTW2000 commented 8 months ago

Maybe you should check the console in the chrome and make sure there is no error ,then your project can run

rahulsingh-99 commented 8 months ago

I've also facing this same issue for 4 days but no one helped me till now

Luan4560 commented 8 months ago

Maybe you should check the console in the chrome and make sure there is no error ,then your project can run

image

ala-bchir commented 7 months ago

can you show me your hardhat.config file ?

Luan4560 commented 7 months ago

can you show me your hardhat.config file ?

import { HardhatUserConfig } from "hardhat/config";

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.24",
};

const config: HardhatUserConfig = {
  solidity: {
    version: "0.8.9",
    defaultNetwork: "sepolia",
    networks: {
      polygon: {
        url: "https://rpc.ankr.com/eth_sepolia",
        accounts: [`0x${process.env.PRIVATE_KEY}`],
      },
    },

    settings: {
      optimizer: {
        enabled: true,
        runs: 200,
      },
    },
  },
};

export default config;
ala-bchir commented 7 months ago

Try this one instead :

require("@matterlabs/hardhat-zksync-solc");

/* @type import('hardhat/config').HardhatUserConfig / module.exports = { solidity: { version: "0.8.17", defaultNetwork: "sepolia", networks: { hardhat: {}, sepolia: { url: "https://11155111.rpc.thirdweb.com", accounts: [0x${process.env.PRIVATE_KEY}] } }, settings: { optimizer: { enabled: true, runs: 200, }, }, }, };

ala-bchir commented 7 months ago

and just to make sure that you did replace your clientId by you actual clientId ?

rahulsingh-99 commented 7 months ago

Still facing the same issue

RathoreAbhiii commented 7 months ago

can you show me your hardhat.config file ?

import { HardhatUserConfig } from "hardhat/config";

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.24",
};

const config: HardhatUserConfig = {
  solidity: {
    version: "0.8.9",
    defaultNetwork: "sepolia",
    networks: {
      polygon: {
        url: "https://rpc.ankr.com/eth_sepolia",
        accounts: [`0x${process.env.PRIVATE_KEY}`],
      },
    },

    settings: {
      optimizer: {
        enabled: true,
        runs: 200,
      },
    },
  },
};

export default config;

Hey, did you try the suggestion? Did it work? Please update this thread if anyone got it working. Thanks!

Chetan51423 commented 6 months ago

Maybe you should check the console in the chrome and make sure there is no error ,then your project can run

image

I am facing the same issue and have not been able to configure it for the last 2 days! I am using Polygonamoy testnet . Please help me regarding this 🙏.

supremex04 commented 6 months ago
import React from "react";
import ReactDOM from "react-dom/client";
import {BrowserRouter as Router} from "react-router-dom";
import {ThirdwebProvider} from "@thirdweb-dev/react"
import { Sepolia } from "@thirdweb-dev/chains";

import { StateContextProvider } from "./context";
import App from "./App";
import "./index.css";
import dotenv from "dotenv";
dotenv.config();

const root = ReactDOM.createRoot(document.getElementById("root"));

root.render(
    <ThirdwebProvider activeChain={Sepolia} clientId= {process.env.CLIENT_ID}>
        <Router>
        <StateContextProvider>
        <App/>

        </StateContextProvider>
        </Router>
    </ThirdwebProvider>

)

I had got similar error. This is my main.jsx file, it works. Make sure you choose correct activeChain field ie. the chain where you deployed the contract and get clientId field from thirdweb here: https://thirdweb.com/dashboard/settings.

nithishp commented 6 months ago

I too had the same issue but after trying so many solutions it somehow got fixed. I don't know how it got fixed and the current code is somewhat similar to the code it started with when facing the problem but now it got fixed. This is my current code hope this helps Screenshot (35)

Akash-Mondal2004 commented 5 months ago

How do you fix the issue with connect wallet as useMetamask is deprecated. Screenshot 2024-06-29 102732

nithishp commented 5 months ago

How do you fix the issue with connect wallet as useMetamask is deprecated. Screenshot 2024-06-29 102732

you can use useConnect('metamask') or useMetamask(). Even though useMetamask() is deprecated it still functions. Hope this helps.

Akash-Mondal2004 commented 5 months ago

Thanks its working and tell me how i delete a particular campaign that i created

nithishp commented 5 months ago

Thanks its working

and tell me how i delete a particular campaign that i created

After deployment data added to the smart contract cannot be deleted. Instead you can mark it using a flag as deleted and don't consider the campaign during rendering time if the flag is set to false.

nithishp commented 5 months ago

Thanks its working

and tell me how i delete a particular campaign that i created

The easiest way would just redeploy the whole contract again and update the lastest contract address in your code. Hope that helps. Sorry for bad English.

Akash-Mondal2004 commented 5 months ago

yea this is possible but i want to implement that user who create a campaign wants to change the goal of raised amount or want to change any other specific data in the existing campaign so is it possible to edit the information

supremex04 commented 5 months ago
function editCampaign(
        uint256 _id,
        string memory _title,
        string memory _description,
        uint256 _target,
        string memory _image
    ) public {
        Campaign storage campaign = campaigns[_id];

        require(msg.sender == campaign.owner, "Only the campaign owner can edit the campaign.");
        require(_target >= campaign.amountCollected, "New target must be greater than or equal to the amount already collected.");

        campaign.title = _title;
        campaign.description = _description;
        campaign.target = _target;
        campaign.image = _image;
    }

something like this should work

rzalete commented 3 months ago
import React from "react";
import ReactDOM from "react-dom/client";
import {BrowserRouter as Router} from "react-router-dom";
import {ThirdwebProvider} from "@thirdweb-dev/react"
import { Sepolia } from "@thirdweb-dev/chains";

import { StateContextProvider } from "./context";
import App from "./App";
import "./index.css";
import dotenv from "dotenv";
dotenv.config();

const root = ReactDOM.createRoot(document.getElementById("root"));

root.render(
    <ThirdwebProvider activeChain={Sepolia} clientId= {process.env.CLIENT_ID}>
        <Router>
        <StateContextProvider>
        <App/>

        </StateContextProvider>
        </Router>
    </ThirdwebProvider>

)

I had got similar error. This is my main.jsx file, it works. Make sure you choose correct activeChain field ie. the chain where you deployed the contract and get clientId field from thirdweb here: https://thirdweb.com/dashboard/settings.

I've written exact code like yours on my main.jsx like this :

import React from "react";
import ReactDOM from "react-dom/client";
import { BrowserRouter as Router } from "react-router-dom";
import { ThirdwebProvider } from "@thirdweb-dev/react";
import { Sepolia } from "@thirdweb-dev/chains";

import { StateContextProvider } from "./context";
import App from "./App";
import "./index.css";

const root = ReactDOM.createRoot(document.getElementById("root"));

root.render(
  <ThirdwebProvider activeChain={Sepolia} clientId='75d6302d3e055fc75b8fb56e3d00a115'>
    <Router>
      <StateContextProvider>
        <App />
      </StateContextProvider>
    </Router>
  </ThirdwebProvider>
);

But I still got this error : image

Does anyone have the solution for this issue?

Akash-Mondal2004 commented 3 months ago

import { ChainId, ThirdwebProvider} from '@thirdweb-dev/react'; try this

rzalete commented 3 months ago

import { ChainId, ThirdwebProvider} from '@thirdweb-dev/react'; try this

I don't think that'll fix it