I cannot use "window.ethereum" AND "fetch" in snaps ! and i have added them to the initialPermissions

I cannot use “window.ethereum” AND “fetch” in snaps !!! and i have added them to the initialPermmissions

Screenshot 2023-08-03 160157

I tried “eth_accounts”, “eth_getBalance”, … but it failed to retrieve any data !

If you could DM me with your repository I could have a look. You should be able to use fetch in a snap after installing it and running it inside of MetaMask Flask. As for window.ethereum, it’s actually just ethereum in the Snaps execution environment. However, you will only have access to read methods. You do not have access to account methods like eth_accounts. That requires connecting to an account which you cannot do from a snap.

Here’s an example of a snap that uses the ethereum provider: GitHub - Montoya/mobymask-snap: Uses MobyMask to warn you when interacting with possible phishers

And here’s a snap that uses network access:

1 Like

thx But why did not mentioned it in the documents ?

We are in the process of updating our documentation. That’s a good callout. It is mentioned here but not clearly enough: Snaps permissions | MetaMask developer documentation

I will talk to the team and get this improved.

1 Like

Thx, please mention a list of ethereum JSON-RPC apis that we can use inside a snap .