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.
Replies: 2 comments 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.
-
Now in this next.js project global project |
Beta Was this translation helpful? Give feedback.
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);