Issue
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
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;
  }
}
                        
                        Answered By - Yilmaz Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.