Hello, when I tried to use CDN:
MetaMaskSDK is not a constructor
But using with node modules works fine. Whats the problem?
Hello, when I tried to use CDN:
MetaMaskSDK is not a constructor
But using with node modules works fine. Whats the problem?
Hello @user2149 !
Welcome to MetaMask community!
What version of @metamask/sdk are you using? 3.0.0 or 0.2.4 ?
Show the library import code.
Thanks for you reply.
Im using CDN from MetaMask docs:
https://docs.metamask.io/wallet/how-to/use-sdk/javascript/pure-js/
<script src="https://c0f4f41c-2f55-4863-921b-sdk-docs.github.io/cdn/metamask-sdk.js"></script>
Try pass an object with options as an argument in MetaMaskSDK like this:
<script>
console.log(MetaMaskSDK);
const opt = {
forceInjectProvider: typeof window.ethereum === 'undefined',
}
const MMSDK = new MetaMaskSDK.MetaMaskSDK(opt);
ethereum.request({method: 'eth_requestAccounts'})
</script>
thats work with
forceInjectProvider: true;
becauase forceInjectProvider receives a type bool, thanks for you solution!! Greetings.
@user2149 You may hardcode forceInjectProvider, but checking against window.ethereum is more flexible.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.