Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

encode_eip712 doesn't work correctly when int256 is used #2785

Open
@fvictorio

Description

@fvictorio

Version

ethers-core v2.0.14 (https://github.com/gakonst/ethers-rs#51fe937f)

Platform
GNU/Linux x86_64

Description

TypedData::encode_eip712 doesn't work correctly when an int256 is used. This is easier explained with some tests, so I opened a WIP PR with a couple of tests: #2784

Both tests use almost the same EIP712 data, except one uses uint256 and the other one uses int256.

I'm pretty sure the int256 hash used in the test is correct because I verified it both with viem and ethers.js:

const viem = require("viem")
const ethers = require("ethers")

const typedData = {
  "domain": {
    "name": "TestName",
    "version": "1",
    "chainId": 31337,
    "verifyingContract": "0x1111111111111111111111111111111111111111",
  },
  "types": {
    "Test": [{ "name": "amount", "type": "int256" }],
  },
  "message": {
    "amount": "1234",
  },
  "primaryType": "Test",
};

console.log("viem", viem.hashTypedData(typedData))
console.log("ethers", ethers.TypedDataEncoder.hash(typedData.domain, typedData.types, typedData.message))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions