ethers-simple-storage-fcc icon indicating copy to clipboard operation
ethers-simple-storage-fcc copied to clipboard

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

Open DanielJonasMielke opened this issue 2 years ago • 4 comments

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

DanielJonasMielke avatar Mar 15 '23 15:03 DanielJonasMielke

Could you see this?

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

PatrickAlphaC avatar Mar 17 '23 02:03 PatrickAlphaC

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"
  },

dustinpor2626 avatar Mar 19 '23 14:03 dustinpor2626

@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()

sunnyStefi avatar Mar 21 '23 15:03 sunnyStefi

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

RomanIvn avatar Apr 11 '23 12:04 RomanIvn