ethers.provider is not defined #4196
-
I am using ethers library for my project but import {ethers} from 'ethers';
const { ethereum } = window as any;
const getEthereumContract = () => {
const provider = new ethers.providers.Web3Provider(ethereum);
const signer = provider.getSigner();
const { Contract } = ethers;
const contract = new Contract(contractAddress, contractABI, signer);
console.log({
provider,
signer,
contract
})
}
|
Beta Was this translation helpful? Give feedback.
Answered by
gurwindersinghdev
Jun 30, 2023
Replies: 1 comment 2 replies
-
hi, you are the using the old documentation , have a look on new documentation https://docs.ethers.org/v6/getting-started/ const provider = new ethers.providers.Web3Provider(ethereum); providers.Web3Providers is replaced by this ..... (BrowserProvider) const provider = new ethers.BrowserProvider(window.ethereum); |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Yana-Gupta
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi, you are the using the old documentation , have a look on new documentation
https://docs.ethers.org/v6/getting-started/
const provider = new ethers.providers.Web3Provider(ethereum);
providers.Web3Providers is replaced by this ..... (BrowserProvider)
const provider = new ethers.BrowserProvider(window.ethereum);