Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.ethereum not injected in iframes #1616

Open
stephancill opened this issue Jul 4, 2024 · 1 comment
Open

window.ethereum not injected in iframes #1616

stephancill opened this issue Jul 4, 2024 · 1 comment
Labels
enhancement New feature or request feedback Improvements proposed

Comments

@stephancill
Copy link

We're working on frames.fun, which adds farcaster frames to X using iframes - for some reason window.ethereum is not available in the added iframes we add to the page whereas metamask is.

Do you have any ideas around why this could be the case?

Maybe the content script load isn't triggered multiple times due to some deduplication by tab?

Happy to provide more details/repro if nothing comes to mind

@DanielSinclair DanielSinclair added the feedback Improvements proposed label Jul 8, 2024
@DanielSinclair
Copy link
Contributor

Hi @stephancill. Thank you for highlighting this. We currently don't inject our provider into iframes because of known vulnerabilities with this approach that wallets have experienced in the past. But we are reevaluating and discussing to see if there is a better approach given your valid usecase.

I have a few recommendations of a better way to approach this:

  • Use EIP-6963 and inject mipd into the page directly (i.e. x.com)
  • Pass messages to and from your iframes, inpage script, and background script to maintain a singular provider instance
  • Require only one connection approval from the user. In the Farcaster world, you're essentially putting trust in Farcaster to forward frame transactions. You should follow this model within your extension, and only ask the user to approve one dApp connection approval
  • Prepare transactions on the client-side. With Frames or Blinks, you typically wouldn't need to interact with window directly. Rather your Frame would return a prepared transaction at an endpoint, and Farcaster or Blinks would forward this transaction to the wallet. You would want to maintain this for compatibility; otherwise the frames would work with Frames.fun, but not Farcaster, and vice versa.

@DanielSinclair DanielSinclair added the enhancement New feature or request label Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feedback Improvements proposed
Projects
None yet
Development

No branches or pull requests

2 participants