Skip to content

vm.signTypedData or vm.generateEIP712Digest #3330

Closed as not planned
Closed as not planned
@colinnielsen

Description

@colinnielsen

Component

Forge

Describe the feature you would like

For EIP712 testing, it would be great to have a EIP712 digest generator that creates a 32 byte digest based the types, domain, and values following the algorithm defined in the EIP712 spec, or even a fully built signedTypedData cheatcode.

I've had a lot of headache recently with EIP712 foundry tests passing when they shouldn't have because there was no way to test if a contract is computing a digest properly.

I am not sure what cheatcodes would look like in solidity, but I imagine passing a it:

  1. EIP712 domain struct
  2. The EIP712 type def: eg: Transaction(Person from,Person to,Asset tx)Asset(address token,uint256 amount)Person(address wallet,string name)
  3. The abi.encodePacked() values of the struct

This could be a possible interface

function generateEIP712Digest(EIP712Domain memory domain, string memory eip712Type, bytes memory structValue) public view returns (string memory);

function signTypedData(uint256 privateKey, EIP712Domain memory domain, string memory eip712Type, bytes memory structValue) public view returns (uint8 v, bytes32 r, bytes32 s);

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions