I have this interface
interface IWeb3 {
ethereum?: MetaMaskInpageProvider;
provider?: any;
contract?: any;
};
I found the type for ethereum from import { MetaMaskInpageProvider } from "@metamask/providers"
but could not find others.
I had to install ethers
library
import { MetaMaskInpageProvider } from "@metamask/providers";
import { Contract, providers } from "ethers";
interface IWeb3 {
ethereum?: MetaMaskInpageProvider;
provider?: providers.Web3Provider;
contract?: Contract;
};
Also to be able to use window.ethereum
, I had to set this:
declare global {
interface Window {
ethereum: MetaMaskInpageProvider;
}
}