我有这个接口
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;
}
}