Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

How to run ganache in browser #1704

Closed
dyfvicture opened this issue Nov 30, 2021 · 2 comments
Closed

How to run ganache in browser #1704

dyfvicture opened this issue Nov 30, 2021 · 2 comments

Comments

@dyfvicture
Copy link

dyfvicture commented Nov 30, 2021

How to run ganache in browser? Could anyone help to figure out where I am wrong when I fork a provider, thank.

I did a test follow: https://github.com/trufflesuite/ganache/blob/efa9c470503f667294fe78df6e0f6ee70382a151/test/smoke/forking/infura/simple.js

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web/ganache.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/web3/1.2.7-rc.0/web3.min.js"></script>

<script>
     async function init() {
          const web3 = new Web3();
          const provider = Ganache.provider({
                fork: `https://${network}.infura.io/v3/${INFURA_KEY}@${blockHeight}`,
                logger
          }); // ERROR: o.URL is not a constructor
          web3.setProvider(provider);
     }

    window.addEventListener('load', async () => {
         await init();
    })
</script>
@davidmurdoch
Copy link
Member

Forking doesn't yet work in the browser.

@dyfvicture
Copy link
Author

Forking doesn't yet work in the browser.

OK, thanks for your reply

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants