PatrickAlphaC / ethers-simple-storage-fcc

88 stars 125 forks source link

Deployment issue Lesson 5 pt 10 #112

Closed ramziosta closed 8 months ago

ramziosta commented 8 months ago

I am having an issue getting the deployment: I get an error but I see a contract up on the chain and blocks are made. I am not getting the same confirmation as the video.

1

I did have to change a few things in my code, such as importing fs instead of 'fs-extra' and using: ethers.JsonRpcProvider("http://127.0.0.1:7545/"); without "provider" after doing some research online my IDE and AI helped me debug into changing them to newer versions

this is my code:

const {ethers} = require('ethers');
const fs = require("fs");
require('dotenv').config();

async function Deploy() {
    const provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545");
    const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
    const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
    const bin = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.bin", "utf8");

    const contractFactory = new ethers.ContractFactory(abi, bin, wallet);
    console.log("🚀 Deploying, please wait...")
    const contract = await contractFactory.deploy({gasLimit: 6721975});
    // overrides can be :  transactionNonce: 1000000, gasPrice: 100000000000, value: 10000000000000000 , gasPrice: 10000000000
    // https://docs.ethers.org/v5/api/contract/contract-factory/#ContractFactory-deploy
    console.log("💰 " +contract);
    // the older the block the more secure it is, we make sure we have another block attached to the one we just sent up to the chain to make sure we can mine it

}

Deploy().then(() => process.exit(0))
    .catch(error => {
        console.error(error);
        process.exitCode = 1;
    });
and this is my error:

2 3 6 5 4

PatrickAlphaC commented 8 months ago

Thanks for making this issue. It's likely an issue with a package of hardhat you're using.

Can you:

  1. Make this a discusson on the full repo? https://github.com/smartcontractkit/full-blockchain-solidity-course-js/
  2. Follow this section for formatting questions? https://www.youtube.com/watch?t=19846&v=gyMwXuJrbJQ&feature=youtu.be
ramziosta commented 8 months ago

I opened one at https://github.com/smartcontractkit/full-blockchain-solidity-course-js/discussions/6401