smartcontractkit / full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
12.25k stars 2.94k forks source link

Lesson 5: Can't deploy the contract #5038

Closed AnnachiPSP closed 1 year ago

AnnachiPSP commented 1 year ago

Discussed in https://github.com/smartcontractkit/full-blockchain-solidity-course-js/discussions/5037

Originally posted by **AnnachiPSP** March 9, 2023 I've been getting the same error multiple times after verifying a lot. Please help.. **The error says:** "invalid bytecode (argument="bytecode", value={}, code=INVALID_ARGUMENT, version=contracts/5.7.0)" `const ethers = require("ethers"); const fs = require("fs"); async function main(){ //address: HTTP://127.0.0.1:7545 const provider = new ethers.providers.JsonRpcProvider("HTTP://127.0.0.1:7545"); const wallet = new ethers.Wallet("0x95c80fdb45c15b69e2920952c06c6ab005c6b379bc8f2b5aadcf7543a9e44f2a", provider); const abi = new fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8"); const binary = new fs.readFileSync("./SimpleStorage_sol_SimpleStorage.bin", "utf8" ); console.log("ABI code: ", abi); console.log("Binary code:", binary); const contractFactory = new ethers.ContractFactory(abi, binary, wallet); console.log("Deploying the respective contract......"); const contract = await contractFactory.deploy(); console.log(contract); } main().then(() => process.exit(0)).catch((error) => { console.error(error); process.exit(1); });` The above code is my deploy.js code. ![er1](https://user-images.githubusercontent.com/63850192/223862863-943dac2a-3df1-48bd-b539-4cf4b95ad47f.jpg) ![er2](https://user-images.githubusercontent.com/63850192/223862869-d11d2555-361c-44b2-93d1-8857ed6f679c.jpg) ![er3](https://user-images.githubusercontent.com/63850192/223862872-6846c74f-a2c5-4bd0-b5d2-699185bb06b3.jpg) Please help me rectify my error
alymurtazamemon commented 1 year ago

@AnnachiPSP Hey, I have answered your query in a discussion(#5037) but this is not a course-related issue instead it is your code-related issue due to that I am closing this.

closing #5038