-
Notifications
You must be signed in to change notification settings - Fork 12
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
hardhat does not support EIP-712 for payloads with signed integers #407
Comments
This issue appears to be limited to the hardhat node. If I update the unit test above to construct an Updated test:
|
Thanks @willmeister, I'll look into this. |
Thanks for the great reproduction steps @willmeister! I can confirm that this wasn't happening with |
The underlying cause seems to be gakonst/ethers-rs#2785 Hopefully that gets fixed and released soon. If not, we should try to find a workaround (perhaps migrating this part of the code to alloy is the solution, and it's something we need to eventually do anyway since ethers-rs is deprecated). |
We've released EDR v0.3.8 with a fix for this issue. To upgrade to the latest EDR version immediately, you can remove your You can verify that you’re using the latest version of EDR by running the following command: |
Version of Hardhat
2.22.3
What happened?
Attempting to create an EIP-712 signature for a type that contains a signed integer (e.g.
int256
), results in an error in one of two ways:ethers.verifyTypedData(...)
)ProviderError: Failed to serialize serde JSON object
Note: The same operation succeeds if the type is instead a
uint256
.Minimal reproduction steps
Fresh install unit test example
npm install --save-dev hardhat
npx hardhat init
(choose to use typescript without viem, default for everything else)test/sigTest.ts
:npx hardhat test
uint256
signature succeeding and theint256
signature either throwing or being uncrecoverable:Test via JSON RPC pointing at local hardhat node:
npx hardhat node
curl {"jsonrpc":"2.0","id":"1","method":"eth_signTypedData_v4","params":["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",{"types":{"Test":[{"name":"amount","type":"int256"}],"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}]},"domain":{"name":"TestName","version":"1","chainId":"0x7a69","verifyingContract":"0x1111111111111111111111111111111111111111"},"primaryType":"Test","message":{"amount":"-100000000"}}]} http://127.0.0.1:8545/
Failed to serialize serde JSON object
errorcurl
command with{"amount":"100000000"}
(remove negative sign)Note: the node seems to handle an abi-encoded negative
int256
( e.g.0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0a1f00
), but ethers.js v6 encodes BigInts to the decimal string, andhardhat-ethers
signTypedData(...) does the same, indicating that signed decimal integers should be supported, and as pointed out by the unit test example, this does not work end-to-end using hardhat either.Search terms
eth_signTypedData_v4 signTypedData EIP-712 int
The text was updated successfully, but these errors were encountered: