-
Notifications
You must be signed in to change notification settings - Fork 295
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
Issue and potential solutions for EIP712 support #3643
Comments
@peekpi what is the front-end you are referring to? changing the contract code as mention will result in compatibility to only metamask. harmony one wallet will not work. |
Another solution is to add hard fork in the chain to return eth-compatible chainID (1666600000...) for eth-compatible transactions. |
this is not possible right? currently the |
you are right. actually, EIP712 requires that the wallet refuse to sign if the chainID in the |
There are a few issues with the proposed change. Ideally the For smart contracts that utilize harmony specific chain id, a better solution could be to introduce a new field, such as
|
Summary
When calculating a EIP712 transaction hash, the
uint256 chainID
may be used. This field is optional in EIP712, but it is used in most EIP712 dApps.The problem is that harmony has two chainID, one is the original chainID and the other is added later for Ethereum format transactions.
Thie may cause EIP712 transactions to fail because the EIP712 contract uses the original chainID, but Metamask uses the Ethereum chainID.
For example, a typical code for getting a chainID in an EIP712 contract would look like this:
In mainnet it will return 1, then the contract uses the result to verify EIP712 transactions. But when Metamask generates an EIP712 transaction, it uses the Ethereum ChainID which is 1666600000 for the mainnet. Then the transaction commits to the contract and verifies fails.
Proposal
To avoid this issue, you can modify either the contract code or the front-end code.
For the contract, you can change it like follows:
For the front-end, you need to change the Ethereum chainID to Harmony chainID:The text was updated successfully, but these errors were encountered: