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

Support extension wallets by serving a website on localhost #18

Open
artistic709 opened this issue Aug 11, 2024 · 5 comments
Open

Support extension wallets by serving a website on localhost #18

artistic709 opened this issue Aug 11, 2024 · 5 comments

Comments

@artistic709
Copy link

Added a way to connect extension wallets: using a localhost web server to forward signature requests to the browser.

@danhper
Copy link
Owner

danhper commented Aug 12, 2024

Hi @artistic709 ,
Could you elaborate a bit on the use case you have in mind please?
There is a plan to run anvil on localhost to be able to fork etc, which would make it possible to connect eclair and the browser wallet to the same development node. Is it what you have in mind?

@artistic709
Copy link
Author

Hi @danhper , this is the scenario I'm considering:
I want to send transactions in production environment via command line. Rather than using a hardware wallet or importing a private key, I would prefer to use, say, a MetaMask account to sign transactions.

@danhper
Copy link
Owner

danhper commented Aug 14, 2024

Ahhh, I see, that makes sense! In theory this is definitely doable but it might be a bit of work, especially given that alloy does not seem to support anything like this out of the box.

I think that the flow could look like:

  1. Spin up an http server to serve a very simple webpage (the page doesn't really need to do anything)
  2. Spin up a websocket server to communicate between eclair and the webpage
  3. Connect from the webpage to eclair's websocket server
  4. When eclair needs to sign something, send a request to the webpage via ws
  5. Request the signature from metamask and sent it back to eclair via ws
  6. Send the signed tx in eclair

This does look like a fun little project but there are a few things I'll be prioritising before it, so I can't really give a timeline for when I think it might be ready.
If you'd like to give it a shot, I'm of course more than open to contributions!
Thanks again for the idea!

@artistic709
Copy link
Author

Yeah I think that will be really helpful for advanced users.
Unfortunately I don't write Rust, but I can make a proof of concept in Python + vanilla JS.

BTW the 5th and 6th steps might not work
because it's very difficult (if not impossible) to ask MetaMask to sign a raw transaction.
Instead, we'll just let MetaMask broadcast the tx and wait for the txid to come back.

@danhper
Copy link
Owner

danhper commented Aug 15, 2024

I see, thanks for the explanation! Yeah, then the transaction would be sent by metamask and the txid would be sent back to eclair via websocket.
A proof-of-concept would be super helpful and the JS part could be used directly, so that would definitely be very welcome, thanks!

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

No branches or pull requests

2 participants