Skip to content

eip712HashStruct

function eip712HashStruct(
string calldata typeName,
bytes calldata abiEncodedData
) external pure returns (bytes32);

Returns the EIP-712 struct hash for a registered struct name (e.g. "Mail") and its abi.encode-d value.

This is not the final signable digest. To produce the digest that ecrecover expects, combine the struct hash with a domain separator: keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)). Alternatively, use eip712HashTypedData to compute the complete digest in one call.

Note: Requires the test.solidity.eip712Types configuration. See the EIP-712 type hashing guide for setup and full signing examples.

Mail memory m = Mail({
from: Person({ wallet: address(0xA), name: "Alice" }),
to: Person({ wallet: address(0xB), name: "Bob" }),
contents: "hello"
});
bytes32 hash = cheats.eip712HashStruct("Mail", abi.encode(m));