Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

the issue is coming at JsonRpcProvider can you check it guys #114

Open
Vinodnaruto opened this issue Mar 16, 2024 · 4 comments
Open

the issue is coming at JsonRpcProvider can you check it guys #114

Vinodnaruto opened this issue Mar 16, 2024 · 4 comments

Comments

@Vinodnaruto
Copy link

const ethers = require("ethers");
const fs = require("fs-extra");

const main = async () => {
  // HTTP://127.0.0.1:7545
  const provider = new ethers.Provider.JsonRpcProvider("http://127.0.0.1:7545");
  const wallet = new ethers.Wallet(
    "0xfbf6631ef24e8f33394de624d841f4527c90e745be540d28e14f78827cd5f3c6",
    provider
  );
  const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf-8");
  const binary = fs.readFileSync(
    "./SimpleStorage_sol_SimpleStorage.bin",
    "utf-8"
  );
  const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
  console.log("Deploying, please wait...");
  const contract = await contractFactory.deploy();
  console.log(contract);
};
main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

in the code error was showing at

TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')
    at main (/Users/vinod/Documents/hh-fcc/ethers-simple-storage-fcc/deploy.js:6:40)
    at Object.<anonymous> (/Users/vinod/Documents/hh-fcc/ethers-simple-storage-fcc/deploy.js:21:1)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47
@PatrickAlphaC
Copy link
Owner

Could you try cloning this repo and working with the code here?

@anudeep652
Copy link

anudeep652 commented Mar 24, 2024

@Vinodnaruto change this

  const provider = new ethers.Provider.JsonRpcProvider("http://127.0.0.1:7545");

to this:

  const provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545");

@gagan-kotian
Copy link

I did this const provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545");
Just to get this error
PS C:\gg> node deploy.js
Deploying, please wait...
Error: missing revert data (action="estimateGas", data=null, reason=null, transaction={ "data": "0x6080604052348015600e575f80fd5b506101718061001c5f395ff3fe608060405234801561000f575f80fd5b506004361061003f575f3560e01c80632e64cec1146100435780636057361d146100615780638381f58a1461007d575b5f80fd5b61004b61009b565b60405161005891906100c9565b60405180910390f35b61007b60048036038101906100769190610110565b6100a3565b005b6100856100ac565b60405161009291906100c9565b60405180910390f35b5f8054905090565b805f8190555050565b5f5481565b5f819050919050565b6100c3816100b1565b82525050565b5f6020820190506100dc5f8301846100ba565b92915050565b5f80fd5b6100ef816100b1565b81146100f9575f80fd5b50565b5f8135905061010a816100e6565b92915050565b5f60208284031215610125576101246100e2565b5b5f610132848285016100fc565b9150509291505056fea2646970667358221220a4745bf85c84ccaf9470d10fb67cd403e9b381954633fcd1d2a5a51fcf383e8e64736f6c63430008190033", "from": "0xfFB3DB707C131f907A4E5B93D4FF4fAF9aE51a9C", "to": null }, invocation=null, revert=null, code=CALL_EXCEPTION, version=6.11.1)
at makeError (C:\gg\node_modules\ethers\lib.commonjs\utils\errors.js:129:21)
at getBuiltinCallException (C:\gg\node_modules\ethers\lib.commonjs\abi\abi-coder.js:105:37)
at AbiCoder.getBuiltinCallException (C:\gg\node_modules\ethers\lib.commonjs\abi\abi-coder.js:206:16)
at JsonRpcProvider.getRpcError (C:\gg\node_modules\ethers\lib.commonjs\providers\provider-jsonrpc.js:668:43)
at C:\gg\node_modules\ethers\lib.commonjs\providers\provider-jsonrpc.js:302:45
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'CALL_EXCEPTION',
action: 'estimateGas',
data: null,
reason: null,
transaction: {
to: null,
data: '0x6080604052348015600e575f80fd5b506101718061001c5f395ff3fe608060405234801561000f575f80fd5b506004361061003f575f3560e01c80632e64cec1146100435780636057361d146100615780638381f58a1461007d575b5f80fd5b61004b61009b565b60405161005891906100c9565b60405180910390f35b61007b60048036038101906100769190610110565b6100a3565b005b6100856100ac565b60405161009291906100c9565b60405180910390f35b5f8054905090565b805f8190555050565b5f5481565b5f819050919050565b6100c3816100b1565b82525050565b5f6020820190506100dc5f8301846100ba565b92915050565b5f80fd5b6100ef816100b1565b81146100f9575f80fd5b50565b5f8135905061010a816100e6565b92915050565b5f60208284031215610125576101246100e2565b5b5f610132848285016100fc565b9150509291505056fea2646970667358221220a4745bf85c84ccaf9470d10fb67cd403e9b381954633fcd1d2a5a51fcf383e8e64736f6c63430008190033',
from: '0xfFB3DB707C131f907A4E5B93D4FF4fAF9aE51a9C'
},
invocation: null,
revert: null,
shortMessage: 'missing revert data',
info: {
error: {
message: 'VM Exception while processing transaction: invalid opcode',
stack: 'RuntimeError: VM Exception while processing transaction: invalid opcode\n' +
' at exactimate (C:\Program Files\WindowsApps\GanacheUI_2.7.1.0_x64__rb4352f0jd4m2\app\resources\static\node\node_modules\ganache\dist\node\1.js:2:182136)',
code: -32000,
name: 'RuntimeError',
data: [Object]
},
payload: {
method: 'eth_estimateGas',
params: [Array],
id: 3,
jsonrpc: '2.0'
}
}
}

@APJG-7
Copy link

APJG-7 commented Apr 8, 2024

I also got the same error and I tried this by setting the gas limit

const factory = new ethers.ContractFactory(abi, bin, wallet);
  const options = {
    gasLimit: 3000000,
  }

  const contract = await factory.deploy(options);

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

No branches or pull requests

5 participants