When I open the below HTML code in Mist 0.11.1 the popup shows empty that is window.Web3 is undefined!

How to make window.Web3 to work in Mist?

My code similar to this works in MetaMask but not in Mist.

<title>Test Web3</title>

I experiment on Ubuntu Linux 18.10.

Well, a real code from this site:

async function myweb3_init(init) {
    var web3js;
    // Modern dapp browsers...
    if (window.ethereum) {
        window.web3 = new Web3(ethereum);
        try {
            // Request account access if needed
            await ethereum.enable();
            // Accounts now exposed
        } catch (error) {
            // User denied account access...
    // Legacy dapp browsers...
    else if (window.web3) {
        window.web3 = new Web3(web3.currentProvider);
        // Accounts always exposed
    // Non-dapp browsers...
    else {
        alert('Non-Ethereum browser detected. You should consider trying MetaMask!');
    return web3js;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.