Open sneaker1 opened 3 years ago
The dynamic script should be standalone because it's sandboxed in an iframe for security reasons. In most environments it will fail reading parameters from the parent window.
IIRC Web3.givenProvider
relies on the global environment (window
) and so does window.ethereum
(obviously). Modern browsers will restrict what you can do from within an iframe
. While in the past things like window.parent.variableFromParentGlobalSope
were allowed, this is no longer possible. When you try to access Web3.givenProvider
inside an iframe
, it's simply not there because it's on the parent window scope.
I can't know for sure, but I guess that the MetaMask extension on Firefox injects itself as the givenProvider
for the main window and its children frames. Probably that is not possible in Chromium-based browsers. But this is just a hunch.
Lastly, we usually avoid depending on the user having MetaMask installed to simply see a dispute. Since it's just a matter of reading data, we recommend using a read-only RPC endpoint for this purpose.
Hello,
i am using the metaevidence with a dynamicScript. It generally works and I think i know how to use it.
I need to load dynamic data from a contract. To connect to the blockchain I want to use metamask. I don't want to use a infura link. I use:
const web3 = new Web3(Web3.givenProvider);
This does work in Firefox. In Chromium and Brave, unfortunately, Web3.givenProvider is null. And window.ethereum is undefined.
I have already tried different versions of metamask. Always the same.
Do you have any idea what could be the reason, why this is only working in Firefox?
Please take a look at it on case 919 on the Kovan testnet. https://court.kleros.io/cases/919 Watch the console output.
This is the dynamic script that is used.
Regards, Sneaker