Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to deploy on sepolia testnet instead of hardhat localhost? #21

Open
elvisisvan opened this issue Nov 15, 2023 · 0 comments
Open

how to deploy on sepolia testnet instead of hardhat localhost? #21

elvisisvan opened this issue Nov 15, 2023 · 0 comments

Comments

@elvisisvan
Copy link

i'm trying to deploy my contract on ethereum sepolia network but encountered this error:

Error: sending a transaction requires a signer (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=contracts/5.7.0)

i have added const signer = provider.getSigner(); according to this answer on stackoverflow but the error is still there, here's my App.js code:

...
  const loadBlockchainData = async () => {
try {
      const provider = new ethers.providers.Web3Provider(window.ethereum)
      setProvider(provider)
      const signer = provider.getSigner();
      const network = await provider.getNetwork()
      const chainId = network.chainId;
      const contractAddresses = config[chainId];
      if(!contractAddresses) {
        throw new Error(`No contract deployed to chain with id ${chainId}`);
      }
  
      const carbonCredit = new ethers.Contract(config[network.chainId].carbonCredit.address, CarbonCredit, provider)
      const totalSupply = await carbonCredit.totalSupply()
      const credits = []
  
      for (var i = 1; i <= totalSupply; i++) {
        const uri = await carbonCredit.tokenURI(i)
        const response = await fetch(uri)
        const metadata = await response.json()
        credits.push(metadata)
      }
  
      setCredits(credits)
  
      const escrow = new ethers.Contract(config[network.chainId].escrow.address, Escrow, provider)
      setEscrow(escrow)
  
      window.ethereum.on('accountsChanged', async () => {
        const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
        const account = ethers.utils.getAddress(accounts[0])
        setAccount(account);
      })
} catch (error) {
  console.error("Error loading blockchain data", error);
}
  }

  useEffect(() => {
    loadBlockchainData()
  }, [])
...

image

can anyone help me with this? i'm more than happy to provide more related code if you ask, any help would be awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant