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

Partial compatilibity with MetaMask #22

Open
livid opened this issue Mar 3, 2022 · 3 comments
Open

Partial compatilibity with MetaMask #22

livid opened this issue Mar 3, 2022 · 3 comments

Comments

@livid
Copy link

livid commented Mar 3, 2022

Make some essential features usable with MetaMask by adding a JSON RPC endpoint:

  • Show balance
  • Send Starcoin to other addresses

Since MetaMask is already on millions of users' Chrome, if users can access some Starcoin features from MetaMask, it would be an easier first step for users to try Starcoin.

Some more complicated features like interacting with an EVM contract would not be possible at the moment.

@jolestar
Copy link
Member

jolestar commented Mar 9, 2022

Let me technically derive the feasibility of this solution:

We build an RPC proxy that translates requests to Ethereum RPC API into requests for Starcoin and the response of starcoin RPC into the response of Ethereum.

Translating the query API should not be too difficult. It is mainly an engineering task.

However, if we want to submit transactions, we encounter two difficulties:

  1. The transaction signed by MetaMask is an Ethereum transaction and cannot be converted to a Starcoin transaction. We can not change a transaction after it is signed.
  2. Starcoin's address is different from Ethereum's address and requires a mapping method.

@jolestar
Copy link
Member

jolestar commented Mar 9, 2022

One solution maybe is:

The user sends the Ethereum transaction to the proxy node, which packages the Ethereum transaction into a payload of Starcoin transaction and submits it to a smart contract on the Starcoin chain through the proxy account, we call the smart contract EVMProxy.

The EVMProxy parses the Ethereum transaction and then verify and executes the transaction in the smart contract by simulating the user.

  1. The EVMProxy on starcoin can verify Ethereum transaction signature by 0x::Signature::ecrecover
  2. EVMProxy can use Signer Delegate to simulate the user.
  3. We take the first 16 bytes of the Ethereum address as the Starcoin address.
  4. The account delegated by EVMProxy, can not send transactions directly, so the proxy can provide a DApp to support withdrawing Token to another Starcoin address by signing a withdrawal transaction.

@jolestar
Copy link
Member

jolestar commented Mar 9, 2022

Another approach might be to support Walletconnect, it supports multi chain, I record an issue: starcoinorg/starmask-extension#54

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

No branches or pull requests

2 participants