如何找到以太坊、提供商和合约的类型

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

我有这个界面

interface IWeb3 {  
  ethereum?: MetaMaskInpageProvider;
  provider?: any;
  contract?: any;
};

我从 import { MetaMaskInpageProvider } from "@metamask/providers" 找到了以太坊的类型,但找不到其他类型。

我必须安装 ethers

import { MetaMaskInpageProvider } from "@metamask/providers";
import { Contract, providers } from "ethers";

interface IWeb3 {  
  ethereum?: MetaMaskInpageProvider;
  provider?: providers.Web3Provider;
  contract?: Contract;
};

也是为了能够使用 window.ethereum,我必须这样设置:

declare global {
  interface Window {
    ethereum: MetaMaskInpageProvider;
  }
}