'How to find the type for ethereum, provider, and contract

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.



Solution 1:[1]

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;
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yilmaz