PatrickAlphaC / ethers-simple-storage-fcc

90 stars 128 forks source link

"providers" property doesnt exist on type ethers (TypeScript) #68

Open MielkeDaniel opened 1 year ago

MielkeDaniel commented 1 year ago
import { ethers } from "ethers";

async function main() {
  // http://127.0.0.1:7545

  let provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:7545");
}

Underlines "providers"-keyword with the following error:

Property 'providers' does not exist on type 'typeof import("/Users/danielmielke/Code/hh-fcc/ethers-simple-storage/node_modules/ethers/types/ethers")'.

Any idea why? Buggy ethers version? Im using ^6.1.0

PatrickAlphaC commented 1 year ago

Could you see this?

https://github.com/PatrickAlphaC/ethers-simple-storage-fcc/pull/67

dustinpor2626 commented 1 year ago
const ether = require("ethers");

async function main() {
const provider = new ether.JsonRpcProvider("http://127.0.0.1:7545");
}
   "dependencies": {
    "ethers": "^6.1.0",
    "solc": "^0.8.19"
  },
sunnyStefi commented 1 year ago

@Mielke

  1. Make sure to always check the current docs to stay at their pace! it's not buggy, they change the functions.

cit. all the ethers.providers.* are being moved to ethers.*

This works for ethers v 6.2.0:

let provider = new ethers.getDefaultProvider("http://127.0.0.1:7545")
  1. There are other issues that arise with ethers 6.2.0:
const deploymentReceipt = await contract.deployTransaction.wait(1)

should be changed into

const txResponse = await contract.deploymentTransaction().wait()
RomanIvn commented 1 year ago

Also console.log(`Contract deployed to ${contract.address}`) changed toconsole.log(`Contract deployed to ${await contract.getAddress()}`)